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

Side by Side Diff: ppapi/shared_impl/tracked_callback.h

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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 PPAPI_SHARED_IMPL_TRACKED_CALLBACK_H_ 5 #ifndef PPAPI_SHARED_IMPL_TRACKED_CALLBACK_H_
6 #define PPAPI_SHARED_IMPL_TRACKED_CALLBACK_H_ 6 #define PPAPI_SHARED_IMPL_TRACKED_CALLBACK_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/callback.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/synchronization/condition_variable.h" 15 #include "base/synchronization/condition_variable.h"
15 #include "ppapi/c/pp_completion_callback.h" 16 #include "ppapi/c/pp_completion_callback.h"
16 #include "ppapi/c/pp_instance.h" 17 #include "ppapi/c/pp_instance.h"
17 #include "ppapi/c/pp_resource.h" 18 #include "ppapi/c/pp_resource.h"
18 #include "ppapi/shared_impl/ppapi_shared_export.h" 19 #include "ppapi/shared_impl/ppapi_shared_export.h"
19 #include "ppapi/shared_impl/ppb_message_loop_shared.h" 20 #include "ppapi/shared_impl/ppb_message_loop_shared.h"
20 21
21 namespace ppapi { 22 namespace ppapi {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // 78 //
78 // Run() will invoke the call immediately, if invoked from the target thread 79 // Run() will invoke the call immediately, if invoked from the target thread
79 // (as determined by target_loop_). If invoked on a different thread, the 80 // (as determined by target_loop_). If invoked on a different thread, the
80 // callback will be scheduled to run later on target_loop_. 81 // callback will be scheduled to run later on target_loop_.
81 void Run(int32_t result); 82 void Run(int32_t result);
82 // PostRun is like Run(), except it guarantees that the callback will be run 83 // PostRun is like Run(), except it guarantees that the callback will be run
83 // later. In particular, if you invoke PostRun on the same thread on which the 84 // later. In particular, if you invoke PostRun on the same thread on which the
84 // callback is targeted to run, it will *not* be run immediately. 85 // callback is targeted to run, it will *not* be run immediately.
85 void PostRun(int32_t result); 86 void PostRun(int32_t result);
86 87
87 void BlockUntilRun(); 88 // A task to perform cleanup actions or write output params before calling
89 // back to the plugin. The |result| parameter has the current status, e.g.
90 // whether the operation has been aborted. The return value of the task
91 // becomes the final callback result. The task is always called on the same
92 // thread as the callback to the plugin.
93 typedef base::Callback<int32_t(int32_t /* result */)> CompletionTask;
94
95 // Sets a task that is run just before calling back into the plugin. This
96 // should only be called once.
97 void set_completion_task(const CompletionTask& completion_task);
88 98
89 // Returns the ID of the resource which "owns" the callback, or 0 if the 99 // Returns the ID of the resource which "owns" the callback, or 0 if the
90 // callback is not associated with any resource. 100 // callback is not associated with any resource.
91 PP_Resource resource_id() const { return resource_id_; } 101 PP_Resource resource_id() const { return resource_id_; }
92 102
93 // Returns true if the callback was completed (possibly aborted). 103 // Returns true if the callback was completed (possibly aborted).
94 bool completed() const { return completed_; } 104 bool completed() const { return completed_; }
95 105
96 // Returns true if the callback was or should be aborted; this will be the 106 // Returns true if the callback was or should be aborted; this will be the
97 // case whenever |Abort()| or |PostAbort()| is called before a non-abortive 107 // case whenever |Abort()| or |PostAbort()| is called before a non-abortive
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // Flag used by |PostAbort()| and |PostRun()| to check that we don't schedule 160 // Flag used by |PostAbort()| and |PostRun()| to check that we don't schedule
151 // the callback more than once. 161 // the callback more than once.
152 bool is_scheduled_; 162 bool is_scheduled_;
153 163
154 scoped_refptr<CallbackTracker> tracker_; 164 scoped_refptr<CallbackTracker> tracker_;
155 PP_Resource resource_id_; 165 PP_Resource resource_id_;
156 bool completed_; 166 bool completed_;
157 bool aborted_; 167 bool aborted_;
158 PP_CompletionCallback callback_; 168 PP_CompletionCallback callback_;
159 169
170 // Task to run just before calling back into the plugin.
171 CompletionTask completion_task_;
172
160 // The MessageLoopShared on which this callback should be run. This will be 173 // The MessageLoopShared on which this callback should be run. This will be
161 // NULL if we're in-process. 174 // NULL if we're in-process.
162 scoped_refptr<MessageLoopShared> target_loop_; 175 scoped_refptr<MessageLoopShared> target_loop_;
163 176
164 int32_t result_for_blocked_callback_; 177 int32_t result_for_blocked_callback_;
165 // Used for pausing/waking the blocked thread if this is a blocking completion 178 // Used for pausing/waking the blocked thread if this is a blocking completion
166 // callback. Note that in-process, there is no lock, blocking callbacks are 179 // callback. Note that in-process, there is no lock, blocking callbacks are
167 // not allowed, and therefore this pointer will be NULL. 180 // not allowed, and therefore this pointer will be NULL.
168 scoped_ptr<base::ConditionVariable> operation_completed_condvar_; 181 scoped_ptr<base::ConditionVariable> operation_completed_condvar_;
169 182
170 DISALLOW_IMPLICIT_CONSTRUCTORS(TrackedCallback); 183 DISALLOW_IMPLICIT_CONSTRUCTORS(TrackedCallback);
171 }; 184 };
172 185
173 } // namespace ppapi 186 } // namespace ppapi
174 187
175 #endif // PPAPI_SHARED_IMPL_TRACKED_CALLBACK_H_ 188 #endif // PPAPI_SHARED_IMPL_TRACKED_CALLBACK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698