srpcgen: Use 'const char*' for string parameters
[chromium-blink-merge.git] / base / callback.h
blobab8f7bb8a711d39f85069b3fdcbf65a09948ba44
1 // This file was GENERATED by command:
2 // pump.py callback.h.pump
3 // DO NOT EDIT BY HAND!!!
6 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
7 // Use of this source code is governed by a BSD-style license that can be
8 // found in the LICENSE file.
10 #ifndef BASE_CALLBACK_H_
11 #define BASE_CALLBACK_H_
12 #pragma once
14 #include "base/callback_forward.h"
15 #include "base/callback_internal.h"
16 #include "base/template_util.h"
18 // NOTE: Header files that do not require the full definition of Callback or
19 // Closure should #include "base/callback_forward.h" instead of this file.
21 // WHAT IS THIS:
23 // The templated Callback class is a generalized function object. Together
24 // with the Bind() function in bind.h, they provide a type-safe method for
25 // performing currying of arguments, and creating a "closure."
27 // In programming languages, a closure is a first-class function where all its
28 // parameters have been bound (usually via currying). Closures are well
29 // suited for representing, and passing around a unit of delayed execution.
30 // They are used in Chromium code to schedule tasks on different MessageLoops.
33 // MEMORY MANAGEMENT AND PASSING
35 // The Callback objects themselves should be passed by const-reference, and
36 // stored by copy. They internally store their state via a refcounted class
37 // and thus do not need to be deleted.
39 // The reason to pass via a const-reference is to avoid unnecessary
40 // AddRef/Release pairs to the internal state.
43 // EXAMPLE USAGE:
45 // /* Binding a normal function. */
46 // int Return5() { return 5; }
47 // base::Callback<int(void)> func_cb = base::Bind(&Return5);
48 // LOG(INFO) << func_cb.Run(); // Prints 5.
50 // void PrintHi() { LOG(INFO) << "hi."; }
51 // base::Closure void_func_cb = base::Bind(&PrintHi);
52 // void_func_cb.Run(); // Prints: hi.
54 // /* Binding a class method. */
55 // class Ref : public RefCountedThreadSafe<Ref> {
56 // public:
57 // int Foo() { return 3; }
58 // void PrintBye() { LOG(INFO) << "bye."; }
59 // };
60 // scoped_refptr<Ref> ref = new Ref();
61 // base::Callback<int(void)> ref_cb = base::Bind(&Ref::Foo, ref.get());
62 // LOG(INFO) << ref_cb.Run(); // Prints out 3.
64 // base::Closure void_ref_cb = base::Bind(&Ref::PrintBye, ref.get());
65 // void_ref_cb.Run(); // Prints: bye.
67 // /* Binding a class method in a non-refcounted class.
68 // *
69 // * WARNING: You must be sure the referee outlives the callback!
70 // * This is particularly important if you post a closure to a
71 // * MessageLoop because then it becomes hard to know what the
72 // * lifetime of the referee needs to be.
73 // */
74 // class NoRef {
75 // public:
76 // int Foo() { return 4; }
77 // void PrintWhy() { LOG(INFO) << "why???"; }
78 // };
79 // NoRef no_ref;
80 // base::Callback<int(void)> base::no_ref_cb =
81 // base::Bind(&NoRef::Foo, base::Unretained(&no_ref));
82 // LOG(INFO) << ref_cb.Run(); // Prints out 4.
84 // base::Closure void_no_ref_cb =
85 // base::Bind(&NoRef::PrintWhy, base::Unretained(no_ref));
86 // void_no_ref_cb.Run(); // Prints: why???
88 // /* Binding a reference. */
89 // int Identity(int n) { return n; }
90 // int value = 1;
91 // base::Callback<int(void)> bound_copy_cb = base::Bind(&Identity, value);
92 // base::Callback<int(void)> bound_ref_cb =
93 // base::Bind(&Identity, base::ConstRef(value));
94 // LOG(INFO) << bound_copy_cb.Run(); // Prints 1.
95 // LOG(INFO) << bound_ref_cb.Run(); // Prints 1.
96 // value = 2;
97 // LOG(INFO) << bound_copy_cb.Run(); // Prints 1.
98 // LOG(INFO) << bound_ref_cb.Run(); // Prints 2.
100 // /* Currying parameters. This also works for methods. */
101 // int Sum(int a, int b, int c) {
102 // return a + b + c;
103 // }
104 // base::Callback<int(int, int)> sum3_cb = base::Bind(&Sum, 3);
105 // LOG(INFO) << sum3_cb.Run(4, 5); // Prints 12.
107 // base::Callback<int(int)> sum7_cb = base::Bind(&Sum, 3, 4);
108 // LOG(INFO) << sum7_cb.Run(10); // Prints 17.
111 // WHERE IS THIS DESIGN FROM:
113 // The design Callback and Bind is heavily influenced by C++'s
114 // tr1::function/tr1::bind, and by the "Google Callback" system used inside
115 // Google.
118 // HOW THE IMPLEMENTATION WORKS:
120 // There are three main components to the system:
121 // 1) The Callback classes.
122 // 2) The Bind() functions.
123 // 3) The arguments wrappers (e.g., Unretained() and ConstRef()).
125 // The Callback classes represent a generic function pointer. Internally,
126 // it stores a refcounted piece of state that represents the target function
127 // and all its bound parameters. Each Callback specialization has a templated
128 // constructor that takes an BindState<>*. In the context of the constructor,
129 // the static type of this BindState<> pointer uniquely identifies the
130 // function it is representing, all its bound parameters, and a Run() method
131 // that is capable of invoking the target.
133 // Callback's constructor takes the BindState<>* that has the full static type
134 // and erases the target function type as well as the types of the bound
135 // parameters. It does this by storing a pointer to the specific Run()
136 // function, and upcasting the state of BindState<>* to a
137 // BindStateBase*. This is safe as long as this BindStateBase pointer
138 // is only used with the stored Run() pointer.
140 // To BindState<> objects are created inside the Bind() functions.
141 // These functions, along with a set of internal templates, are responsible for
143 // - Unwrapping the function signature into return type, and parameters
144 // - Determining the number of parameters that are bound
145 // - Creating the BindState storing the bound parameters
146 // - Performing compile-time asserts to avoid error-prone behavior
147 // - Returning an Callback<> with an arity matching the number of unbound
148 // parameters and that knows the correct refcounting semantics for the
149 // target object if we are binding a method.
151 // The Bind functions do the above using type-inference, and template
152 // specializations.
154 // By default Bind() will store copies of all bound parameters, and attempt
155 // to refcount a target object if the function being bound is a class method.
157 // To change this behavior, we introduce a set of argument wrappers
158 // (e.g., Unretained(), and ConstRef()). These are simple container templates
159 // that are passed by value, and wrap a pointer to argument. See the
160 // file-level comment in base/bind_helpers.h for more info.
162 // These types are passed to the Unwrap() functions, and the MaybeRefcount()
163 // functions respectively to modify the behavior of Bind(). The Unwrap()
164 // and MaybeRefcount() functions change behavior by doing partial
165 // specialization based on whether or not a parameter is a wrapper type.
167 // ConstRef() is similar to tr1::cref. Unretained() is specific to Chromium.
170 // WHY NOT TR1 FUNCTION/BIND?
172 // Direct use of tr1::function and tr1::bind was considered, but ultimately
173 // rejected because of the number of copy constructors invocations involved
174 // in the binding of arguments during construction, and the forwarding of
175 // arguments during invocation. These copies will no longer be an issue in
176 // C++0x because C++0x will support rvalue reference allowing for the compiler
177 // to avoid these copies. However, waiting for C++0x is not an option.
179 // Measured with valgrind on gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5), the
180 // tr1::bind call itself will invoke a non-trivial copy constructor three times
181 // for each bound parameter. Also, each when passing a tr1::function, each
182 // bound argument will be copied again.
184 // In addition to the copies taken at binding and invocation, copying a
185 // tr1::function causes a copy to be made of all the bound parameters and
186 // state.
188 // Furthermore, in Chromium, it is desirable for the Callback to take a
189 // reference on a target object when representing a class method call. This
190 // is not supported by tr1.
192 // Lastly, tr1::function and tr1::bind has a more general and flexible API.
193 // This includes things like argument reordering by use of
194 // tr1::bind::placeholder, support for non-const reference parameters, and some
195 // limited amount of subtyping of the tr1::function object (e.g.,
196 // tr1::function<int(int)> is convertible to tr1::function<void(int)>).
198 // These are not features that are required in Chromium. Some of them, such as
199 // allowing for reference parameters, and subtyping of functions, may actually
200 // become a source of errors. Removing support for these features actually
201 // allows for a simpler implementation, and a terser Currying API.
204 // WHY NOT GOOGLE CALLBACKS?
206 // The Google callback system also does not support refcounting. Furthermore,
207 // its implementation has a number of strange edge cases with respect to type
208 // conversion of its arguments. In particular, the argument's constness must
209 // at times match exactly the function signature, or the type-inference might
210 // break. Given the above, writing a custom solution was easier.
213 // MISSING FUNCTIONALITY
214 // - Invoking the return of Bind. Bind(&foo).Run() does not work;
215 // - Binding arrays to functions that take a non-const pointer.
216 // Example:
217 // void Foo(const char* ptr);
218 // void Bar(char* ptr);
219 // Bind(&Foo, "test");
220 // Bind(&Bar, "test"); // This fails because ptr is not const.
222 namespace base {
224 // First, we forward declare the Callback class template. This informs the
225 // compiler that the template only has 1 type parameter which is the function
226 // signature that the Callback is representing.
228 // After this, create template specializations for 0-7 parameters. Note that
229 // even though the template typelist grows, the specialization still
230 // only has one type: the function signature.
232 // If you are thinking of forward declaring Callback in your own header file,
233 // please include "base/callback_forward.h" instead.
234 template <typename Sig>
235 class Callback;
237 namespace internal {
238 template <typename Runnable, typename RunType, typename BoundArgsType>
239 struct BindState;
240 } // namespace internal
242 template <typename R>
243 class Callback<R(void)> : public internal::CallbackBase {
244 public:
245 typedef R(RunType)();
247 Callback() : CallbackBase(NULL) { }
249 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
250 // return the exact Callback<> type. See base/bind.h for details.
251 template <typename Runnable, typename RunType, typename BoundArgsType>
252 Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state)
253 : CallbackBase(bind_state) {
255 // Force the assignment to a local variable of PolymorphicInvoke
256 // so the compiler will typecheck that the passed in Run() method has
257 // the correct type.
258 PolymorphicInvoke invoke_func =
259 &internal::BindState<Runnable, RunType, BoundArgsType>
260 ::InvokerType::Run;
261 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
264 bool Equals(const Callback& other) const {
265 return CallbackBase::Equals(other);
268 R Run() const {
269 PolymorphicInvoke f =
270 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
272 return f(bind_state_.get());
275 private:
276 typedef R(*PolymorphicInvoke)(
277 internal::BindStateBase*);
281 template <typename R, typename A1>
282 class Callback<R(A1)> : public internal::CallbackBase {
283 public:
284 typedef R(RunType)(A1);
286 Callback() : CallbackBase(NULL) { }
288 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
289 // return the exact Callback<> type. See base/bind.h for details.
290 template <typename Runnable, typename RunType, typename BoundArgsType>
291 Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state)
292 : CallbackBase(bind_state) {
294 // Force the assignment to a local variable of PolymorphicInvoke
295 // so the compiler will typecheck that the passed in Run() method has
296 // the correct type.
297 PolymorphicInvoke invoke_func =
298 &internal::BindState<Runnable, RunType, BoundArgsType>
299 ::InvokerType::Run;
300 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
303 bool Equals(const Callback& other) const {
304 return CallbackBase::Equals(other);
307 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1) const {
308 PolymorphicInvoke f =
309 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
311 return f(bind_state_.get(), internal::CallbackForward(a1));
314 private:
315 typedef R(*PolymorphicInvoke)(
316 internal::BindStateBase*,
317 typename internal::CallbackParamTraits<A1>::ForwardType);
321 template <typename R, typename A1, typename A2>
322 class Callback<R(A1, A2)> : public internal::CallbackBase {
323 public:
324 typedef R(RunType)(A1, A2);
326 Callback() : CallbackBase(NULL) { }
328 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
329 // return the exact Callback<> type. See base/bind.h for details.
330 template <typename Runnable, typename RunType, typename BoundArgsType>
331 Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state)
332 : CallbackBase(bind_state) {
334 // Force the assignment to a local variable of PolymorphicInvoke
335 // so the compiler will typecheck that the passed in Run() method has
336 // the correct type.
337 PolymorphicInvoke invoke_func =
338 &internal::BindState<Runnable, RunType, BoundArgsType>
339 ::InvokerType::Run;
340 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
343 bool Equals(const Callback& other) const {
344 return CallbackBase::Equals(other);
347 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
348 typename internal::CallbackParamTraits<A2>::ForwardType a2) const {
349 PolymorphicInvoke f =
350 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
352 return f(bind_state_.get(), internal::CallbackForward(a1),
353 internal::CallbackForward(a2));
356 private:
357 typedef R(*PolymorphicInvoke)(
358 internal::BindStateBase*,
359 typename internal::CallbackParamTraits<A1>::ForwardType,
360 typename internal::CallbackParamTraits<A2>::ForwardType);
364 template <typename R, typename A1, typename A2, typename A3>
365 class Callback<R(A1, A2, A3)> : public internal::CallbackBase {
366 public:
367 typedef R(RunType)(A1, A2, A3);
369 Callback() : CallbackBase(NULL) { }
371 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
372 // return the exact Callback<> type. See base/bind.h for details.
373 template <typename Runnable, typename RunType, typename BoundArgsType>
374 Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state)
375 : CallbackBase(bind_state) {
377 // Force the assignment to a local variable of PolymorphicInvoke
378 // so the compiler will typecheck that the passed in Run() method has
379 // the correct type.
380 PolymorphicInvoke invoke_func =
381 &internal::BindState<Runnable, RunType, BoundArgsType>
382 ::InvokerType::Run;
383 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
386 bool Equals(const Callback& other) const {
387 return CallbackBase::Equals(other);
390 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
391 typename internal::CallbackParamTraits<A2>::ForwardType a2,
392 typename internal::CallbackParamTraits<A3>::ForwardType a3) const {
393 PolymorphicInvoke f =
394 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
396 return f(bind_state_.get(), internal::CallbackForward(a1),
397 internal::CallbackForward(a2),
398 internal::CallbackForward(a3));
401 private:
402 typedef R(*PolymorphicInvoke)(
403 internal::BindStateBase*,
404 typename internal::CallbackParamTraits<A1>::ForwardType,
405 typename internal::CallbackParamTraits<A2>::ForwardType,
406 typename internal::CallbackParamTraits<A3>::ForwardType);
410 template <typename R, typename A1, typename A2, typename A3, typename A4>
411 class Callback<R(A1, A2, A3, A4)> : public internal::CallbackBase {
412 public:
413 typedef R(RunType)(A1, A2, A3, A4);
415 Callback() : CallbackBase(NULL) { }
417 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
418 // return the exact Callback<> type. See base/bind.h for details.
419 template <typename Runnable, typename RunType, typename BoundArgsType>
420 Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state)
421 : CallbackBase(bind_state) {
423 // Force the assignment to a local variable of PolymorphicInvoke
424 // so the compiler will typecheck that the passed in Run() method has
425 // the correct type.
426 PolymorphicInvoke invoke_func =
427 &internal::BindState<Runnable, RunType, BoundArgsType>
428 ::InvokerType::Run;
429 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
432 bool Equals(const Callback& other) const {
433 return CallbackBase::Equals(other);
436 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
437 typename internal::CallbackParamTraits<A2>::ForwardType a2,
438 typename internal::CallbackParamTraits<A3>::ForwardType a3,
439 typename internal::CallbackParamTraits<A4>::ForwardType a4) const {
440 PolymorphicInvoke f =
441 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
443 return f(bind_state_.get(), internal::CallbackForward(a1),
444 internal::CallbackForward(a2),
445 internal::CallbackForward(a3),
446 internal::CallbackForward(a4));
449 private:
450 typedef R(*PolymorphicInvoke)(
451 internal::BindStateBase*,
452 typename internal::CallbackParamTraits<A1>::ForwardType,
453 typename internal::CallbackParamTraits<A2>::ForwardType,
454 typename internal::CallbackParamTraits<A3>::ForwardType,
455 typename internal::CallbackParamTraits<A4>::ForwardType);
459 template <typename R, typename A1, typename A2, typename A3, typename A4,
460 typename A5>
461 class Callback<R(A1, A2, A3, A4, A5)> : public internal::CallbackBase {
462 public:
463 typedef R(RunType)(A1, A2, A3, A4, A5);
465 Callback() : CallbackBase(NULL) { }
467 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
468 // return the exact Callback<> type. See base/bind.h for details.
469 template <typename Runnable, typename RunType, typename BoundArgsType>
470 Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state)
471 : CallbackBase(bind_state) {
473 // Force the assignment to a local variable of PolymorphicInvoke
474 // so the compiler will typecheck that the passed in Run() method has
475 // the correct type.
476 PolymorphicInvoke invoke_func =
477 &internal::BindState<Runnable, RunType, BoundArgsType>
478 ::InvokerType::Run;
479 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
482 bool Equals(const Callback& other) const {
483 return CallbackBase::Equals(other);
486 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
487 typename internal::CallbackParamTraits<A2>::ForwardType a2,
488 typename internal::CallbackParamTraits<A3>::ForwardType a3,
489 typename internal::CallbackParamTraits<A4>::ForwardType a4,
490 typename internal::CallbackParamTraits<A5>::ForwardType a5) const {
491 PolymorphicInvoke f =
492 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
494 return f(bind_state_.get(), internal::CallbackForward(a1),
495 internal::CallbackForward(a2),
496 internal::CallbackForward(a3),
497 internal::CallbackForward(a4),
498 internal::CallbackForward(a5));
501 private:
502 typedef R(*PolymorphicInvoke)(
503 internal::BindStateBase*,
504 typename internal::CallbackParamTraits<A1>::ForwardType,
505 typename internal::CallbackParamTraits<A2>::ForwardType,
506 typename internal::CallbackParamTraits<A3>::ForwardType,
507 typename internal::CallbackParamTraits<A4>::ForwardType,
508 typename internal::CallbackParamTraits<A5>::ForwardType);
512 template <typename R, typename A1, typename A2, typename A3, typename A4,
513 typename A5, typename A6>
514 class Callback<R(A1, A2, A3, A4, A5, A6)> : public internal::CallbackBase {
515 public:
516 typedef R(RunType)(A1, A2, A3, A4, A5, A6);
518 Callback() : CallbackBase(NULL) { }
520 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
521 // return the exact Callback<> type. See base/bind.h for details.
522 template <typename Runnable, typename RunType, typename BoundArgsType>
523 Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state)
524 : CallbackBase(bind_state) {
526 // Force the assignment to a local variable of PolymorphicInvoke
527 // so the compiler will typecheck that the passed in Run() method has
528 // the correct type.
529 PolymorphicInvoke invoke_func =
530 &internal::BindState<Runnable, RunType, BoundArgsType>
531 ::InvokerType::Run;
532 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
535 bool Equals(const Callback& other) const {
536 return CallbackBase::Equals(other);
539 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
540 typename internal::CallbackParamTraits<A2>::ForwardType a2,
541 typename internal::CallbackParamTraits<A3>::ForwardType a3,
542 typename internal::CallbackParamTraits<A4>::ForwardType a4,
543 typename internal::CallbackParamTraits<A5>::ForwardType a5,
544 typename internal::CallbackParamTraits<A6>::ForwardType a6) const {
545 PolymorphicInvoke f =
546 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
548 return f(bind_state_.get(), internal::CallbackForward(a1),
549 internal::CallbackForward(a2),
550 internal::CallbackForward(a3),
551 internal::CallbackForward(a4),
552 internal::CallbackForward(a5),
553 internal::CallbackForward(a6));
556 private:
557 typedef R(*PolymorphicInvoke)(
558 internal::BindStateBase*,
559 typename internal::CallbackParamTraits<A1>::ForwardType,
560 typename internal::CallbackParamTraits<A2>::ForwardType,
561 typename internal::CallbackParamTraits<A3>::ForwardType,
562 typename internal::CallbackParamTraits<A4>::ForwardType,
563 typename internal::CallbackParamTraits<A5>::ForwardType,
564 typename internal::CallbackParamTraits<A6>::ForwardType);
568 template <typename R, typename A1, typename A2, typename A3, typename A4,
569 typename A5, typename A6, typename A7>
570 class Callback<R(A1, A2, A3, A4, A5, A6, A7)> : public internal::CallbackBase {
571 public:
572 typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7);
574 Callback() : CallbackBase(NULL) { }
576 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
577 // return the exact Callback<> type. See base/bind.h for details.
578 template <typename Runnable, typename RunType, typename BoundArgsType>
579 Callback(internal::BindState<Runnable, RunType, BoundArgsType>* bind_state)
580 : CallbackBase(bind_state) {
582 // Force the assignment to a local variable of PolymorphicInvoke
583 // so the compiler will typecheck that the passed in Run() method has
584 // the correct type.
585 PolymorphicInvoke invoke_func =
586 &internal::BindState<Runnable, RunType, BoundArgsType>
587 ::InvokerType::Run;
588 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
591 bool Equals(const Callback& other) const {
592 return CallbackBase::Equals(other);
595 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
596 typename internal::CallbackParamTraits<A2>::ForwardType a2,
597 typename internal::CallbackParamTraits<A3>::ForwardType a3,
598 typename internal::CallbackParamTraits<A4>::ForwardType a4,
599 typename internal::CallbackParamTraits<A5>::ForwardType a5,
600 typename internal::CallbackParamTraits<A6>::ForwardType a6,
601 typename internal::CallbackParamTraits<A7>::ForwardType a7) const {
602 PolymorphicInvoke f =
603 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
605 return f(bind_state_.get(), internal::CallbackForward(a1),
606 internal::CallbackForward(a2),
607 internal::CallbackForward(a3),
608 internal::CallbackForward(a4),
609 internal::CallbackForward(a5),
610 internal::CallbackForward(a6),
611 internal::CallbackForward(a7));
614 private:
615 typedef R(*PolymorphicInvoke)(
616 internal::BindStateBase*,
617 typename internal::CallbackParamTraits<A1>::ForwardType,
618 typename internal::CallbackParamTraits<A2>::ForwardType,
619 typename internal::CallbackParamTraits<A3>::ForwardType,
620 typename internal::CallbackParamTraits<A4>::ForwardType,
621 typename internal::CallbackParamTraits<A5>::ForwardType,
622 typename internal::CallbackParamTraits<A6>::ForwardType,
623 typename internal::CallbackParamTraits<A7>::ForwardType);
628 // Syntactic sugar to make Callbacks<void(void)> easier to declare since it
629 // will be used in a lot of APIs with delayed execution.
630 typedef Callback<void(void)> Closure;
632 } // namespace base
634 #endif // BASE_CALLBACK_H