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

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

Issue 7015064: Support binding WeakPtr<> to methods with void return types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix a few comments. Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « base/callback.h ('k') | base/template_util.h » ('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 $var MAX_ARITY = 6 8 $var MAX_ARITY = 6
9 9
10 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 10 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
(...skipping 29 matching lines...) Expand all
40 // and thus do not need to be deleted. 40 // and thus do not need to be deleted.
41 // 41 //
42 // The reason to pass via a const-reference is to avoid unnecessary 42 // The reason to pass via a const-reference is to avoid unnecessary
43 // AddRef/Release pairs to the internal state. 43 // AddRef/Release pairs to the internal state.
44 // 44 //
45 // 45 //
46 // EXAMPLE USAGE: 46 // EXAMPLE USAGE:
47 // 47 //
48 // /* Binding a normal function. */ 48 // /* Binding a normal function. */
49 // int Return5() { return 5; } 49 // int Return5() { return 5; }
50 // base::Callback<int(int)> func_cb = base::Bind(&Return5); 50 // base::Callback<int(void)> func_cb = base::Bind(&Return5);
51 // LOG(INFO) << func_cb.Run(5); // Prints 5. 51 // LOG(INFO) << func_cb.Run(); // Prints 5.
52 // 52 //
53 // void PrintHi() { LOG(INFO) << "hi."; } 53 // void PrintHi() { LOG(INFO) << "hi."; }
54 // base::Closure void_func_cb = base::Bind(&PrintHi); 54 // base::Closure void_func_cb = base::Bind(&PrintHi);
55 // LOG(INFO) << void_func_cb.Run(); // Prints: hi. 55 // void_func_cb.Run(); // Prints: hi.
56 // 56 //
57 // /* Binding a class method. */ 57 // /* Binding a class method. */
58 // class Ref : public RefCountedThreadSafe<Ref> { 58 // class Ref : public RefCountedThreadSafe<Ref> {
59 // public: 59 // public:
60 // int Foo() { return 3; } 60 // int Foo() { return 3; }
61 // void PrintBye() { LOG(INFO) << "bye."; } 61 // void PrintBye() { LOG(INFO) << "bye."; }
62 // }; 62 // };
63 // scoped_refptr<Ref> ref = new Ref(); 63 // scoped_refptr<Ref> ref = new Ref();
64 // base::Callback<int(void)> ref_cb = base::Bind(&Ref::Foo, ref.get()); 64 // base::Callback<int(void)> ref_cb = base::Bind(&Ref::Foo, ref.get());
65 // LOG(INFO) << ref_cb.Run(); // Prints out 3. 65 // LOG(INFO) << ref_cb.Run(); // Prints out 3.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // is not supported by tr1. 184 // is not supported by tr1.
185 // 185 //
186 // Lastly, tr1::function and tr1::bind has a more general and flexible API. 186 // Lastly, tr1::function and tr1::bind has a more general and flexible API.
187 // This includes things like argument reordering by use of 187 // This includes things like argument reordering by use of
188 // tr1::bind::placeholder, support for non-const reference parameters, and some 188 // tr1::bind::placeholder, support for non-const reference parameters, and some
189 // limited amount of subtyping of the tr1::function object (eg., 189 // limited amount of subtyping of the tr1::function object (eg.,
190 // tr1::function<int(int)> is convertible to tr1::function<void(int)>). 190 // tr1::function<int(int)> is convertible to tr1::function<void(int)>).
191 // 191 //
192 // These are not features that are required in Chromium. Some of them, such as 192 // These are not features that are required in Chromium. Some of them, such as
193 // allowing for reference parameters, and subtyping of functions, may actually 193 // allowing for reference parameters, and subtyping of functions, may actually
194 // because a source of errors. Removing support for these features actually 194 // become a source of errors. Removing support for these features actually
195 // allows for a simpler implementation, and a terser Currying API. 195 // allows for a simpler implementation, and a terser Currying API.
196 // 196 //
197 // 197 //
198 // WHY NOT GOOGLE CALLBACKS? 198 // WHY NOT GOOGLE CALLBACKS?
199 // 199 //
200 // The Google callback system also does not support refcounting. Furthermore, 200 // The Google callback system also does not support refcounting. Furthermore,
201 // its implementation has a number of strange edge cases with respect to type 201 // its implementation has a number of strange edge cases with respect to type
202 // conversion of its arguments. In particular, the argument's constness must 202 // conversion of its arguments. In particular, the argument's constness must
203 // at times match exactly the function signature, or the type-inference might 203 // at times match exactly the function signature, or the type-inference might
204 // break. Given the above, writing a custom solution was easier. 204 // break. Given the above, writing a custom solution was easier.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 ]] $$ for ARITY 276 ]] $$ for ARITY
277 277
278 // Syntactic sugar to make Callbacks<void(void)> easier to declare since it 278 // Syntactic sugar to make Callbacks<void(void)> easier to declare since it
279 // will be used in a lot of APIs with delayed execution. 279 // will be used in a lot of APIs with delayed execution.
280 typedef Callback<void(void)> Closure; 280 typedef Callback<void(void)> Closure;
281 281
282 } // namespace base 282 } // namespace base
283 283
284 #endif // BASE_CALLBACK_H 284 #endif // BASE_CALLBACK_H
OLDNEW
« no previous file with comments | « base/callback.h ('k') | base/template_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698