blob: 364f506139f66652aff19669e02d281e6d8bc9fb [file] [log] [blame]
ajwong@chromium.orge2cca632011-02-15 10:27:38 +09001// This file was GENERATED by command:
2// pump.py callback.h.pump
3// DO NOT EDIT BY HAND!!!
4
5
ajwong@chromium.org22a8a0d2012-01-04 09:57:39 +09006// Copyright (c) 2012 The Chromium Authors. All rights reserved.
akalin@chromium.org6ed4f882010-02-19 12:15:59 +09007// Use of this source code is governed by a BSD-style license that can be
8// found in the LICENSE file.
9
10#ifndef BASE_CALLBACK_H_
11#define BASE_CALLBACK_H_
12
erikwright@chromium.orgac2a1882011-12-08 06:44:06 +090013#include "base/callback_forward.h"
ajwong@chromium.orgfa0ff432011-02-19 08:29:31 +090014#include "base/callback_internal.h"
ajwong@chromium.orgec1750a2011-06-27 01:22:50 +090015#include "base/template_util.h"
akalin@chromium.org6ed4f882010-02-19 12:15:59 +090016
erikwright@chromium.orgac2a1882011-12-08 06:44:06 +090017// NOTE: Header files that do not require the full definition of Callback or
18// Closure should #include "base/callback_forward.h" instead of this file.
19
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +090020// -----------------------------------------------------------------------------
21// Introduction
22// -----------------------------------------------------------------------------
akalin@chromium.org6ed4f882010-02-19 12:15:59 +090023//
ajwong@chromium.orge2cca632011-02-15 10:27:38 +090024// The templated Callback class is a generalized function object. Together
25// with the Bind() function in bind.h, they provide a type-safe method for
dubroy@chromium.org43d9ac32012-12-07 04:00:50 +090026// performing partial application of functions.
akalin@chromium.org6ed4f882010-02-19 12:15:59 +090027//
dubroy@chromium.org43d9ac32012-12-07 04:00:50 +090028// Partial application (or "currying") is the process of binding a subset of
29// a function's arguments to produce another function that takes fewer
30// arguments. This can be used to pass around a unit of delayed execution,
31// much like lexical closures are used in other languages. For example, it
32// is used in Chromium code to schedule tasks on different MessageLoops.
akalin@chromium.org6ed4f882010-02-19 12:15:59 +090033//
dubroy@chromium.org43d9ac32012-12-07 04:00:50 +090034// A callback with no unbound input parameters (base::Callback<void(void)>)
35// is called a base::Closure. Note that this is NOT the same as what other
36// languages refer to as a closure -- it does not retain a reference to its
37// enclosing environment.
akalin@chromium.org6ed4f882010-02-19 12:15:59 +090038//
ajwong@chromium.orge2cca632011-02-15 10:27:38 +090039// MEMORY MANAGEMENT AND PASSING
akalin@chromium.org6ed4f882010-02-19 12:15:59 +090040//
ajwong@chromium.orge2cca632011-02-15 10:27:38 +090041// The Callback objects themselves should be passed by const-reference, and
42// stored by copy. They internally store their state via a refcounted class
43// and thus do not need to be deleted.
akalin@chromium.org6ed4f882010-02-19 12:15:59 +090044//
ajwong@chromium.orge2cca632011-02-15 10:27:38 +090045// The reason to pass via a const-reference is to avoid unnecessary
46// AddRef/Release pairs to the internal state.
47//
48//
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +090049// -----------------------------------------------------------------------------
50// Quick reference for basic stuff
51// -----------------------------------------------------------------------------
ajwong@chromium.orge2cca632011-02-15 10:27:38 +090052//
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +090053// BINDING A BARE FUNCTION
ajwong@chromium.orge2cca632011-02-15 10:27:38 +090054//
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +090055// int Return5() { return 5; }
56// base::Callback<int(void)> func_cb = base::Bind(&Return5);
57// LOG(INFO) << func_cb.Run(); // Prints 5.
ajwong@chromium.orge2cca632011-02-15 10:27:38 +090058//
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +090059// BINDING A CLASS METHOD
ajwong@chromium.orge2cca632011-02-15 10:27:38 +090060//
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +090061// The first argument to bind is the member function to call, the second is
62// the object on which to call it.
ajwong@chromium.orge2cca632011-02-15 10:27:38 +090063//
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +090064// class Ref : public base::RefCountedThreadSafe<Ref> {
65// public:
66// int Foo() { return 3; }
67// void PrintBye() { LOG(INFO) << "bye."; }
68// };
69// scoped_refptr<Ref> ref = new Ref();
70// base::Callback<void(void)> ref_cb = base::Bind(&Ref::Foo, ref);
71// LOG(INFO) << ref_cb.Run(); // Prints out 3.
ajwong@chromium.orge2cca632011-02-15 10:27:38 +090072//
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +090073// By default the object must support RefCounted or you will get a compiler
74// error. If you're passing between threads, be sure it's
75// RefCountedThreadSafe! See "Advanced binding of member functions" below if
76// you don't want to use reference counting.
ajwong@chromium.orge2cca632011-02-15 10:27:38 +090077//
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +090078// RUNNING A CALLBACK
ajwong@chromium.orge2cca632011-02-15 10:27:38 +090079//
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +090080// Callbacks can be run with their "Run" method, which has the same
81// signature as the template argument to the callback.
ajwong@chromium.org97d22e32011-05-19 05:21:12 +090082//
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +090083// void DoSomething(const base::Callback<void(int, std::string)>& callback) {
84// callback.Run(5, "hello");
85// }
ajwong@chromium.org97d22e32011-05-19 05:21:12 +090086//
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +090087// Callbacks can be run more than once (they don't get deleted or marked when
88// run). However, this precludes using base::Passed (see below).
89//
90// void DoSomething(const base::Callback<double(double)>& callback) {
91// double myresult = callback.Run(3.14159);
92// myresult += callback.Run(2.71828);
93// }
94//
95// PASSING UNBOUND INPUT PARAMETERS
96//
97// Unbound parameters are specified at the time a callback is Run(). They are
98// specified in the Callback template type:
99//
100// void MyFunc(int i, const std::string& str) {}
101// base::Callback<void(int, const std::string&)> cb = base::Bind(&MyFunc);
102// cb.Run(23, "hello, world");
103//
104// PASSING BOUND INPUT PARAMETERS
105//
106// Bound parameters are specified when you create thee callback as arguments
107// to Bind(). They will be passed to the function and the Run()ner of the
108// callback doesn't see those values or even know that the function it's
109// calling.
110//
111// void MyFunc(int i, const std::string& str) {}
112// base::Callback<void(void)> cb = base::Bind(&MyFunc, 23, "hello world");
113// cb.Run();
114//
115// A callback with no unbound input parameters (base::Callback<void(void)>)
116// is called a base::Closure. So we could have also written:
117//
118// base::Closure cb = base::Bind(&MyFunc, 23, "hello world");
119//
120// When calling member functions, bound parameters just go after the object
121// pointer.
122//
123// base::Closure cb = base::Bind(&MyClass::MyFunc, this, 23, "hello world");
124//
125// PARTIAL BINDING OF PARAMETERS
126//
127// You can specify some parameters when you create the callback, and specify
128// the rest when you execute the callback.
129//
130// void MyFunc(int i, const std::string& str) {}
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900131// base::Callback<void(const std::string&)> cb = base::Bind(&MyFunc, 23);
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +0900132// cb.Run("hello world");
133//
134// When calling a function bound parameters are first, followed by unbound
135// parameters.
136//
137//
138// -----------------------------------------------------------------------------
139// Quick reference for advanced binding
140// -----------------------------------------------------------------------------
141//
142// BINDING A CLASS METHOD WITH WEAK POINTERS
143//
144// base::Bind(&MyClass::Foo, GetWeakPtr());
145//
brandonsalmon@chromium.orgacaaae72014-06-26 15:07:45 +0900146// The callback will not be run if the object has already been destroyed.
147// DANGER: weak pointers are not threadsafe, so don't use this
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +0900148// when passing between threads!
149//
150// BINDING A CLASS METHOD WITH MANUAL LIFETIME MANAGEMENT
151//
152// base::Bind(&MyClass::Foo, base::Unretained(this));
153//
154// This disables all lifetime management on the object. You're responsible
155// for making sure the object is alive at the time of the call. You break it,
156// you own it!
157//
158// BINDING A CLASS METHOD AND HAVING THE CALLBACK OWN THE CLASS
159//
160// MyClass* myclass = new MyClass;
161// base::Bind(&MyClass::Foo, base::Owned(myclass));
162//
163// The object will be deleted when the callback is destroyed, even if it's
164// not run (like if you post a task during shutdown). Potentially useful for
165// "fire and forget" cases.
166//
167// IGNORING RETURN VALUES
168//
169// Sometimes you want to call a function that returns a value in a callback
170// that doesn't expect a return value.
171//
172// int DoSomething(int arg) { cout << arg << endl; }
173// base::Callback<void<int>) cb =
174// base::Bind(base::IgnoreResult(&DoSomething));
175//
176//
177// -----------------------------------------------------------------------------
178// Quick reference for binding parameters to Bind()
179// -----------------------------------------------------------------------------
180//
181// Bound parameters are specified as arguments to Bind() and are passed to the
182// function. A callback with no parameters or no unbound parameters is called a
183// Closure (base::Callback<void(void)> and base::Closure are the same thing).
184//
185// PASSING PARAMETERS OWNED BY THE CALLBACK
186//
187// void Foo(int* arg) { cout << *arg << endl; }
188// int* pn = new int(1);
189// base::Closure foo_callback = base::Bind(&foo, base::Owned(pn));
190//
191// The parameter will be deleted when the callback is destroyed, even if it's
192// not run (like if you post a task during shutdown).
193//
194// PASSING PARAMETERS AS A scoped_ptr
195//
196// void TakesOwnership(scoped_ptr<Foo> arg) {}
197// scoped_ptr<Foo> f(new Foo);
198// // f becomes null during the following call.
199// base::Closure cb = base::Bind(&TakesOwnership, base::Passed(&f));
200//
201// Ownership of the parameter will be with the callback until the it is run,
202// when ownership is passed to the callback function. This means the callback
203// can only be run once. If the callback is never run, it will delete the
204// object when it's destroyed.
205//
206// PASSING PARAMETERS AS A scoped_refptr
207//
208// void TakesOneRef(scoped_refptr<Foo> arg) {}
209// scoped_refptr<Foo> f(new Foo)
210// base::Closure cb = base::Bind(&TakesOneRef, f);
211//
212// This should "just work." The closure will take a reference as long as it
213// is alive, and another reference will be taken for the called function.
214//
215// PASSING PARAMETERS BY REFERENCE
216//
scheib@chromium.orga2f2a9b2013-11-28 14:18:53 +0900217// Const references are *copied* unless ConstRef is used. Example:
218//
219// void foo(const int& arg) { printf("%d %p\n", arg, &arg); }
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +0900220// int n = 1;
scheib@chromium.orga2f2a9b2013-11-28 14:18:53 +0900221// base::Closure has_copy = base::Bind(&foo, n);
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +0900222// base::Closure has_ref = base::Bind(&foo, base::ConstRef(n));
223// n = 2;
scheib@chromium.orga2f2a9b2013-11-28 14:18:53 +0900224// foo(n); // Prints "2 0xaaaaaaaaaaaa"
225// has_copy.Run(); // Prints "1 0xbbbbbbbbbbbb"
226// has_ref.Run(); // Prints "2 0xaaaaaaaaaaaa"
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +0900227//
228// Normally parameters are copied in the closure. DANGER: ConstRef stores a
229// const reference instead, referencing the original parameter. This means
230// that you must ensure the object outlives the callback!
231//
232//
233// -----------------------------------------------------------------------------
234// Implementation notes
235// -----------------------------------------------------------------------------
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900236//
237// WHERE IS THIS DESIGN FROM:
238//
239// The design Callback and Bind is heavily influenced by C++'s
240// tr1::function/tr1::bind, and by the "Google Callback" system used inside
241// Google.
242//
243//
244// HOW THE IMPLEMENTATION WORKS:
245//
246// There are three main components to the system:
247// 1) The Callback classes.
248// 2) The Bind() functions.
jhawkins@chromium.orgbb87d2a2011-12-13 09:06:28 +0900249// 3) The arguments wrappers (e.g., Unretained() and ConstRef()).
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900250//
251// The Callback classes represent a generic function pointer. Internally,
252// it stores a refcounted piece of state that represents the target function
253// and all its bound parameters. Each Callback specialization has a templated
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900254// constructor that takes an BindState<>*. In the context of the constructor,
255// the static type of this BindState<> pointer uniquely identifies the
256// function it is representing, all its bound parameters, and a Run() method
257// that is capable of invoking the target.
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900258//
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900259// Callback's constructor takes the BindState<>* that has the full static type
260// and erases the target function type as well as the types of the bound
261// parameters. It does this by storing a pointer to the specific Run()
262// function, and upcasting the state of BindState<>* to a
263// BindStateBase*. This is safe as long as this BindStateBase pointer
264// is only used with the stored Run() pointer.
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900265//
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900266// To BindState<> objects are created inside the Bind() functions.
267// These functions, along with a set of internal templates, are responsible for
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900268//
269// - Unwrapping the function signature into return type, and parameters
270// - Determining the number of parameters that are bound
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900271// - Creating the BindState storing the bound parameters
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900272// - Performing compile-time asserts to avoid error-prone behavior
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900273// - Returning an Callback<> with an arity matching the number of unbound
274// parameters and that knows the correct refcounting semantics for the
275// target object if we are binding a method.
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900276//
277// The Bind functions do the above using type-inference, and template
278// specializations.
279//
280// By default Bind() will store copies of all bound parameters, and attempt
281// to refcount a target object if the function being bound is a class method.
groby@chromium.org34d50fa2012-10-11 12:54:33 +0900282// These copies are created even if the function takes parameters as const
dubroy@chromium.org43d9ac32012-12-07 04:00:50 +0900283// references. (Binding to non-const references is forbidden, see bind.h.)
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900284//
285// To change this behavior, we introduce a set of argument wrappers
jhawkins@chromium.orgbb87d2a2011-12-13 09:06:28 +0900286// (e.g., Unretained(), and ConstRef()). These are simple container templates
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900287// that are passed by value, and wrap a pointer to argument. See the
288// file-level comment in base/bind_helpers.h for more info.
289//
290// These types are passed to the Unwrap() functions, and the MaybeRefcount()
291// functions respectively to modify the behavior of Bind(). The Unwrap()
292// and MaybeRefcount() functions change behavior by doing partial
293// specialization based on whether or not a parameter is a wrapper type.
294//
295// ConstRef() is similar to tr1::cref. Unretained() is specific to Chromium.
296//
297//
298// WHY NOT TR1 FUNCTION/BIND?
299//
300// Direct use of tr1::function and tr1::bind was considered, but ultimately
301// rejected because of the number of copy constructors invocations involved
302// in the binding of arguments during construction, and the forwarding of
303// arguments during invocation. These copies will no longer be an issue in
304// C++0x because C++0x will support rvalue reference allowing for the compiler
305// to avoid these copies. However, waiting for C++0x is not an option.
306//
307// Measured with valgrind on gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5), the
308// tr1::bind call itself will invoke a non-trivial copy constructor three times
309// for each bound parameter. Also, each when passing a tr1::function, each
310// bound argument will be copied again.
311//
312// In addition to the copies taken at binding and invocation, copying a
313// tr1::function causes a copy to be made of all the bound parameters and
314// state.
315//
316// Furthermore, in Chromium, it is desirable for the Callback to take a
317// reference on a target object when representing a class method call. This
318// is not supported by tr1.
319//
320// Lastly, tr1::function and tr1::bind has a more general and flexible API.
321// This includes things like argument reordering by use of
322// tr1::bind::placeholder, support for non-const reference parameters, and some
jhawkins@chromium.orgbb87d2a2011-12-13 09:06:28 +0900323// limited amount of subtyping of the tr1::function object (e.g.,
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900324// tr1::function<int(int)> is convertible to tr1::function<void(int)>).
325//
326// These are not features that are required in Chromium. Some of them, such as
327// allowing for reference parameters, and subtyping of functions, may actually
thakis@chromium.org21cbe222011-04-20 03:22:00 +0900328// become a source of errors. Removing support for these features actually
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900329// allows for a simpler implementation, and a terser Currying API.
330//
331//
332// WHY NOT GOOGLE CALLBACKS?
333//
334// The Google callback system also does not support refcounting. Furthermore,
335// its implementation has a number of strange edge cases with respect to type
336// conversion of its arguments. In particular, the argument's constness must
337// at times match exactly the function signature, or the type-inference might
338// break. Given the above, writing a custom solution was easier.
339//
340//
341// MISSING FUNCTIONALITY
342// - Invoking the return of Bind. Bind(&foo).Run() does not work;
343// - Binding arrays to functions that take a non-const pointer.
344// Example:
345// void Foo(const char* ptr);
346// void Bar(char* ptr);
347// Bind(&Foo, "test");
348// Bind(&Bar, "test"); // This fails because ptr is not const.
akalin@chromium.org6ed4f882010-02-19 12:15:59 +0900349
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900350namespace base {
351
352// First, we forward declare the Callback class template. This informs the
353// compiler that the template only has 1 type parameter which is the function
354// signature that the Callback is representing.
355//
ajwong@chromium.org6f015bd2011-11-29 07:13:54 +0900356// After this, create template specializations for 0-7 parameters. Note that
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900357// even though the template typelist grows, the specialization still
358// only has one type: the function signature.
erikwright@chromium.orgac2a1882011-12-08 06:44:06 +0900359//
360// If you are thinking of forward declaring Callback in your own header file,
361// please include "base/callback_forward.h" instead.
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900362template <typename Sig>
363class Callback;
ajwong@chromium.orge0648232011-02-19 09:52:15 +0900364
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900365namespace internal {
366template <typename Runnable, typename RunType, typename BoundArgsType>
367struct BindState;
368} // namespace internal
369
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900370template <typename R>
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900371class Callback<R(void)> : public internal::CallbackBase {
akalin@chromium.org6ed4f882010-02-19 12:15:59 +0900372 public:
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900373 typedef R(RunType)();
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900374
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900375 Callback() : CallbackBase(NULL) { }
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900376
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900377 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
378 // return the exact Callback<> type. See base/bind.h for details.
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900379 template <typename Runnable, typename BindRunType, typename BoundArgsType>
380 Callback(internal::BindState<Runnable, BindRunType,
381 BoundArgsType>* bind_state)
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900382 : CallbackBase(bind_state) {
383
384 // Force the assignment to a local variable of PolymorphicInvoke
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900385 // so the compiler will typecheck that the passed in Run() method has
386 // the correct type.
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900387 PolymorphicInvoke invoke_func =
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900388 &internal::BindState<Runnable, BindRunType, BoundArgsType>
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900389 ::InvokerType::Run;
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900390 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
akalin@chromium.org6ed4f882010-02-19 12:15:59 +0900391 }
392
ajwong@chromium.org3bc50ce2011-09-10 12:14:35 +0900393 bool Equals(const Callback& other) const {
394 return CallbackBase::Equals(other);
395 }
396
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900397 R Run() const {
398 PolymorphicInvoke f =
399 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
akalin@chromium.org6ed4f882010-02-19 12:15:59 +0900400
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900401 return f(bind_state_.get());
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900402 }
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900403
404 private:
405 typedef R(*PolymorphicInvoke)(
406 internal::BindStateBase*);
407
akalin@chromium.org6ed4f882010-02-19 12:15:59 +0900408};
409
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900410template <typename R, typename A1>
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900411class Callback<R(A1)> : public internal::CallbackBase {
akalin@chromium.org6ed4f882010-02-19 12:15:59 +0900412 public:
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900413 typedef R(RunType)(A1);
akalin@chromium.org6ed4f882010-02-19 12:15:59 +0900414
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900415 Callback() : CallbackBase(NULL) { }
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900416
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900417 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
418 // return the exact Callback<> type. See base/bind.h for details.
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900419 template <typename Runnable, typename BindRunType, typename BoundArgsType>
420 Callback(internal::BindState<Runnable, BindRunType,
421 BoundArgsType>* bind_state)
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900422 : CallbackBase(bind_state) {
423
424 // Force the assignment to a local variable of PolymorphicInvoke
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900425 // so the compiler will typecheck that the passed in Run() method has
426 // the correct type.
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900427 PolymorphicInvoke invoke_func =
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900428 &internal::BindState<Runnable, BindRunType, BoundArgsType>
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900429 ::InvokerType::Run;
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900430 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
akalin@chromium.org6ed4f882010-02-19 12:15:59 +0900431 }
432
ajwong@chromium.org3bc50ce2011-09-10 12:14:35 +0900433 bool Equals(const Callback& other) const {
434 return CallbackBase::Equals(other);
435 }
436
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900437 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1) const {
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900438 PolymorphicInvoke f =
439 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900440
ajwong@chromium.orgf66a7db2011-12-23 06:12:58 +0900441 return f(bind_state_.get(), internal::CallbackForward(a1));
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900442 }
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900443
444 private:
445 typedef R(*PolymorphicInvoke)(
446 internal::BindStateBase*,
447 typename internal::CallbackParamTraits<A1>::ForwardType);
448
akalin@chromium.org6ed4f882010-02-19 12:15:59 +0900449};
450
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900451template <typename R, typename A1, typename A2>
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900452class Callback<R(A1, A2)> : public internal::CallbackBase {
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900453 public:
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900454 typedef R(RunType)(A1, A2);
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900455
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900456 Callback() : CallbackBase(NULL) { }
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900457
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900458 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
459 // return the exact Callback<> type. See base/bind.h for details.
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900460 template <typename Runnable, typename BindRunType, typename BoundArgsType>
461 Callback(internal::BindState<Runnable, BindRunType,
462 BoundArgsType>* bind_state)
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900463 : CallbackBase(bind_state) {
464
465 // Force the assignment to a local variable of PolymorphicInvoke
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900466 // so the compiler will typecheck that the passed in Run() method has
467 // the correct type.
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900468 PolymorphicInvoke invoke_func =
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900469 &internal::BindState<Runnable, BindRunType, BoundArgsType>
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900470 ::InvokerType::Run;
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900471 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900472 }
473
ajwong@chromium.org3bc50ce2011-09-10 12:14:35 +0900474 bool Equals(const Callback& other) const {
475 return CallbackBase::Equals(other);
476 }
477
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900478 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
479 typename internal::CallbackParamTraits<A2>::ForwardType a2) const {
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900480 PolymorphicInvoke f =
481 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900482
ajwong@chromium.orgf66a7db2011-12-23 06:12:58 +0900483 return f(bind_state_.get(), internal::CallbackForward(a1),
484 internal::CallbackForward(a2));
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900485 }
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900486
487 private:
488 typedef R(*PolymorphicInvoke)(
489 internal::BindStateBase*,
490 typename internal::CallbackParamTraits<A1>::ForwardType,
491 typename internal::CallbackParamTraits<A2>::ForwardType);
492
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900493};
494
495template <typename R, typename A1, typename A2, typename A3>
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900496class Callback<R(A1, A2, A3)> : public internal::CallbackBase {
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900497 public:
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900498 typedef R(RunType)(A1, A2, A3);
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900499
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900500 Callback() : CallbackBase(NULL) { }
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900501
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900502 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
503 // return the exact Callback<> type. See base/bind.h for details.
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900504 template <typename Runnable, typename BindRunType, typename BoundArgsType>
505 Callback(internal::BindState<Runnable, BindRunType,
506 BoundArgsType>* bind_state)
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900507 : CallbackBase(bind_state) {
508
509 // Force the assignment to a local variable of PolymorphicInvoke
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900510 // so the compiler will typecheck that the passed in Run() method has
511 // the correct type.
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900512 PolymorphicInvoke invoke_func =
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900513 &internal::BindState<Runnable, BindRunType, BoundArgsType>
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900514 ::InvokerType::Run;
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900515 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900516 }
517
ajwong@chromium.org3bc50ce2011-09-10 12:14:35 +0900518 bool Equals(const Callback& other) const {
519 return CallbackBase::Equals(other);
520 }
521
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900522 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
523 typename internal::CallbackParamTraits<A2>::ForwardType a2,
524 typename internal::CallbackParamTraits<A3>::ForwardType a3) const {
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900525 PolymorphicInvoke f =
526 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900527
ajwong@chromium.orgf66a7db2011-12-23 06:12:58 +0900528 return f(bind_state_.get(), internal::CallbackForward(a1),
529 internal::CallbackForward(a2),
530 internal::CallbackForward(a3));
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900531 }
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900532
533 private:
534 typedef R(*PolymorphicInvoke)(
535 internal::BindStateBase*,
536 typename internal::CallbackParamTraits<A1>::ForwardType,
537 typename internal::CallbackParamTraits<A2>::ForwardType,
538 typename internal::CallbackParamTraits<A3>::ForwardType);
539
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900540};
541
542template <typename R, typename A1, typename A2, typename A3, typename A4>
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900543class Callback<R(A1, A2, A3, A4)> : public internal::CallbackBase {
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900544 public:
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900545 typedef R(RunType)(A1, A2, A3, A4);
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900546
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900547 Callback() : CallbackBase(NULL) { }
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900548
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900549 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
550 // return the exact Callback<> type. See base/bind.h for details.
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900551 template <typename Runnable, typename BindRunType, typename BoundArgsType>
552 Callback(internal::BindState<Runnable, BindRunType,
553 BoundArgsType>* bind_state)
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900554 : CallbackBase(bind_state) {
555
556 // Force the assignment to a local variable of PolymorphicInvoke
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900557 // so the compiler will typecheck that the passed in Run() method has
558 // the correct type.
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900559 PolymorphicInvoke invoke_func =
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900560 &internal::BindState<Runnable, BindRunType, BoundArgsType>
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900561 ::InvokerType::Run;
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900562 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900563 }
564
ajwong@chromium.org3bc50ce2011-09-10 12:14:35 +0900565 bool Equals(const Callback& other) const {
566 return CallbackBase::Equals(other);
567 }
568
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900569 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
570 typename internal::CallbackParamTraits<A2>::ForwardType a2,
571 typename internal::CallbackParamTraits<A3>::ForwardType a3,
572 typename internal::CallbackParamTraits<A4>::ForwardType a4) const {
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900573 PolymorphicInvoke f =
574 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900575
ajwong@chromium.orgf66a7db2011-12-23 06:12:58 +0900576 return f(bind_state_.get(), internal::CallbackForward(a1),
577 internal::CallbackForward(a2),
578 internal::CallbackForward(a3),
579 internal::CallbackForward(a4));
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900580 }
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900581
582 private:
583 typedef R(*PolymorphicInvoke)(
584 internal::BindStateBase*,
585 typename internal::CallbackParamTraits<A1>::ForwardType,
586 typename internal::CallbackParamTraits<A2>::ForwardType,
587 typename internal::CallbackParamTraits<A3>::ForwardType,
588 typename internal::CallbackParamTraits<A4>::ForwardType);
589
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900590};
591
592template <typename R, typename A1, typename A2, typename A3, typename A4,
593 typename A5>
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900594class Callback<R(A1, A2, A3, A4, A5)> : public internal::CallbackBase {
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900595 public:
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900596 typedef R(RunType)(A1, A2, A3, A4, A5);
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900597
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900598 Callback() : CallbackBase(NULL) { }
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900599
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900600 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
601 // return the exact Callback<> type. See base/bind.h for details.
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900602 template <typename Runnable, typename BindRunType, typename BoundArgsType>
603 Callback(internal::BindState<Runnable, BindRunType,
604 BoundArgsType>* bind_state)
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900605 : CallbackBase(bind_state) {
606
607 // Force the assignment to a local variable of PolymorphicInvoke
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900608 // so the compiler will typecheck that the passed in Run() method has
609 // the correct type.
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900610 PolymorphicInvoke invoke_func =
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900611 &internal::BindState<Runnable, BindRunType, BoundArgsType>
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900612 ::InvokerType::Run;
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900613 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900614 }
615
ajwong@chromium.org3bc50ce2011-09-10 12:14:35 +0900616 bool Equals(const Callback& other) const {
617 return CallbackBase::Equals(other);
618 }
619
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900620 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
621 typename internal::CallbackParamTraits<A2>::ForwardType a2,
622 typename internal::CallbackParamTraits<A3>::ForwardType a3,
623 typename internal::CallbackParamTraits<A4>::ForwardType a4,
624 typename internal::CallbackParamTraits<A5>::ForwardType a5) const {
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900625 PolymorphicInvoke f =
626 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900627
ajwong@chromium.orgf66a7db2011-12-23 06:12:58 +0900628 return f(bind_state_.get(), internal::CallbackForward(a1),
629 internal::CallbackForward(a2),
630 internal::CallbackForward(a3),
631 internal::CallbackForward(a4),
632 internal::CallbackForward(a5));
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900633 }
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900634
635 private:
636 typedef R(*PolymorphicInvoke)(
637 internal::BindStateBase*,
638 typename internal::CallbackParamTraits<A1>::ForwardType,
639 typename internal::CallbackParamTraits<A2>::ForwardType,
640 typename internal::CallbackParamTraits<A3>::ForwardType,
641 typename internal::CallbackParamTraits<A4>::ForwardType,
642 typename internal::CallbackParamTraits<A5>::ForwardType);
643
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900644};
645
646template <typename R, typename A1, typename A2, typename A3, typename A4,
647 typename A5, typename A6>
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900648class Callback<R(A1, A2, A3, A4, A5, A6)> : public internal::CallbackBase {
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900649 public:
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900650 typedef R(RunType)(A1, A2, A3, A4, A5, A6);
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900651
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900652 Callback() : CallbackBase(NULL) { }
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900653
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900654 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
655 // return the exact Callback<> type. See base/bind.h for details.
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900656 template <typename Runnable, typename BindRunType, typename BoundArgsType>
657 Callback(internal::BindState<Runnable, BindRunType,
658 BoundArgsType>* bind_state)
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900659 : CallbackBase(bind_state) {
660
661 // Force the assignment to a local variable of PolymorphicInvoke
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900662 // so the compiler will typecheck that the passed in Run() method has
663 // the correct type.
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900664 PolymorphicInvoke invoke_func =
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900665 &internal::BindState<Runnable, BindRunType, BoundArgsType>
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900666 ::InvokerType::Run;
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900667 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900668 }
669
ajwong@chromium.org3bc50ce2011-09-10 12:14:35 +0900670 bool Equals(const Callback& other) const {
671 return CallbackBase::Equals(other);
672 }
673
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900674 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
675 typename internal::CallbackParamTraits<A2>::ForwardType a2,
676 typename internal::CallbackParamTraits<A3>::ForwardType a3,
677 typename internal::CallbackParamTraits<A4>::ForwardType a4,
678 typename internal::CallbackParamTraits<A5>::ForwardType a5,
679 typename internal::CallbackParamTraits<A6>::ForwardType a6) const {
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900680 PolymorphicInvoke f =
681 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900682
ajwong@chromium.orgf66a7db2011-12-23 06:12:58 +0900683 return f(bind_state_.get(), internal::CallbackForward(a1),
684 internal::CallbackForward(a2),
685 internal::CallbackForward(a3),
686 internal::CallbackForward(a4),
687 internal::CallbackForward(a5),
688 internal::CallbackForward(a6));
ajwong@chromium.org62fb0a02011-02-18 13:05:14 +0900689 }
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900690
691 private:
692 typedef R(*PolymorphicInvoke)(
693 internal::BindStateBase*,
694 typename internal::CallbackParamTraits<A1>::ForwardType,
695 typename internal::CallbackParamTraits<A2>::ForwardType,
696 typename internal::CallbackParamTraits<A3>::ForwardType,
697 typename internal::CallbackParamTraits<A4>::ForwardType,
698 typename internal::CallbackParamTraits<A5>::ForwardType,
699 typename internal::CallbackParamTraits<A6>::ForwardType);
700
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900701};
702
ajwong@chromium.org6f015bd2011-11-29 07:13:54 +0900703template <typename R, typename A1, typename A2, typename A3, typename A4,
704 typename A5, typename A6, typename A7>
705class Callback<R(A1, A2, A3, A4, A5, A6, A7)> : public internal::CallbackBase {
706 public:
707 typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7);
708
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900709 Callback() : CallbackBase(NULL) { }
ajwong@chromium.org6f015bd2011-11-29 07:13:54 +0900710
ajwong@chromium.org6f015bd2011-11-29 07:13:54 +0900711 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
712 // return the exact Callback<> type. See base/bind.h for details.
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900713 template <typename Runnable, typename BindRunType, typename BoundArgsType>
714 Callback(internal::BindState<Runnable, BindRunType,
715 BoundArgsType>* bind_state)
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900716 : CallbackBase(bind_state) {
717
718 // Force the assignment to a local variable of PolymorphicInvoke
ajwong@chromium.org6f015bd2011-11-29 07:13:54 +0900719 // so the compiler will typecheck that the passed in Run() method has
720 // the correct type.
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900721 PolymorphicInvoke invoke_func =
xiaomings@google.comdcfad552012-08-14 08:11:50 +0900722 &internal::BindState<Runnable, BindRunType, BoundArgsType>
ajwong@chromium.orgabd70002011-12-20 09:10:04 +0900723 ::InvokerType::Run;
ajwong@chromium.org6f015bd2011-11-29 07:13:54 +0900724 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
725 }
726
727 bool Equals(const Callback& other) const {
728 return CallbackBase::Equals(other);
729 }
730
731 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
732 typename internal::CallbackParamTraits<A2>::ForwardType a2,
733 typename internal::CallbackParamTraits<A3>::ForwardType a3,
734 typename internal::CallbackParamTraits<A4>::ForwardType a4,
735 typename internal::CallbackParamTraits<A5>::ForwardType a5,
736 typename internal::CallbackParamTraits<A6>::ForwardType a6,
737 typename internal::CallbackParamTraits<A7>::ForwardType a7) const {
738 PolymorphicInvoke f =
739 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
740
ajwong@chromium.orgf66a7db2011-12-23 06:12:58 +0900741 return f(bind_state_.get(), internal::CallbackForward(a1),
742 internal::CallbackForward(a2),
743 internal::CallbackForward(a3),
744 internal::CallbackForward(a4),
745 internal::CallbackForward(a5),
746 internal::CallbackForward(a6),
747 internal::CallbackForward(a7));
ajwong@chromium.org6f015bd2011-11-29 07:13:54 +0900748 }
749
750 private:
751 typedef R(*PolymorphicInvoke)(
752 internal::BindStateBase*,
753 typename internal::CallbackParamTraits<A1>::ForwardType,
754 typename internal::CallbackParamTraits<A2>::ForwardType,
755 typename internal::CallbackParamTraits<A3>::ForwardType,
756 typename internal::CallbackParamTraits<A4>::ForwardType,
757 typename internal::CallbackParamTraits<A5>::ForwardType,
758 typename internal::CallbackParamTraits<A6>::ForwardType,
759 typename internal::CallbackParamTraits<A7>::ForwardType);
760
761};
762
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900763
wtc@chromium.org98eec042014-07-03 15:10:13 +0900764// Syntactic sugar to make Callback<void(void)> easier to declare since it
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900765// will be used in a lot of APIs with delayed execution.
766typedef Callback<void(void)> Closure;
767
768} // namespace base
akalin@chromium.org6ed4f882010-02-19 12:15:59 +0900769
770#endif // BASE_CALLBACK_H