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

Unified Diff: extensions/browser/file_reader.cc

Issue 2301713002: Remove some UI->FILE->UI thread hops in ExecuteCodeFunction (Closed)
Patch Set: fix chromeos 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
« extensions/browser/file_reader.h ('K') | « extensions/browser/file_reader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/file_reader.cc
diff --git a/extensions/browser/file_reader.cc b/extensions/browser/file_reader.cc
index c5deb9b646e071cc844cceb9ec57922b35afab31..6094bc84fa11abd8b0ad633a6e0c721066d4946d 100644
--- a/extensions/browser/file_reader.cc
+++ b/extensions/browser/file_reader.cc
@@ -11,10 +11,13 @@
using content::BrowserThread;
-FileReader::FileReader(const extensions::ExtensionResource& resource,
- const Callback& callback)
+FileReader::FileReader(
+ const extensions::ExtensionResource& resource,
+ const OptionalFileThreadTaskCallback& optional_file_thread_task_callback,
+ const DoneCallback& done_callback)
: resource_(resource),
- callback_(callback),
+ optional_file_thread_task_callback_(optional_file_thread_task_callback),
+ done_callback_(done_callback),
origin_task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
void FileReader::Start() {
@@ -28,6 +31,11 @@ FileReader::~FileReader() {}
void FileReader::ReadFileOnBackgroundThread() {
std::unique_ptr<std::string> data(new std::string());
bool success = base::ReadFileToString(resource_.GetFilePath(), data.get());
+
+ if (!optional_file_thread_task_callback_.is_null())
+ optional_file_thread_task_callback_.Run(success, data.get());
+
origin_task_runner_->PostTask(
- FROM_HERE, base::Bind(callback_, success, base::Passed(std::move(data))));
+ FROM_HERE,
+ base::Bind(done_callback_, success, base::Passed(std::move(data))));
}
« extensions/browser/file_reader.h ('K') | « extensions/browser/file_reader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698