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

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

Issue 2085673002: Remove calls to MessageLoop::current() in extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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
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 "base/memory/ref_counted.h"
Reilly Grant (use Gerrit) 2016/06/27 20:01:58 Duplicate include.
fdoray 2016/06/29 14:25:05 Done.
13 #include "base/single_thread_task_runner.h"
12 #include "extensions/common/extension_resource.h" 14 #include "extensions/common/extension_resource.h"
13 15
14 namespace base {
15 class MessageLoop;
16 }
17
18 // This file defines an interface for reading a file asynchronously on a 16 // This file defines an interface for reading a file asynchronously on a
19 // background thread. 17 // background thread.
20 // Consider abstracting out a FilePathProvider (ExtensionResource) and moving 18 // Consider abstracting out a FilePathProvider (ExtensionResource) and moving
21 // back to chrome/browser/net if other subsystems want to use it. 19 // back to chrome/browser/net if other subsystems want to use it.
22 class FileReader : public base::RefCountedThreadSafe<FileReader> { 20 class FileReader : public base::RefCountedThreadSafe<FileReader> {
23 public: 21 public:
24 // 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.
25 typedef base::Callback<void(bool, const std::string&)> Callback; 23 typedef base::Callback<void(bool, const std::string&)> Callback;
26 24
27 FileReader(const extensions::ExtensionResource& resource, 25 FileReader(const extensions::ExtensionResource& resource,
28 const Callback& callback); 26 const Callback& callback);
29 27
30 // Called to start reading the file on a background thread. Upon completion, 28 // Called to start reading the file on a background thread. Upon completion,
31 // the callback will be notified of the results. 29 // the callback will be notified of the results.
32 void Start(); 30 void Start();
33 31
34 private: 32 private:
35 friend class base::RefCountedThreadSafe<FileReader>; 33 friend class base::RefCountedThreadSafe<FileReader>;
36 34
37 virtual ~FileReader(); 35 virtual ~FileReader();
38 36
39 void ReadFileOnBackgroundThread(); 37 void ReadFileOnBackgroundThread();
40 38
41 extensions::ExtensionResource resource_; 39 extensions::ExtensionResource resource_;
42 Callback callback_; 40 Callback callback_;
43 base::MessageLoop* origin_loop_; 41 const scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_;
44 }; 42 };
45 43
46 #endif // EXTENSIONS_BROWSER_FILE_READER_H_ 44 #endif // EXTENSIONS_BROWSER_FILE_READER_H_
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/incident_reporting/state_store_unittest.cc ('k') | extensions/browser/file_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698