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 15 matching lines...) Expand all Loading... |
26 // us to shield the Callback class from the types of the bound argument via | 26 // us to shield the Callback class from the types of the bound argument via |
27 // "type erasure." | 27 // "type erasure." |
28 // At the base level, the only task is to add reference counting data. Don't use | 28 // At the base level, the only task is to add reference counting data. Don't use |
29 // RefCountedThreadSafe since it requires the destructor to be a virtual method. | 29 // RefCountedThreadSafe since it requires the destructor to be a virtual method. |
30 // Creating a vtable for every BindState template instantiation results in a lot | 30 // Creating a vtable for every BindState template instantiation results in a lot |
31 // of bloat. Its only task is to call the destructor which can be done with a | 31 // of bloat. Its only task is to call the destructor which can be done with a |
32 // function pointer. | 32 // function pointer. |
33 class BASE_EXPORT BindStateBase { | 33 class BASE_EXPORT BindStateBase { |
34 public: | 34 public: |
35 using InvokeFuncStorage = void(*)(); | 35 using InvokeFuncStorage = void(*)(); |
| 36 bool HasOneRef() const; |
36 | 37 |
37 protected: | 38 protected: |
38 BindStateBase(InvokeFuncStorage polymorphic_invoke, | 39 BindStateBase(InvokeFuncStorage polymorphic_invoke, |
39 void (*destructor)(const BindStateBase*)); | 40 void (*destructor)(const BindStateBase*)); |
40 BindStateBase(InvokeFuncStorage polymorphic_invoke, | 41 BindStateBase(InvokeFuncStorage polymorphic_invoke, |
41 void (*destructor)(const BindStateBase*), | 42 void (*destructor)(const BindStateBase*), |
42 bool (*is_cancelled)(const BindStateBase*)); | 43 bool (*is_cancelled)(const BindStateBase*)); |
43 ~BindStateBase() = default; | 44 ~BindStateBase() = default; |
44 | 45 |
45 private: | 46 private: |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 ~CallbackBase() {} | 131 ~CallbackBase() {} |
131 }; | 132 }; |
132 | 133 |
133 extern template class CallbackBase<CopyMode::MoveOnly>; | 134 extern template class CallbackBase<CopyMode::MoveOnly>; |
134 extern template class CallbackBase<CopyMode::Copyable>; | 135 extern template class CallbackBase<CopyMode::Copyable>; |
135 | 136 |
136 } // namespace internal | 137 } // namespace internal |
137 } // namespace base | 138 } // namespace base |
138 | 139 |
139 #endif // BASE_CALLBACK_INTERNAL_H_ | 140 #endif // BASE_CALLBACK_INTERNAL_H_ |
OLD | NEW |