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

Side by Side Diff: base/callback.h

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 | « no previous file | base/callback.h.pump » ('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 file was GENERATED by command: 1 // This file was GENERATED by command:
2 // pump.py callback.h.pump 2 // pump.py callback.h.pump
3 // DO NOT EDIT BY HAND!!! 3 // DO NOT EDIT BY HAND!!!
4 4
5 5
6 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 6 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
7 // Use of this source code is governed by a BSD-style license that can be 7 // Use of this source code is governed by a BSD-style license that can be
8 // found in the LICENSE file. 8 // found in the LICENSE file.
9 9
10 #ifndef BASE_CALLBACK_H_ 10 #ifndef BASE_CALLBACK_H_
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // The design Callback and Bind is heavily influenced by C++'s 117 // The design Callback and Bind is heavily influenced by C++'s
118 // tr1::function/tr1::bind, and by the "Google Callback" system used inside 118 // tr1::function/tr1::bind, and by the "Google Callback" system used inside
119 // Google. 119 // Google.
120 // 120 //
121 // 121 //
122 // HOW THE IMPLEMENTATION WORKS: 122 // HOW THE IMPLEMENTATION WORKS:
123 // 123 //
124 // There are three main components to the system: 124 // There are three main components to the system:
125 // 1) The Callback classes. 125 // 1) The Callback classes.
126 // 2) The Bind() functions. 126 // 2) The Bind() functions.
127 // 3) The arguments wrappers (eg., Unretained() and ConstRef()). 127 // 3) The arguments wrappers (e.g., Unretained() and ConstRef()).
128 // 128 //
129 // The Callback classes represent a generic function pointer. Internally, 129 // The Callback classes represent a generic function pointer. Internally,
130 // it stores a refcounted piece of state that represents the target function 130 // it stores a refcounted piece of state that represents the target function
131 // and all its bound parameters. Each Callback specialization has a templated 131 // and all its bound parameters. Each Callback specialization has a templated
132 // constructor that takes an BindStateHolder<> object. In the context of 132 // constructor that takes an BindStateHolder<> object. In the context of
133 // the constructor, the static type of this BindStateHolder<> object 133 // the constructor, the static type of this BindStateHolder<> object
134 // uniquely identifies the function it is representing, all its bound 134 // uniquely identifies the function it is representing, all its bound
135 // parameters, and a DoInvoke() that is capable of invoking the target. 135 // parameters, and a DoInvoke() that is capable of invoking the target.
136 // 136 //
137 // Callback's constructor is takes the BindStateHolder<> that has the 137 // Callback's constructor is takes the BindStateHolder<> that has the
(...skipping 15 matching lines...) Expand all
153 // refcounting semantics for the target object if we are binding a class 153 // refcounting semantics for the target object if we are binding a class
154 // method. 154 // method.
155 // 155 //
156 // The Bind functions do the above using type-inference, and template 156 // The Bind functions do the above using type-inference, and template
157 // specializations. 157 // specializations.
158 // 158 //
159 // By default Bind() will store copies of all bound parameters, and attempt 159 // By default Bind() will store copies of all bound parameters, and attempt
160 // to refcount a target object if the function being bound is a class method. 160 // to refcount a target object if the function being bound is a class method.
161 // 161 //
162 // To change this behavior, we introduce a set of argument wrappers 162 // To change this behavior, we introduce a set of argument wrappers
163 // (eg. Unretained(), and ConstRef()). These are simple container templates 163 // (e.g., Unretained(), and ConstRef()). These are simple container templates
164 // that are passed by value, and wrap a pointer to argument. See the 164 // that are passed by value, and wrap a pointer to argument. See the
165 // file-level comment in base/bind_helpers.h for more info. 165 // file-level comment in base/bind_helpers.h for more info.
166 // 166 //
167 // These types are passed to the Unwrap() functions, and the MaybeRefcount() 167 // These types are passed to the Unwrap() functions, and the MaybeRefcount()
168 // functions respectively to modify the behavior of Bind(). The Unwrap() 168 // functions respectively to modify the behavior of Bind(). The Unwrap()
169 // and MaybeRefcount() functions change behavior by doing partial 169 // and MaybeRefcount() functions change behavior by doing partial
170 // specialization based on whether or not a parameter is a wrapper type. 170 // specialization based on whether or not a parameter is a wrapper type.
171 // 171 //
172 // ConstRef() is similar to tr1::cref. Unretained() is specific to Chromium. 172 // ConstRef() is similar to tr1::cref. Unretained() is specific to Chromium.
173 // 173 //
(...skipping 16 matching lines...) Expand all
190 // tr1::function causes a copy to be made of all the bound parameters and 190 // tr1::function causes a copy to be made of all the bound parameters and
191 // state. 191 // state.
192 // 192 //
193 // Furthermore, in Chromium, it is desirable for the Callback to take a 193 // Furthermore, in Chromium, it is desirable for the Callback to take a
194 // reference on a target object when representing a class method call. This 194 // reference on a target object when representing a class method call. This
195 // is not supported by tr1. 195 // is not supported by tr1.
196 // 196 //
197 // Lastly, tr1::function and tr1::bind has a more general and flexible API. 197 // Lastly, tr1::function and tr1::bind has a more general and flexible API.
198 // This includes things like argument reordering by use of 198 // This includes things like argument reordering by use of
199 // tr1::bind::placeholder, support for non-const reference parameters, and some 199 // tr1::bind::placeholder, support for non-const reference parameters, and some
200 // limited amount of subtyping of the tr1::function object (eg., 200 // limited amount of subtyping of the tr1::function object (e.g.,
201 // tr1::function<int(int)> is convertible to tr1::function<void(int)>). 201 // tr1::function<int(int)> is convertible to tr1::function<void(int)>).
202 // 202 //
203 // These are not features that are required in Chromium. Some of them, such as 203 // These are not features that are required in Chromium. Some of them, such as
204 // allowing for reference parameters, and subtyping of functions, may actually 204 // allowing for reference parameters, and subtyping of functions, may actually
205 // become a source of errors. Removing support for these features actually 205 // become a source of errors. Removing support for these features actually
206 // allows for a simpler implementation, and a terser Currying API. 206 // allows for a simpler implementation, and a terser Currying API.
207 // 207 //
208 // 208 //
209 // WHY NOT GOOGLE CALLBACKS? 209 // WHY NOT GOOGLE CALLBACKS?
210 // 210 //
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 }; 641 };
642 642
643 643
644 // Syntactic sugar to make Callbacks<void(void)> easier to declare since it 644 // Syntactic sugar to make Callbacks<void(void)> easier to declare since it
645 // will be used in a lot of APIs with delayed execution. 645 // will be used in a lot of APIs with delayed execution.
646 typedef Callback<void(void)> Closure; 646 typedef Callback<void(void)> Closure;
647 647
648 } // namespace base 648 } // namespace base
649 649
650 #endif // BASE_CALLBACK_H 650 #endif // BASE_CALLBACK_H
OLDNEW
« no previous file with comments | « no previous file | base/callback.h.pump » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698