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

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
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..1963bc1dd6532da90850026c0a1fb6cf40d5b273 100644
--- a/ppapi/shared_impl/tracked_callback.cc
+++ b/ppapi/shared_impl/tracked_callback.cc
@@ -128,6 +128,9 @@ void TrackedCallback::Run(int32_t result) {
PostRun(result);
return;
}
+
+ result = RunCompletionTask(result);
yzshen1 2013/08/07 21:09:10 One thing that may be tricky is that this completi
dmichael (off chromium) 2013/08/08 17:29:58 I think the answer is "don't do that". The complet
bbudge 2013/08/08 18:34:00 I moved the task invocation to after MarkAsComplet
+
// Copy |callback_| now, since |MarkAsCompleted()| may delete us.
PP_CompletionCallback callback = callback_;
// Do this before running the callback in case of reentrancy (which
@@ -164,6 +167,11 @@ void TrackedCallback::PostRun(int32_t result) {
is_scheduled_ = true;
}
+void TrackedCallback::SetCompletionTask(const CompletionTask& completion_task) {
+ DCHECK(completion_task_.is_null());
+ completion_task_ = completion_task;
+}
+
// static
bool TrackedCallback::IsPending(
const scoped_refptr<TrackedCallback>& callback) {
@@ -195,7 +203,8 @@ int32_t TrackedCallback::BlockUntilComplete() {
while (!completed())
operation_completed_condvar_->Wait();
- return result_for_blocked_callback_;
+
+ return RunCompletionTask(result_for_blocked_callback_);
}
void TrackedCallback::MarkAsCompleted() {
@@ -211,4 +220,10 @@ void TrackedCallback::MarkAsCompleted() {
tracker_ = NULL;
}
+int32_t TrackedCallback::RunCompletionTask(int32_t result) {
+ if (!completion_task_.is_null())
+ result = completion_task_.Run(result);
+ return result;
teravest 2013/08/08 16:49:52 nit: I think you want to call completion_task_.Res
bbudge 2013/08/08 18:34:00 Yes, good catch. Another danger is if the task bun
+}
+
} // namespace ppapi
« ppapi/shared_impl/tracked_callback.h ('K') | « ppapi/shared_impl/tracked_callback.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698