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

Side by Side Diff: base/callback.h.pump

Issue 8919016: base::Bind: Make use of partial currying to get rid of a helper class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes. Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « base/callback.h ('k') | chrome/browser/chrome_benchmarking_message_filter.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 $$ This is a pump file for generating file templates. Pump is a python 1 $$ This is a pump file for generating file templates. Pump is a python
2 $$ script that is part of the Google Test suite of utilities. Description 2 $$ script that is part of the Google Test suite of utilities. Description
3 $$ can be found here: 3 $$ can be found here:
4 $$ 4 $$
5 $$ http://code.google.com/p/googletest/wiki/PumpManual 5 $$ http://code.google.com/p/googletest/wiki/PumpManual
6 $$ 6 $$
7 7
8 $$ See comment for MAX_ARITY in base/bind.h.pump. 8 $$ See comment for MAX_ARITY in base/bind.h.pump.
9 $var MAX_ARITY = 7 9 $var MAX_ARITY = 7
10 10
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // The design Callback and Bind is heavily influenced by C++'s 122 // The design Callback and Bind is heavily influenced by C++'s
123 // tr1::function/tr1::bind, and by the "Google Callback" system used inside 123 // tr1::function/tr1::bind, and by the "Google Callback" system used inside
124 // Google. 124 // Google.
125 // 125 //
126 // 126 //
127 // HOW THE IMPLEMENTATION WORKS: 127 // HOW THE IMPLEMENTATION WORKS:
128 // 128 //
129 // There are three main components to the system: 129 // There are three main components to the system:
130 // 1) The Callback classes. 130 // 1) The Callback classes.
131 // 2) The Bind() functions. 131 // 2) The Bind() functions.
132 // 3) The arguments wrappers (eg., Unretained() and ConstRef()). 132 // 3) The arguments wrappers (e.g., Unretained() and ConstRef()).
133 // 133 //
134 // The Callback classes represent a generic function pointer. Internally, 134 // The Callback classes represent a generic function pointer. Internally,
135 // it stores a refcounted piece of state that represents the target function 135 // it stores a refcounted piece of state that represents the target function
136 // and all its bound parameters. Each Callback specialization has a templated 136 // and all its bound parameters. Each Callback specialization has a templated
137 // constructor that takes an BindStateHolder<> object. In the context of 137 // constructor that takes an BindStateHolder<> object. In the context of
138 // the constructor, the static type of this BindStateHolder<> object 138 // the constructor, the static type of this BindStateHolder<> object
139 // uniquely identifies the function it is representing, all its bound 139 // uniquely identifies the function it is representing, all its bound
140 // parameters, and a DoInvoke() that is capable of invoking the target. 140 // parameters, and a DoInvoke() that is capable of invoking the target.
141 // 141 //
142 // Callback's constructor is takes the BindStateHolder<> that has the 142 // Callback's constructor is takes the BindStateHolder<> that has the
(...skipping 15 matching lines...) Expand all
158 // refcounting semantics for the target object if we are binding a class 158 // refcounting semantics for the target object if we are binding a class
159 // method. 159 // method.
160 // 160 //
161 // The Bind functions do the above using type-inference, and template 161 // The Bind functions do the above using type-inference, and template
162 // specializations. 162 // specializations.
163 // 163 //
164 // By default Bind() will store copies of all bound parameters, and attempt 164 // By default Bind() will store copies of all bound parameters, and attempt
165 // to refcount a target object if the function being bound is a class method. 165 // to refcount a target object if the function being bound is a class method.
166 // 166 //
167 // To change this behavior, we introduce a set of argument wrappers 167 // To change this behavior, we introduce a set of argument wrappers
168 // (eg. Unretained(), and ConstRef()). These are simple container templates 168 // (e.g., Unretained(), and ConstRef()). These are simple container templates
169 // that are passed by value, and wrap a pointer to argument. See the 169 // that are passed by value, and wrap a pointer to argument. See the
170 // file-level comment in base/bind_helpers.h for more info. 170 // file-level comment in base/bind_helpers.h for more info.
171 // 171 //
172 // These types are passed to the Unwrap() functions, and the MaybeRefcount() 172 // These types are passed to the Unwrap() functions, and the MaybeRefcount()
173 // functions respectively to modify the behavior of Bind(). The Unwrap() 173 // functions respectively to modify the behavior of Bind(). The Unwrap()
174 // and MaybeRefcount() functions change behavior by doing partial 174 // and MaybeRefcount() functions change behavior by doing partial
175 // specialization based on whether or not a parameter is a wrapper type. 175 // specialization based on whether or not a parameter is a wrapper type.
176 // 176 //
177 // ConstRef() is similar to tr1::cref. Unretained() is specific to Chromium. 177 // ConstRef() is similar to tr1::cref. Unretained() is specific to Chromium.
178 // 178 //
(...skipping 16 matching lines...) Expand all
195 // tr1::function causes a copy to be made of all the bound parameters and 195 // tr1::function causes a copy to be made of all the bound parameters and
196 // state. 196 // state.
197 // 197 //
198 // Furthermore, in Chromium, it is desirable for the Callback to take a 198 // Furthermore, in Chromium, it is desirable for the Callback to take a
199 // reference on a target object when representing a class method call. This 199 // reference on a target object when representing a class method call. This
200 // is not supported by tr1. 200 // is not supported by tr1.
201 // 201 //
202 // Lastly, tr1::function and tr1::bind has a more general and flexible API. 202 // Lastly, tr1::function and tr1::bind has a more general and flexible API.
203 // This includes things like argument reordering by use of 203 // This includes things like argument reordering by use of
204 // tr1::bind::placeholder, support for non-const reference parameters, and some 204 // tr1::bind::placeholder, support for non-const reference parameters, and some
205 // limited amount of subtyping of the tr1::function object (eg., 205 // limited amount of subtyping of the tr1::function object (e.g.,
206 // tr1::function<int(int)> is convertible to tr1::function<void(int)>). 206 // tr1::function<int(int)> is convertible to tr1::function<void(int)>).
207 // 207 //
208 // These are not features that are required in Chromium. Some of them, such as 208 // These are not features that are required in Chromium. Some of them, such as
209 // allowing for reference parameters, and subtyping of functions, may actually 209 // allowing for reference parameters, and subtyping of functions, may actually
210 // become a source of errors. Removing support for these features actually 210 // become a source of errors. Removing support for these features actually
211 // allows for a simpler implementation, and a terser Currying API. 211 // allows for a simpler implementation, and a terser Currying API.
212 // 212 //
213 // 213 //
214 // WHY NOT GOOGLE CALLBACKS? 214 // WHY NOT GOOGLE CALLBACKS?
215 // 215 //
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 305
306 ]] $$ for ARITY 306 ]] $$ for ARITY
307 307
308 // Syntactic sugar to make Callbacks<void(void)> easier to declare since it 308 // Syntactic sugar to make Callbacks<void(void)> easier to declare since it
309 // will be used in a lot of APIs with delayed execution. 309 // will be used in a lot of APIs with delayed execution.
310 typedef Callback<void(void)> Closure; 310 typedef Callback<void(void)> Closure;
311 311
312 } // namespace base 312 } // namespace base
313 313
314 #endif // BASE_CALLBACK_H 314 #endif // BASE_CALLBACK_H
OLDNEW
« no previous file with comments | « base/callback.h ('k') | chrome/browser/chrome_benchmarking_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698