OLD | NEW |
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 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 // Returns true if the callback was completed (possibly aborted). | 103 // Returns true if the callback was completed (possibly aborted). |
104 bool completed() const { return completed_; } | 104 bool completed() const { return completed_; } |
105 | 105 |
106 // 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 |
107 // case whenever |Abort()| or |PostAbort()| is called before a non-abortive | 107 // case whenever |Abort()| or |PostAbort()| is called before a non-abortive |
108 // completion. | 108 // completion. |
109 bool aborted() const { return aborted_; } | 109 bool aborted() const { return aborted_; } |
110 | 110 |
111 // Returns true if this is a blocking callback. | 111 // Returns true if this is a blocking callback. |
112 bool is_blocking() { | 112 bool is_blocking() { return !callback_.func; } |
113 return !callback_.func; | |
114 } | |
115 | 113 |
116 MessageLoopShared* target_loop() const { | 114 MessageLoopShared* target_loop() const { return target_loop_.get(); } |
117 return target_loop_.get(); | |
118 } | |
119 | 115 |
120 // Determines if the given callback is pending. A callback is pending if it | 116 // Determines if the given callback is pending. A callback is pending if it |
121 // has not completed and has not been aborted. When receiving a plugin call, | 117 // has not completed and has not been aborted. When receiving a plugin call, |
122 // use this to detect if |callback| represents an operation in progress. When | 118 // use this to detect if |callback| represents an operation in progress. When |
123 // finishing a plugin call, use this to determine whether to write 'out' | 119 // finishing a plugin call, use this to determine whether to write 'out' |
124 // params and Run |callback|. | 120 // params and Run |callback|. |
125 // NOTE: an aborted callback has not necessarily completed, so a false result | 121 // NOTE: an aborted callback has not necessarily completed, so a false result |
126 // doesn't imply that the callback has completed. | 122 // doesn't imply that the callback has completed. |
127 // As a convenience, if |callback| is null, this returns false. | 123 // As a convenience, if |callback| is null, this returns false. |
128 static bool IsPending(const scoped_refptr<TrackedCallback>& callback); | 124 static bool IsPending(const scoped_refptr<TrackedCallback>& callback); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // 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 |
184 // not allowed, and therefore this pointer will be NULL. | 180 // not allowed, and therefore this pointer will be NULL. |
185 scoped_ptr<base::ConditionVariable> operation_completed_condvar_; | 181 scoped_ptr<base::ConditionVariable> operation_completed_condvar_; |
186 | 182 |
187 DISALLOW_IMPLICIT_CONSTRUCTORS(TrackedCallback); | 183 DISALLOW_IMPLICIT_CONSTRUCTORS(TrackedCallback); |
188 }; | 184 }; |
189 | 185 |
190 } // namespace ppapi | 186 } // namespace ppapi |
191 | 187 |
192 #endif // PPAPI_SHARED_IMPL_TRACKED_CALLBACK_H_ | 188 #endif // PPAPI_SHARED_IMPL_TRACKED_CALLBACK_H_ |
OLD | NEW |