Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Side by Side Diff: chrome/browser/extensions/file_reader.cc

Issue 8437002: Move BrowserThread to content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: A few updates. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/file_reader.h" 5 #include "chrome/browser/extensions/file_reader.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/common/extensions/extension_resource.h" 9 #include "chrome/common/extensions/extension_resource.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 11
12 using content::BrowserThread;
13
12 FileReader::FileReader(const ExtensionResource& resource, Callback* callback) 14 FileReader::FileReader(const ExtensionResource& resource, Callback* callback)
13 : resource_(resource), 15 : resource_(resource),
14 callback_(callback), 16 callback_(callback),
15 origin_loop_(MessageLoop::current()) { 17 origin_loop_(MessageLoop::current()) {
16 DCHECK(callback_); 18 DCHECK(callback_);
17 } 19 }
18 20
19 void FileReader::Start() { 21 void FileReader::Start() {
20 BrowserThread::PostTask( 22 BrowserThread::PostTask(
21 BrowserThread::FILE, FROM_HERE, 23 BrowserThread::FILE, FROM_HERE,
22 NewRunnableMethod(this, &FileReader::ReadFileOnBackgroundThread)); 24 NewRunnableMethod(this, &FileReader::ReadFileOnBackgroundThread));
23 } 25 }
24 26
25 FileReader::~FileReader() {} 27 FileReader::~FileReader() {}
26 28
27 void FileReader::ReadFileOnBackgroundThread() { 29 void FileReader::ReadFileOnBackgroundThread() {
28 std::string data; 30 std::string data;
29 bool success = file_util::ReadFileToString(resource_.GetFilePath(), &data); 31 bool success = file_util::ReadFileToString(resource_.GetFilePath(), &data);
30 origin_loop_->PostTask(FROM_HERE, NewRunnableMethod( 32 origin_loop_->PostTask(FROM_HERE, NewRunnableMethod(
31 this, &FileReader::RunCallback, success, data)); 33 this, &FileReader::RunCallback, success, data));
32 } 34 }
33 35
34 void FileReader::RunCallback(bool success, const std::string& data) { 36 void FileReader::RunCallback(bool success, const std::string& data) {
35 callback_->Run(success, data); 37 callback_->Run(success, data);
36 delete callback_; 38 delete callback_;
37 } 39 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/file_manager_util.cc ('k') | chrome/browser/extensions/file_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698