Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: base/callback_internal.h

Issue 2723423002: Start BindStateBase ref count from 1 instead of 0 (Closed)
Patch Set: s/MAKE_REF_COUNT_START_FROM_ONE/REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE()/ Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/BUILD.gn ('k') | base/callback_internal.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE();
49
48 using InvokeFuncStorage = void(*)(); 50 using InvokeFuncStorage = void(*)();
49 51
50 private: 52 private:
51 BindStateBase(InvokeFuncStorage polymorphic_invoke, 53 BindStateBase(InvokeFuncStorage polymorphic_invoke,
52 void (*destructor)(const BindStateBase*)); 54 void (*destructor)(const BindStateBase*));
53 BindStateBase(InvokeFuncStorage polymorphic_invoke, 55 BindStateBase(InvokeFuncStorage polymorphic_invoke,
54 void (*destructor)(const BindStateBase*), 56 void (*destructor)(const BindStateBase*),
55 bool (*is_cancelled)(const BindStateBase*)); 57 bool (*is_cancelled)(const BindStateBase*));
56 58
57 ~BindStateBase() = default; 59 ~BindStateBase() = default;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ~CallbackBase() {} 150 ~CallbackBase() {}
149 }; 151 };
150 152
151 extern template class CallbackBase<CopyMode::MoveOnly>; 153 extern template class CallbackBase<CopyMode::MoveOnly>;
152 extern template class CallbackBase<CopyMode::Copyable>; 154 extern template class CallbackBase<CopyMode::Copyable>;
153 155
154 } // namespace internal 156 } // namespace internal
155 } // namespace base 157 } // namespace base
156 158
157 #endif // BASE_CALLBACK_INTERNAL_H_ 159 #endif // BASE_CALLBACK_INTERNAL_H_
OLDNEW
« no previous file with comments | « base/BUILD.gn ('k') | base/callback_internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698