| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // Holds the Callback methods that don't require specialization to reduce | 55 // Holds the Callback methods that don't require specialization to reduce |
| 56 // template bloat. | 56 // template bloat. |
| 57 // CallbackBase<MoveOnly> is a direct base class of MoveOnly callbacks, and | 57 // CallbackBase<MoveOnly> is a direct base class of MoveOnly callbacks, and |
| 58 // CallbackBase<Copyable> uses CallbackBase<MoveOnly> for its implementation. | 58 // CallbackBase<Copyable> uses CallbackBase<MoveOnly> for its implementation. |
| 59 template <> | 59 template <> |
| 60 class BASE_EXPORT CallbackBase<CopyMode::MoveOnly> { | 60 class BASE_EXPORT CallbackBase<CopyMode::MoveOnly> { |
| 61 public: | 61 public: |
| 62 CallbackBase(CallbackBase&& c); | 62 CallbackBase(CallbackBase&& c); |
| 63 CallbackBase& operator=(CallbackBase&& c); | 63 CallbackBase& operator=(CallbackBase&& c); |
| 64 | 64 |
| 65 explicit CallbackBase(const CallbackBase<CopyMode::Copyable>& c); |
| 66 CallbackBase& operator=(const CallbackBase<CopyMode::Copyable>& c); |
| 67 |
| 65 // Returns true if Callback is null (doesn't refer to anything). | 68 // Returns true if Callback is null (doesn't refer to anything). |
| 66 bool is_null() const { return bind_state_.get() == NULL; } | 69 bool is_null() const { return bind_state_.get() == NULL; } |
| 67 explicit operator bool() const { return !is_null(); } | 70 explicit operator bool() const { return !is_null(); } |
| 68 | 71 |
| 69 // Returns the Callback into an uninitialized state. | 72 // Returns the Callback into an uninitialized state. |
| 70 void Reset(); | 73 void Reset(); |
| 71 | 74 |
| 72 protected: | 75 protected: |
| 73 // In C++, it is safe to cast function pointers to function pointers of | 76 // In C++, it is safe to cast function pointers to function pointers of |
| 74 // another type. It is not okay to use void*. We create a InvokeFuncStorage | 77 // another type. It is not okay to use void*. We create a InvokeFuncStorage |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 ~CallbackBase() {} | 112 ~CallbackBase() {} |
| 110 }; | 113 }; |
| 111 | 114 |
| 112 extern template class CallbackBase<CopyMode::MoveOnly>; | 115 extern template class CallbackBase<CopyMode::MoveOnly>; |
| 113 extern template class CallbackBase<CopyMode::Copyable>; | 116 extern template class CallbackBase<CopyMode::Copyable>; |
| 114 | 117 |
| 115 } // namespace internal | 118 } // namespace internal |
| 116 } // namespace base | 119 } // namespace base |
| 117 | 120 |
| 118 #endif // BASE_CALLBACK_INTERNAL_H_ | 121 #endif // BASE_CALLBACK_INTERNAL_H_ |
| OLD | NEW |