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

Unified Diff: extensions/browser/file_reader.h

Issue 2301713002: Remove some UI->FILE->UI thread hops in ExecuteCodeFunction (Closed)
Patch Set: git cl format Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/file_reader.h
diff --git a/extensions/browser/file_reader.h b/extensions/browser/file_reader.h
index 9b391f8635be496d1792bfa6d52f4307aec29bc3..a9f88688cca1e136125037ffdb312357cb91172e 100644
--- a/extensions/browser/file_reader.h
+++ b/extensions/browser/file_reader.h
@@ -19,10 +19,15 @@
class FileReader : public base::RefCountedThreadSafe<FileReader> {
public:
// Reports success or failure and the data of the file upon success.
- typedef base::Callback<void(bool, std::unique_ptr<std::string>)> Callback;
+ using DoneCallback = base::Callback<void(bool, std::unique_ptr<std::string>)>;
+ // Lets the caller accomplish tasks on the file data, after the file content
+ // has been read.
+ // If the file reading doesn't succeed, this will be ignored.
+ using OptionalFileThreadTaskCallback = base::Callback<void(std::string*)>;
FileReader(const extensions::ExtensionResource& resource,
- const Callback& callback);
+ const OptionalFileThreadTaskCallback& file_thread_task_callback,
+ const DoneCallback& done_callback);
// Called to start reading the file on a background thread. Upon completion,
// the callback will be notified of the results.
@@ -36,7 +41,8 @@ class FileReader : public base::RefCountedThreadSafe<FileReader> {
void ReadFileOnBackgroundThread();
extensions::ExtensionResource resource_;
- Callback callback_;
+ OptionalFileThreadTaskCallback optional_file_thread_task_callback_;
+ DoneCallback done_callback_;
const scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_;
};

Powered by Google App Engine
This is Rietveld 408576698