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 27 matching lines...) Expand all Loading... |
38 // us to shield the Callback class from the types of the bound argument via | 38 // us to shield the Callback class from the types of the bound argument via |
39 // "type erasure." | 39 // "type erasure." |
40 // At the base level, the only task is to add reference counting data. Don't use | 40 // At the base level, the only task is to add reference counting data. Don't use |
41 // RefCountedThreadSafe since it requires the destructor to be a virtual method. | 41 // RefCountedThreadSafe since it requires the destructor to be a virtual method. |
42 // Creating a vtable for every BindState template instantiation results in a lot | 42 // Creating a vtable for every BindState template instantiation results in a lot |
43 // of bloat. Its only task is to call the destructor which can be done with a | 43 // of bloat. Its only task is to call the destructor which can be done with a |
44 // function pointer. | 44 // function pointer. |
45 class BASE_EXPORT BindStateBase | 45 class BASE_EXPORT BindStateBase |
46 : public RefCountedThreadSafe<BindStateBase, BindStateBaseRefCountTraits> { | 46 : public RefCountedThreadSafe<BindStateBase, BindStateBaseRefCountTraits> { |
47 public: | 47 public: |
| 48 static constexpr subtle::StartRefCountFromOneTag kRefCountPreference = |
| 49 subtle::kStartRefCountFromOneTag; |
| 50 |
48 using InvokeFuncStorage = void(*)(); | 51 using InvokeFuncStorage = void(*)(); |
49 | 52 |
50 private: | 53 private: |
51 BindStateBase(InvokeFuncStorage polymorphic_invoke, | 54 BindStateBase(InvokeFuncStorage polymorphic_invoke, |
52 void (*destructor)(const BindStateBase*)); | 55 void (*destructor)(const BindStateBase*)); |
53 BindStateBase(InvokeFuncStorage polymorphic_invoke, | 56 BindStateBase(InvokeFuncStorage polymorphic_invoke, |
54 void (*destructor)(const BindStateBase*), | 57 void (*destructor)(const BindStateBase*), |
55 bool (*is_cancelled)(const BindStateBase*)); | 58 bool (*is_cancelled)(const BindStateBase*)); |
56 | 59 |
57 ~BindStateBase() = default; | 60 ~BindStateBase() = default; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 ~CallbackBase() {} | 151 ~CallbackBase() {} |
149 }; | 152 }; |
150 | 153 |
151 extern template class CallbackBase<CopyMode::MoveOnly>; | 154 extern template class CallbackBase<CopyMode::MoveOnly>; |
152 extern template class CallbackBase<CopyMode::Copyable>; | 155 extern template class CallbackBase<CopyMode::Copyable>; |
153 | 156 |
154 } // namespace internal | 157 } // namespace internal |
155 } // namespace base | 158 } // namespace base |
156 | 159 |
157 #endif // BASE_CALLBACK_INTERNAL_H_ | 160 #endif // BASE_CALLBACK_INTERNAL_H_ |
OLD | NEW |