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

Unified Diff: ppapi/shared_impl/tracked_callback.cc

Issue 22646005: Do PPB_FileIO Query and Read in the plugin process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. 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..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() {

Powered by Google App Engine
This is Rietveld 408576698