| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "chrome/browser/extensions/file_reader.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/file_util.h" | |
| 9 #include "base/message_loop.h" | |
| 10 #include "chrome/common/extensions/extension_resource.h" | |
| 11 #include "content/public/browser/browser_thread.h" | |
| 12 | |
| 13 using content::BrowserThread; | |
| 14 | |
| 15 FileReader::FileReader(const ExtensionResource& resource, | |
| 16 const Callback& callback) | |
| 17 : resource_(resource), | |
| 18 callback_(callback), | |
| 19 origin_loop_(MessageLoop::current()) { | |
| 20 } | |
| 21 | |
| 22 void FileReader::Start() { | |
| 23 BrowserThread::PostTask( | |
| 24 BrowserThread::FILE, FROM_HERE, | |
| 25 base::Bind(&FileReader::ReadFileOnBackgroundThread, this)); | |
| 26 } | |
| 27 | |
| 28 FileReader::~FileReader() {} | |
| 29 | |
| 30 void FileReader::ReadFileOnBackgroundThread() { | |
| 31 std::string data; | |
| 32 bool success = file_util::ReadFileToString(resource_.GetFilePath(), &data); | |
| 33 origin_loop_->PostTask(FROM_HERE, base::Bind(callback_, success, data)); | |
| 34 } | |
| OLD | NEW |