| Index: ppapi/shared_impl/tracked_callback.cc
|
| diff --git a/ppapi/shared_impl/tracked_callback.cc b/ppapi/shared_impl/tracked_callback.cc
|
| index 854e9dfb1509ebb843cdbc9633b1c6aca5371f5a..d98d56bf2138d9c5e6169c4a2577562acfbabfbf 100644
|
| --- a/ppapi/shared_impl/tracked_callback.cc
|
| +++ b/ppapi/shared_impl/tracked_callback.cc
|
| @@ -128,11 +128,18 @@ void TrackedCallback::Run(int32_t result) {
|
| PostRun(result);
|
| return;
|
| }
|
| - // Copy |callback_| now, since |MarkAsCompleted()| may delete us.
|
| +
|
| + // Copy callback fields now, since |MarkAsCompleted()| may delete us.
|
| PP_CompletionCallback callback = callback_;
|
| + CompletionTask completion_task = completion_task_;
|
| + completion_task_.Reset();
|
| // Do this before running the callback in case of reentrancy (which
|
| // shouldn't happen, but avoid strange failures).
|
| MarkAsCompleted();
|
| +
|
| + if (!completion_task.is_null())
|
| + result = completion_task.Run(result);
|
| +
|
| // TODO(dmichael): Associate a message loop with the callback; if it's not
|
| // the same as the current thread's loop, then post it to the right loop.
|
| CallWhileUnlocked(PP_RunCompletionCallback, &callback, result);
|
| @@ -164,6 +171,12 @@ void TrackedCallback::PostRun(int32_t result) {
|
| is_scheduled_ = true;
|
| }
|
|
|
| +void TrackedCallback::set_completion_task(
|
| + const CompletionTask& completion_task) {
|
| + DCHECK(completion_task_.is_null());
|
| + completion_task_ = completion_task;
|
| +}
|
| +
|
| // static
|
| bool TrackedCallback::IsPending(
|
| const scoped_refptr<TrackedCallback>& callback) {
|
| @@ -195,7 +208,13 @@ int32_t TrackedCallback::BlockUntilComplete() {
|
|
|
| while (!completed())
|
| operation_completed_condvar_->Wait();
|
| - return result_for_blocked_callback_;
|
| +
|
| + int32_t result = result_for_blocked_callback_;
|
| + if (!completion_task_.is_null()) {
|
| + result = completion_task_.Run(result);
|
| + completion_task_.Reset();
|
| + }
|
| + return result;
|
| }
|
|
|
| void TrackedCallback::MarkAsCompleted() {
|
|
|