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

Unified Diff: content/child/fileapi/webfilewriter_impl.cc

Issue 893233002: fileapi: Use standard task-runner to run the fileapi callbacks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 11 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
« no previous file with comments | « content/child/fileapi/webfilesystem_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/fileapi/webfilewriter_impl.cc
diff --git a/content/child/fileapi/webfilewriter_impl.cc b/content/child/fileapi/webfilewriter_impl.cc
index 0af17b8750eedffb69c096e6edd446dc9549cd24..ef16def19a7eab7241c6d9a15f7eeb3a2ac99f92 100644
--- a/content/child/fileapi/webfilewriter_impl.cc
+++ b/content/child/fileapi/webfilewriter_impl.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/synchronization/waitable_event.h"
+#include "base/thread_task_runner_handle.h"
#include "content/child/child_thread_impl.h"
#include "content/child/fileapi/file_system_dispatcher.h"
#include "content/child/worker_task_runner.h"
@@ -31,7 +32,9 @@ class WebFileWriterImpl::WriterBridge
public:
WriterBridge(WebFileWriterImpl::Type type)
: request_id_(0),
- thread_id_(WorkerTaskRunner::Instance()->CurrentWorkerId()),
+ running_on_worker_(WorkerTaskRunner::Instance()->CurrentWorkerId() > 0),
+ task_runner_(running_on_worker_ ? base::ThreadTaskRunnerHandle::Get()
+ : nullptr),
written_bytes_(0) {
if (type == WebFileWriterImpl::TYPE_SYNC)
waitable_event_.reset(new base::WaitableEvent(false, false));
@@ -96,23 +99,25 @@ class WebFileWriterImpl::WriterBridge
void PostTaskToWorker(const base::Closure& closure) {
written_bytes_ = 0;
- if (!thread_id_) {
+ if (!running_on_worker_) {
DCHECK(!waitable_event_);
closure.Run();
return;
}
+ DCHECK(task_runner_);
if (waitable_event_) {
results_closure_ = closure;
waitable_event_->Signal();
return;
}
- WorkerTaskRunner::Instance()->PostTask(thread_id_, closure);
+ task_runner_->PostTask(FROM_HERE, closure);
}
StatusCallback status_callback_;
WriteCallback write_callback_;
int request_id_;
- int thread_id_;
+ const bool running_on_worker_;
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
int written_bytes_;
scoped_ptr<base::WaitableEvent> waitable_event_;
base::Closure results_closure_;
« no previous file with comments | « content/child/fileapi/webfilesystem_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698