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

Unified Diff: ppapi/shared_impl/tracked_callback.h

Issue 9015009: Use the new callback tracker and delete the old one (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add IsPending Created 8 years, 12 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/resource_tracker.h ('k') | ppapi/shared_impl/tracked_callback.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/shared_impl/tracked_callback.h
diff --git a/ppapi/shared_impl/tracked_callback.h b/ppapi/shared_impl/tracked_callback.h
index ed42a5954ca65a1634d9727de00b029f7d517c0c..d04606fc6e81aad330a339f72ea76ca89041c1bd 100644
--- a/ppapi/shared_impl/tracked_callback.h
+++ b/ppapi/shared_impl/tracked_callback.h
@@ -63,6 +63,8 @@ class PPAPI_SHARED_EXPORT TrackedCallback
// Run the callback with the given result. If the callback had previously been
// 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().
void Run(int32_t result);
// Returns the ID of the resource which "owns" the callback, or 0 if the
@@ -77,6 +79,24 @@ class PPAPI_SHARED_EXPORT TrackedCallback
// completion.
bool aborted() const { return aborted_; }
+ // Helper to determine if the given callback is set and not yet completed.
+ // The normal pattern is to use a scoped_refptr to hold a callback. This
+ // function tells you if the operation is currently in progress by checking
+ // both the null-ness of the scoped_refptr, as well as the completion state
+ // 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 is 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);
+
private:
// This class is ref counted.
friend class base::RefCountedThreadSafe<TrackedCallback>;
« no previous file with comments | « ppapi/shared_impl/resource_tracker.h ('k') | ppapi/shared_impl/tracked_callback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698