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 // This file contains utility functions and classes that help the | 5 // This file contains utility functions and classes that help the |
6 // implementation, and management of the Callback objects. | 6 // implementation, and management of the Callback objects. |
7 | 7 |
8 #ifndef BASE_CALLBACK_INTERNAL_H_ | 8 #ifndef BASE_CALLBACK_INTERNAL_H_ |
9 #define BASE_CALLBACK_INTERNAL_H_ | 9 #define BASE_CALLBACK_INTERNAL_H_ |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // Holds the Callback methods that don't require specialization to reduce | 70 // Holds the Callback methods that don't require specialization to reduce |
71 // template bloat. | 71 // template bloat. |
72 // CallbackBase<MoveOnly> is a direct base class of MoveOnly callbacks, and | 72 // CallbackBase<MoveOnly> is a direct base class of MoveOnly callbacks, and |
73 // CallbackBase<Copyable> uses CallbackBase<MoveOnly> for its implementation. | 73 // CallbackBase<Copyable> uses CallbackBase<MoveOnly> for its implementation. |
74 template <> | 74 template <> |
75 class BASE_EXPORT CallbackBase<CopyMode::MoveOnly> { | 75 class BASE_EXPORT CallbackBase<CopyMode::MoveOnly> { |
76 public: | 76 public: |
77 CallbackBase(CallbackBase&& c); | 77 CallbackBase(CallbackBase&& c); |
78 CallbackBase& operator=(CallbackBase&& c); | 78 CallbackBase& operator=(CallbackBase&& c); |
79 | 79 |
| 80 explicit CallbackBase(const CallbackBase<CopyMode::Copyable>& c); |
| 81 CallbackBase& operator=(const CallbackBase<CopyMode::Copyable>& c); |
| 82 |
80 // Returns true if Callback is null (doesn't refer to anything). | 83 // Returns true if Callback is null (doesn't refer to anything). |
81 bool is_null() const { return bind_state_.get() == NULL; } | 84 bool is_null() const { return bind_state_.get() == NULL; } |
82 explicit operator bool() const { return !is_null(); } | 85 explicit operator bool() const { return !is_null(); } |
83 | 86 |
84 // Returns true if the callback invocation will be nop due to an cancellation. | 87 // Returns true if the callback invocation will be nop due to an cancellation. |
85 // It's invalid to call this on uninitialized callback. | 88 // It's invalid to call this on uninitialized callback. |
86 bool IsCancelled() const; | 89 bool IsCancelled() const; |
87 | 90 |
88 // Returns the Callback into an uninitialized state. | 91 // Returns the Callback into an uninitialized state. |
89 void Reset(); | 92 void Reset(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 ~CallbackBase() {} | 128 ~CallbackBase() {} |
126 }; | 129 }; |
127 | 130 |
128 extern template class CallbackBase<CopyMode::MoveOnly>; | 131 extern template class CallbackBase<CopyMode::MoveOnly>; |
129 extern template class CallbackBase<CopyMode::Copyable>; | 132 extern template class CallbackBase<CopyMode::Copyable>; |
130 | 133 |
131 } // namespace internal | 134 } // namespace internal |
132 } // namespace base | 135 } // namespace base |
133 | 136 |
134 #endif // BASE_CALLBACK_INTERNAL_H_ | 137 #endif // BASE_CALLBACK_INTERNAL_H_ |
OLD | NEW |