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

Side by Side Diff: base/callback_internal.h

Issue 2310093003: Make BindStateBase constructor out-of-line (Closed)
Patch Set: rebase Created 4 years, 3 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 | « no previous file | 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 12 matching lines...) Expand all
23 // class can use to represent a function object with bound arguments. It 23 // class can use to represent a function object with bound arguments. It
24 // behaves as an existential type that is used by a corresponding 24 // behaves as an existential type that is used by a corresponding
25 // DoInvoke function to perform the function execution. This allows 25 // DoInvoke function to perform the function execution. This allows
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 BindStateBase { 33 class BASE_EXPORT BindStateBase {
34 public: 34 public:
35 using InvokeFuncStorage = void(*)(); 35 using InvokeFuncStorage = void(*)();
36 36
37 protected: 37 protected:
38 BindStateBase(InvokeFuncStorage polymorphic_invoke, 38 BindStateBase(InvokeFuncStorage polymorphic_invoke,
39 void (*destructor)(BindStateBase*)) 39 void (*destructor)(BindStateBase*));
40 : polymorphic_invoke_(polymorphic_invoke),
41 ref_count_(0), destructor_(destructor) {}
42 ~BindStateBase() = default; 40 ~BindStateBase() = default;
43 41
44 private: 42 private:
45 friend class scoped_refptr<BindStateBase>; 43 friend class scoped_refptr<BindStateBase>;
46 template <CopyMode copy_mode> 44 template <CopyMode copy_mode>
47 friend class CallbackBase; 45 friend class CallbackBase;
48 46
49 void AddRef(); 47 void AddRef();
50 void Release(); 48 void Release();
51 49
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 ~CallbackBase() {} 115 ~CallbackBase() {}
118 }; 116 };
119 117
120 extern template class CallbackBase<CopyMode::MoveOnly>; 118 extern template class CallbackBase<CopyMode::MoveOnly>;
121 extern template class CallbackBase<CopyMode::Copyable>; 119 extern template class CallbackBase<CopyMode::Copyable>;
122 120
123 } // namespace internal 121 } // namespace internal
124 } // namespace base 122 } // namespace base
125 123
126 #endif // BASE_CALLBACK_INTERNAL_H_ 124 #endif // BASE_CALLBACK_INTERNAL_H_
OLDNEW
« no previous file with comments | « no previous file | base/callback_internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698