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

Unified Diff: ppapi/shared_impl/tracked_callback.cc

Issue 22606005: Add CompletionTask to PPAPI TrackedCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | « ppapi/shared_impl/tracked_callback.h ('k') | 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 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).
yzshen1 2013/08/08 23:55:49 nit: Please update the comment: With completion_ta
bbudge 2013/08/09 18:56:26 Done.
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_;
+
bbudge 2013/08/08 18:34:00 David, is it safe to access member fields here? Co
dmichael (off chromium) 2013/08/08 20:45:44 Should be safe. There are two things that could m
+ 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() {
« no previous file with comments | « ppapi/shared_impl/tracked_callback.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698