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

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

Issue 256022: Loads local resources from current locale subtree if available, if not it fal... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/net/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 "chrome/browser/chrome_thread.h" 8 #include "chrome/browser/chrome_thread.h"
9 #include "chrome/common/extensions/extension_resource.h"
9 10
10 FileReader::FileReader(const FilePath& path, Callback* callback) 11 FileReader::FileReader(const ExtensionResource& resource, Callback* callback)
11 : path_(path), 12 : resource_(resource),
12 callback_(callback), 13 callback_(callback),
13 origin_loop_(MessageLoop::current()) { 14 origin_loop_(MessageLoop::current()) {
14 DCHECK(callback_); 15 DCHECK(callback_);
15 } 16 }
16 17
17 void FileReader::Start() { 18 void FileReader::Start() {
18 ChromeThread::GetMessageLoop(ChromeThread::FILE)->PostTask(FROM_HERE, 19 ChromeThread::GetMessageLoop(ChromeThread::FILE)->PostTask(FROM_HERE,
19 NewRunnableMethod(this, &FileReader::ReadFileOnBackgroundThread)); 20 NewRunnableMethod(this, &FileReader::ReadFileOnBackgroundThread));
20 } 21 }
21 22
22 void FileReader::ReadFileOnBackgroundThread() { 23 void FileReader::ReadFileOnBackgroundThread() {
23 std::string data; 24 std::string data;
24 bool success = file_util::ReadFileToString(path_, &data); 25 bool success = file_util::ReadFileToString(resource_.GetFilePath(), &data);
25 origin_loop_->PostTask(FROM_HERE, NewRunnableMethod( 26 origin_loop_->PostTask(FROM_HERE, NewRunnableMethod(
26 this, &FileReader::RunCallback, success, data)); 27 this, &FileReader::RunCallback, success, data));
27 } 28 }
28 29
29 void FileReader::RunCallback(bool success, const std::string& data) { 30 void FileReader::RunCallback(bool success, const std::string& data) {
30 callback_->Run(success, data); 31 callback_->Run(success, data);
31 delete callback_; 32 delete callback_;
32 } 33 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/file_reader.h ('k') | chrome/browser/extensions/file_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698