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

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

Issue 13243003: Move MessageLoop to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | « content/shell/shell_url_request_context_getter.h ('k') | ipc/ipc_test_base.h » ('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) 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 #ifndef EXTENSIONS_BROWSER_FILE_READER_H_ 5 #ifndef EXTENSIONS_BROWSER_FILE_READER_H_
6 #define EXTENSIONS_BROWSER_FILE_READER_H_ 6 #define EXTENSIONS_BROWSER_FILE_READER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "extensions/common/extension_resource.h" 12 #include "extensions/common/extension_resource.h"
13 13
14 namespace base {
14 class MessageLoop; 15 class MessageLoop;
16 }
15 17
16 // This file defines an interface for reading a file asynchronously on a 18 // This file defines an interface for reading a file asynchronously on a
17 // background thread. 19 // background thread.
18 // Consider abstracting out a FilePathProvider (ExtensionResource) and moving 20 // Consider abstracting out a FilePathProvider (ExtensionResource) and moving
19 // back to chrome/browser/net if other subsystems want to use it. 21 // back to chrome/browser/net if other subsystems want to use it.
20 class FileReader : public base::RefCountedThreadSafe<FileReader> { 22 class FileReader : public base::RefCountedThreadSafe<FileReader> {
21 public: 23 public:
22 // Reports success or failure and the data of the file upon success. 24 // Reports success or failure and the data of the file upon success.
23 typedef base::Callback<void(bool, const std::string&)> Callback; 25 typedef base::Callback<void(bool, const std::string&)> Callback;
24 26
25 FileReader(const extensions::ExtensionResource& resource, 27 FileReader(const extensions::ExtensionResource& resource,
26 const Callback& callback); 28 const Callback& callback);
27 29
28 // Called to start reading the file on a background thread. Upon completion, 30 // Called to start reading the file on a background thread. Upon completion,
29 // the callback will be notified of the results. 31 // the callback will be notified of the results.
30 void Start(); 32 void Start();
31 33
32 private: 34 private:
33 friend class base::RefCountedThreadSafe<FileReader>; 35 friend class base::RefCountedThreadSafe<FileReader>;
34 36
35 virtual ~FileReader(); 37 virtual ~FileReader();
36 38
37 void ReadFileOnBackgroundThread(); 39 void ReadFileOnBackgroundThread();
38 40
39 extensions::ExtensionResource resource_; 41 extensions::ExtensionResource resource_;
40 Callback callback_; 42 Callback callback_;
41 MessageLoop* origin_loop_; 43 base::MessageLoop* origin_loop_;
42 }; 44 };
43 45
44 #endif // EXTENSIONS_BROWSER_FILE_READER_H_ 46 #endif // EXTENSIONS_BROWSER_FILE_READER_H_
OLDNEW
« no previous file with comments | « content/shell/shell_url_request_context_getter.h ('k') | ipc/ipc_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698