Remove linux_chromium_gn_dbg from the chromium CQ.
[chromium-blink-merge.git] / extensions / browser / file_reader.cc
blobebb9ed4bac6f9c206a6a888c27f15fd8578822e2
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "extensions/browser/file_reader.h"
7 #include "base/bind.h"
8 #include "base/files/file_util.h"
9 #include "base/message_loop/message_loop.h"
10 #include "content/public/browser/browser_thread.h"
12 using content::BrowserThread;
14 FileReader::FileReader(const extensions::ExtensionResource& resource,
15 const Callback& callback)
16 : resource_(resource),
17 callback_(callback),
18 origin_loop_(base::MessageLoop::current()) {}
20 void FileReader::Start() {
21 BrowserThread::PostTask(
22 BrowserThread::FILE, FROM_HERE,
23 base::Bind(&FileReader::ReadFileOnBackgroundThread, this));
26 FileReader::~FileReader() {}
28 void FileReader::ReadFileOnBackgroundThread() {
29 std::string data;
30 bool success = base::ReadFileToString(resource_.GetFilePath(), &data);
31 origin_loop_->PostTask(FROM_HERE, base::Bind(callback_, success, data));