| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // params and Run |callback|. | 105 // params and Run |callback|. |
| 106 // NOTE: an aborted callback has not necessarily completed, so a false result | 106 // NOTE: an aborted callback has not necessarily completed, so a false result |
| 107 // doesn't imply that the callback has completed. | 107 // doesn't imply that the callback has completed. |
| 108 // As a convenience, if |callback| is null, this returns false. | 108 // As a convenience, if |callback| is null, this returns false. |
| 109 static bool IsPending(const scoped_refptr<TrackedCallback>& callback); | 109 static bool IsPending(const scoped_refptr<TrackedCallback>& callback); |
| 110 | 110 |
| 111 // Helper to determine if the given callback is scheduled to run on another | 111 // Helper to determine if the given callback is scheduled to run on another |
| 112 // message loop. | 112 // message loop. |
| 113 static bool IsScheduledToRun(const scoped_refptr<TrackedCallback>& callback); | 113 static bool IsScheduledToRun(const scoped_refptr<TrackedCallback>& callback); |
| 114 | 114 |
| 115 protected: | 115 // Returns true if this is a blocking callback. |
| 116 bool is_blocking() { | 116 bool is_blocking() { |
| 117 return !callback_.func; | 117 return !callback_.func; |
| 118 } | 118 } |
| 119 | 119 |
| 120 protected: |
| 120 bool is_required() { | 121 bool is_required() { |
| 121 return (callback_.func && | 122 return (callback_.func && |
| 122 !(callback_.flags & PP_COMPLETIONCALLBACK_FLAG_OPTIONAL)); | 123 !(callback_.flags & PP_COMPLETIONCALLBACK_FLAG_OPTIONAL)); |
| 123 } | 124 } |
| 124 bool is_optional() { | 125 bool is_optional() { |
| 125 return (callback_.func && | 126 return (callback_.func && |
| 126 (callback_.flags & PP_COMPLETIONCALLBACK_FLAG_OPTIONAL)); | 127 (callback_.flags & PP_COMPLETIONCALLBACK_FLAG_OPTIONAL)); |
| 127 } | 128 } |
| 128 bool has_null_target_loop() const { return target_loop_.get() == NULL; } | 129 bool has_null_target_loop() const { return target_loop_.get() == NULL; } |
| 129 | 130 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // callback. Note that in-process, there is no lock, blocking callbacks are | 166 // callback. Note that in-process, there is no lock, blocking callbacks are |
| 166 // not allowed, and therefore this pointer will be NULL. | 167 // not allowed, and therefore this pointer will be NULL. |
| 167 scoped_ptr<base::ConditionVariable> operation_completed_condvar_; | 168 scoped_ptr<base::ConditionVariable> operation_completed_condvar_; |
| 168 | 169 |
| 169 DISALLOW_IMPLICIT_CONSTRUCTORS(TrackedCallback); | 170 DISALLOW_IMPLICIT_CONSTRUCTORS(TrackedCallback); |
| 170 }; | 171 }; |
| 171 | 172 |
| 172 } // namespace ppapi | 173 } // namespace ppapi |
| 173 | 174 |
| 174 #endif // PPAPI_SHARED_IMPL_TRACKED_CALLBACK_H_ | 175 #endif // PPAPI_SHARED_IMPL_TRACKED_CALLBACK_H_ |
| OLD | NEW |