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

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

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/extensions/extensions_ui.cc ('k') | chrome/browser/extensions/file_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 //
5 // This file defines an interface for reading a file asynchronously on a
6 // background thread.
7 4
8 #ifndef CHROME_BROWSER_NET_FILE_READER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_FILE_READER_H_
9 #define CHROME_BROWSER_NET_FILE_READER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_FILE_READER_H_
10 7
11 #include <string> 8 #include <string>
12 9
13 #include "base/file_path.h"
14 #include "base/ref_counted.h" 10 #include "base/ref_counted.h"
15 #include "base/task.h" 11 #include "base/task.h"
12 #include "chrome/common/extensions/extension_resource.h"
16 13
17 class MessageLoop; 14 class MessageLoop;
18 15
16 // This file defines an interface for reading a file asynchronously on a
17 // background thread.
18 // Consider abstracting out a FilePathProvider (ExtensionResource) and moving
19 // back to chrome/browser/net if other subsystems want to use it.
19 class FileReader : public base::RefCountedThreadSafe<FileReader> { 20 class FileReader : public base::RefCountedThreadSafe<FileReader> {
20 public: 21 public:
21 // Reports success or failure and the data of the file upon success. 22 // Reports success or failure and the data of the file upon success.
22 typedef Callback2<bool, const std::string&>::Type Callback; 23 typedef Callback2<bool, const std::string&>::Type Callback;
23 24
24 FileReader(const FilePath& path, Callback* callback); 25 FileReader(const ExtensionResource& resource, Callback* callback);
25 26
26 // Called to start reading the file on a background thread. Upon completion, 27 // Called to start reading the file on a background thread. Upon completion,
27 // the callback will be notified of the results. 28 // the callback will be notified of the results.
28 void Start(); 29 void Start();
29 30
30 private: 31 private:
31 void ReadFileOnBackgroundThread(); 32 void ReadFileOnBackgroundThread();
32 void RunCallback(bool success, const std::string& data); 33 void RunCallback(bool success, const std::string& data);
33 34
34 FilePath path_; 35 ExtensionResource resource_;
35 Callback* callback_; 36 Callback* callback_;
36 MessageLoop* origin_loop_; 37 MessageLoop* origin_loop_;
37 }; 38 };
38 39
39 #endif // CHROME_BROWSER_NET_FILE_READER_H_ 40 #endif // CHROME_BROWSER_EXTENSIONS_FILE_READER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extensions_ui.cc ('k') | chrome/browser/extensions/file_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698