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

Unified Diff: ppapi/shared_impl/tracked_callback.cc

Issue 23706006: PPAPI: Blocking callbacks shouldn't need a target_loop_ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove comment Created 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/shared_impl/tracked_callback.cc
diff --git a/ppapi/shared_impl/tracked_callback.cc b/ppapi/shared_impl/tracked_callback.cc
index 1a3ac21adb5610b332f617b3c10b13f1ec74acf2..23e953851ca522b713babd9c037522e907053492 100644
--- a/ppapi/shared_impl/tracked_callback.cc
+++ b/ppapi/shared_impl/tracked_callback.cc
@@ -165,16 +165,22 @@ void TrackedCallback::PostRun(int32_t result) {
// should never try to PostRun more than once otherwise.
DCHECK(result == PP_ERROR_ABORTED || !is_scheduled_);
- base::Closure callback_closure(
- RunWhileLocked(base::Bind(&TrackedCallback::Run, this, result)));
- if (!target_loop_.get()) {
- // We must be running in-process and on the main thread (the Enter
- // classes protect against having a null target_loop_ otherwise).
- DCHECK(IsMainThread());
- DCHECK(PpapiGlobals::Get()->IsHostGlobals());
- base::MessageLoop::current()->PostTask(FROM_HERE, callback_closure);
+ if (is_blocking()) {
+ // We might not have a MessageLoop to post to, so we must call Run()
+ // directly.
+ Run(result);
} else {
- target_loop_->PostClosure(FROM_HERE, callback_closure, 0);
+ base::Closure callback_closure(
+ RunWhileLocked(base::Bind(&TrackedCallback::Run, this, result)));
+ if (target_loop_) {
+ target_loop_->PostClosure(FROM_HERE, callback_closure, 0);
+ } else {
+ // We must be running in-process and on the main thread (the Enter
+ // classes protect against having a null target_loop_ otherwise).
+ DCHECK(IsMainThread());
+ DCHECK(PpapiGlobals::Get()->IsHostGlobals());
+ base::MessageLoop::current()->PostTask(FROM_HERE, callback_closure);
+ }
}
is_scheduled_ = true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698