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

Unified Diff: ppapi/shared_impl/tracked_callback.h

Issue 10909244: PPAPI: Get TrackedCallback ready for running on non-main threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 3 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.h
diff --git a/ppapi/shared_impl/tracked_callback.h b/ppapi/shared_impl/tracked_callback.h
index 5286b51c6a375f5fd07ca1a24a69ba07e7d6f720..524e1ffaf270a75bcb3c2f9ce52ac0bb5aafa032 100644
--- a/ppapi/shared_impl/tracked_callback.h
+++ b/ppapi/shared_impl/tracked_callback.h
@@ -11,7 +11,6 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
#include "base/synchronization/condition_variable.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_instance.h"
@@ -74,8 +73,14 @@ class PPAPI_SHARED_EXPORT TrackedCallback
// marked as to be aborted (by |PostAbort()|), |result| will be ignored and
// the callback will be run with result |PP_ERROR_ABORTED|.
//
- // See also ClearAndRun().
+ // Run() will invoke the call immediately, if invoked from the target thread
+ // (as determined by target_loop_). If invoked on a different thread, the
+ // callback will be schedule to run later on target_loop_.
viettrungluu 2012/09/25 00:18:11 s/schedule/&d/
+ // TODO(dmichael): Make the above part about different threads actually true.
viettrungluu 2012/09/25 00:18:11 Haha.
void Run(int32_t result);
+ // PostRun is like Run(), except it guarantees that the callback will be run
+ // later. In particular, if you invoke PostRun on the same thread on which the
+ // callback is targeted to run, it will *not* be run immediately.
void PostRun(int32_t result);
void BlockUntilRun();
@@ -99,17 +104,6 @@ class PPAPI_SHARED_EXPORT TrackedCallback
// of the callback (which may still be out-standing via a PostAbort).
static bool IsPending(const scoped_refptr<TrackedCallback>& callback);
- // Runs the given callback, clearing the given scoped_refptr before execution.
- // This is useful for cases where there can be only one pending callback, and
- // the presence of the callback indicates one is pending. Such code would
- // normally want to clear it before execution so the plugin can issue a new
- // request.
- static void ClearAndRun(scoped_refptr<TrackedCallback>* callback,
- int32_t result);
-
- // Same as ClearAndRun except it calls Abort().
- static void ClearAndAbort(scoped_refptr<TrackedCallback>* callback);
-
protected:
bool is_blocking() {
return !callback_.func;
@@ -142,11 +136,9 @@ class PPAPI_SHARED_EXPORT TrackedCallback
friend class base::RefCountedThreadSafe<TrackedCallback>;
virtual ~TrackedCallback();
- // Factory used by |PostAbort()| and |PostRun()|. Note that it's safe to
- // cancel any pending posted tasks on destruction -- before it's destroyed,
- // the "owning" |CallbackTracker| must have gone through and done
- // (synchronous) |Abort()|s.
- base::WeakPtrFactory<TrackedCallback> weak_ptr_factory_;
+ // Flag used by |PostAbort()| and |PostRun()| to check that we don't schedule
+ // the callback more than once.
+ bool is_scheduled_;
scoped_refptr<CallbackTracker> tracker_;
PP_Resource resource_id_;

Powered by Google App Engine
This is Rietveld 408576698