Chromium Code Reviews| 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..1ba43d97c06dbba8a7e2f74413b92b35fa0ebfc9 100644 |
| --- a/ppapi/shared_impl/tracked_callback.cc |
| +++ b/ppapi/shared_impl/tracked_callback.cc |
| @@ -165,16 +165,23 @@ 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. Since we don't want to attempt to re-acquire the lock, we |
| + // don't use the locking closure. |
|
bbudge
2013/09/04 22:52:16
Second part of comment needs tweaking. Maybe s/use
|
| + 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_) { |
|
bbudge
2013/09/04 22:50:36
Do we have a conversion operator now? Should we st
|
| + 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; |
| } |