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

Side by Side Diff: chrome/browser/net/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
« no previous file with comments | « chrome/browser/net/file_reader.h ('k') | chrome/browser/net/file_reader_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/net/file_reader.h"
6
7 #include "base/file_util.h"
8 #include "chrome/browser/chrome_thread.h"
9
10 FileReader::FileReader(const FilePath& path, Callback* callback)
11 : path_(path),
12 callback_(callback),
13 origin_loop_(MessageLoop::current()) {
14 DCHECK(callback_);
15 }
16
17 void FileReader::Start() {
18 ChromeThread::GetMessageLoop(ChromeThread::FILE)->PostTask(FROM_HERE,
19 NewRunnableMethod(this, &FileReader::ReadFileOnBackgroundThread));
20 }
21
22 void FileReader::ReadFileOnBackgroundThread() {
23 std::string data;
24 bool success = file_util::ReadFileToString(path_, &data);
25 origin_loop_->PostTask(FROM_HERE, NewRunnableMethod(
26 this, &FileReader::RunCallback, success, data));
27 }
28
29 void FileReader::RunCallback(bool success, const std::string& data) {
30 callback_->Run(success, data);
31 delete callback_;
32 }
OLDNEW
« no previous file with comments | « chrome/browser/net/file_reader.h ('k') | chrome/browser/net/file_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698