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

Side by Side Diff: webkit/plugins/ppapi/callbacks.h

Issue 8741006: Add exports needed for glue to build as a component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase to r112585 Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/plugin_switches.h ('k') | webkit/plugins/ppapi/file_path.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_CALLBACKS_H_ 5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_CALLBACKS_H_
6 #define WEBKIT_GLUE_PLUGINS_PEPPER_CALLBACKS_H_ 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_CALLBACKS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/task.h" 13 #include "base/task.h"
14 #include "ppapi/c/pp_completion_callback.h" 14 #include "ppapi/c/pp_completion_callback.h"
15 #include "ppapi/c/pp_resource.h" 15 #include "ppapi/c/pp_resource.h"
16 #include "webkit/plugins/webkit_plugins_export.h"
16 17
17 namespace webkit { 18 namespace webkit {
18 namespace ppapi { 19 namespace ppapi {
19 20
20 class TrackedCallback; 21 class TrackedCallback;
21 22
22 // Pepper callbacks have the following semantics (unless otherwise specified; 23 // Pepper callbacks have the following semantics (unless otherwise specified;
23 // in particular, the below apply to all completion callbacks): 24 // in particular, the below apply to all completion callbacks):
24 // - Callbacks are always run on the main thread. 25 // - Callbacks are always run on the main thread.
25 // - Callbacks are always called from the main message loop. In particular, 26 // - Callbacks are always called from the main message loop. In particular,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 70
70 // Abort all callbacks (synchronously). 71 // Abort all callbacks (synchronously).
71 void AbortAll(); 72 void AbortAll();
72 73
73 // Abort all callbacks associated to the given resource ID (which must be 74 // Abort all callbacks associated to the given resource ID (which must be
74 // valid, i.e., nonzero) by posting a task (or tasks). 75 // valid, i.e., nonzero) by posting a task (or tasks).
75 void PostAbortForResource(PP_Resource resource_id); 76 void PostAbortForResource(PP_Resource resource_id);
76 77
77 private: 78 private:
78 friend class base::RefCountedThreadSafe<CallbackTracker>; 79 friend class base::RefCountedThreadSafe<CallbackTracker>;
79 ~CallbackTracker(); 80 WEBKIT_PLUGINS_EXPORT ~CallbackTracker();
80 81
81 // |TrackedCallback| are expected to automatically add and 82 // |TrackedCallback| are expected to automatically add and
82 // remove themselves from their provided |CallbackTracker|. 83 // remove themselves from their provided |CallbackTracker|.
83 friend class TrackedCallback; 84 friend class TrackedCallback;
84 void Add(const scoped_refptr<TrackedCallback>& tracked_callback); 85 void Add(const scoped_refptr<TrackedCallback>& tracked_callback);
85 void Remove(const scoped_refptr<TrackedCallback>& tracked_callback); 86 void Remove(const scoped_refptr<TrackedCallback>& tracked_callback);
86 87
87 // For each resource ID with a pending callback, store a set with its pending 88 // For each resource ID with a pending callback, store a set with its pending
88 // callbacks. (Resource ID 0 is used for callbacks not associated to a valid 89 // callbacks. (Resource ID 0 is used for callbacks not associated to a valid
89 // resource.) If a resource ID is re-used for another resource, there may be 90 // resource.) If a resource ID is re-used for another resource, there may be
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // callback; see the comment for |MarkAsCompleted()| for a caveat. 126 // callback; see the comment for |MarkAsCompleted()| for a caveat.
126 class TrackedCallback : public base::RefCountedThreadSafe<TrackedCallback> { 127 class TrackedCallback : public base::RefCountedThreadSafe<TrackedCallback> {
127 public: 128 public:
128 // The constructor will add the new object to the tracker. The resource ID is 129 // The constructor will add the new object to the tracker. The resource ID is
129 // optional -- set it to 0 if no resource is associated to the callback. 130 // optional -- set it to 0 if no resource is associated to the callback.
130 TrackedCallback(const scoped_refptr<CallbackTracker>& tracker, 131 TrackedCallback(const scoped_refptr<CallbackTracker>& tracker,
131 PP_Resource resource_id); 132 PP_Resource resource_id);
132 133
133 // These run the callback in an abortive manner, or post a task to do so (but 134 // These run the callback in an abortive manner, or post a task to do so (but
134 // immediately marking the callback as to be aborted). 135 // immediately marking the callback as to be aborted).
135 void Abort(); 136 WEBKIT_PLUGINS_EXPORT void Abort();
136 void PostAbort(); 137 void PostAbort();
137 138
138 // Returns the ID of the resource which "owns" the callback, or 0 if the 139 // Returns the ID of the resource which "owns" the callback, or 0 if the
139 // callback is not associated with any resource. 140 // callback is not associated with any resource.
140 PP_Resource resource_id() const { return resource_id_; } 141 PP_Resource resource_id() const { return resource_id_; }
141 142
142 // Returns true if the callback was completed (possibly aborted). 143 // Returns true if the callback was completed (possibly aborted).
143 bool completed() const { return completed_; } 144 bool completed() const { return completed_; }
144 145
145 // Returns true if the callback was or should be aborted; this will be the 146 // Returns true if the callback was or should be aborted; this will be the
(...skipping 26 matching lines...) Expand all
172 bool aborted_; 173 bool aborted_;
173 174
174 DISALLOW_COPY_AND_ASSIGN(TrackedCallback); 175 DISALLOW_COPY_AND_ASSIGN(TrackedCallback);
175 }; 176 };
176 177
177 // |TrackedCompletionCallback| represents a tracked Pepper completion callback. 178 // |TrackedCompletionCallback| represents a tracked Pepper completion callback.
178 class TrackedCompletionCallback : public TrackedCallback { 179 class TrackedCompletionCallback : public TrackedCallback {
179 public: 180 public:
180 // Create a tracked completion callback and register it with the tracker. The 181 // Create a tracked completion callback and register it with the tracker. The
181 // resource ID may be 0 if the callback is not associated to any resource. 182 // resource ID may be 0 if the callback is not associated to any resource.
182 TrackedCompletionCallback(const scoped_refptr<CallbackTracker>& tracker, 183 WEBKIT_PLUGINS_EXPORT TrackedCompletionCallback(
183 PP_Resource resource_id, 184 const scoped_refptr<CallbackTracker>& tracker,
184 const PP_CompletionCallback& callback); 185 PP_Resource resource_id,
186 const PP_CompletionCallback& callback);
185 187
186 // Run the callback with the given result. If the callback had previously been 188 // Run the callback with the given result. If the callback had previously been
187 // marked as to be aborted (by |PostAbort()|), |result| will be ignored and 189 // marked as to be aborted (by |PostAbort()|), |result| will be ignored and
188 // the callback will be run with result |PP_ERROR_ABORTED|. 190 // the callback will be run with result |PP_ERROR_ABORTED|.
189 void Run(int32_t result); 191 WEBKIT_PLUGINS_EXPORT void Run(int32_t result);
190 192
191 protected: 193 protected:
192 // |TrackedCallback| method: 194 // |TrackedCallback| method:
193 virtual void AbortImpl(); 195 virtual void AbortImpl();
194 196
195 private: 197 private:
196 PP_CompletionCallback callback_; 198 PP_CompletionCallback callback_;
197 199
198 DISALLOW_COPY_AND_ASSIGN(TrackedCompletionCallback); 200 DISALLOW_COPY_AND_ASSIGN(TrackedCompletionCallback);
199 }; 201 };
200 202
201 } // namespace ppapi 203 } // namespace ppapi
202 } // namespace webkit 204 } // namespace webkit
203 205
204 #endif // WEBKIT_PLUGINS_PPAPI_CALLBACKS_H_ 206 #endif // WEBKIT_PLUGINS_PPAPI_CALLBACKS_H_
OLDNEW
« no previous file with comments | « webkit/plugins/plugin_switches.h ('k') | webkit/plugins/ppapi/file_path.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698