Home | History | Annotate | Download | only in base
      1 // This file was GENERATED by command:
      2 //     pump.py bind_internal.h.pump
      3 // DO NOT EDIT BY HAND!!!
      4 
      5 
      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
      8 // found in the LICENSE file.
      9 
     10 #ifndef BASE_BIND_INTERNAL_H_
     11 #define BASE_BIND_INTERNAL_H_
     12 
     13 #include "base/bind_helpers.h"
     14 #include "base/callback_internal.h"
     15 #include "base/memory/raw_scoped_refptr_mismatch_checker.h"
     16 #include "base/memory/weak_ptr.h"
     17 #include "base/template_util.h"
     18 #include "build/build_config.h"
     19 
     20 #if defined(OS_WIN)
     21 #include "base/bind_internal_win.h"
     22 #endif
     23 
     24 namespace base {
     25 namespace internal {
     26 
     27 // See base/callback.h for user documentation.
     28 //
     29 //
     30 // CONCEPTS:
     31 //  Runnable -- A type (really a type class) that has a single Run() method
     32 //              and a RunType typedef that corresponds to the type of Run().
     33 //              A Runnable can declare that it should treated like a method
     34 //              call by including a typedef named IsMethod.  The value of
     35 //              this typedef is NOT inspected, only the existence.  When a
     36 //              Runnable declares itself a method, Bind() will enforce special
     37 //              refcounting + WeakPtr handling semantics for the first
     38 //              parameter which is expected to be an object.
     39 //  Functor -- A copyable type representing something that should be called.
     40 //             All function pointers, Callback<>, and Runnables are functors
     41 //             even if the invocation syntax differs.
     42 //  RunType -- A function type (as opposed to function _pointer_ type) for
     43 //             a Run() function.  Usually just a convenience typedef.
     44 //  (Bound)ArgsType -- A function type that is being (ab)used to store the
     45 //                     types of set of arguments.  The "return" type is always
     46 //                     void here.  We use this hack so that we do not need
     47 //                     a new type name for each arity of type. (eg.,
     48 //                     BindState1, BindState2).  This makes forward
     49 //                     declarations and friending much much easier.
     50 //
     51 // Types:
     52 //  RunnableAdapter<> -- Wraps the various "function" pointer types into an
     53 //                       object that adheres to the Runnable interface.
     54 //                       There are |3*ARITY| RunnableAdapter types.
     55 //  FunctionTraits<> -- Type traits that unwrap a function signature into a
     56 //                      a set of easier to use typedefs.  Used mainly for
     57 //                      compile time asserts.
     58 //                      There are |ARITY| FunctionTraits types.
     59 //  ForceVoidReturn<> -- Helper class for translating function signatures to
     60 //                       equivalent forms with a "void" return type.
     61 //                    There are |ARITY| ForceVoidReturn types.
     62 //  FunctorTraits<> -- Type traits used determine the correct RunType and
     63 //                     RunnableType for a Functor.  This is where function
     64 //                     signature adapters are applied.
     65 //                    There are |ARITY| ForceVoidReturn types.
     66 //  MakeRunnable<> -- Takes a Functor and returns an object in the Runnable
     67 //                    type class that represents the underlying Functor.
     68 //                    There are |O(1)| MakeRunnable types.
     69 //  InvokeHelper<> -- Take a Runnable + arguments and actully invokes it.
     70 // Handle the differing syntaxes needed for WeakPtr<> support,
     71 //                    and for ignoring return values.  This is separate from
     72 //                    Invoker to avoid creating multiple version of Invoker<>
     73 //                    which grows at O(n^2) with the arity.
     74 //                    There are |k*ARITY| InvokeHelper types.
     75 //  Invoker<> -- Unwraps the curried parameters and executes the Runnable.
     76 //               There are |(ARITY^2 + ARITY)/2| Invoketypes.
     77 //  BindState<> -- Stores the curried parameters, and is the main entry point
     78 //                 into the Bind() system, doing most of the type resolution.
     79 //                 There are ARITY BindState types.
     80 
     81 // RunnableAdapter<>
     82 //
     83 // The RunnableAdapter<> templates provide a uniform interface for invoking
     84 // a function pointer, method pointer, or const method pointer. The adapter
     85 // exposes a Run() method with an appropriate signature. Using this wrapper
     86 // allows for writing code that supports all three pointer types without
     87 // undue repetition.  Without it, a lot of code would need to be repeated 3
     88 // times.
     89 //
     90 // For method pointers and const method pointers the first argument to Run()
     91 // is considered to be the received of the method.  This is similar to STL's
     92 // mem_fun().
     93 //
     94 // This class also exposes a RunType typedef that is the function type of the
     95 // Run() function.
     96 //
     97 // If and only if the wrapper contains a method or const method pointer, an
     98 // IsMethod typedef is exposed.  The existence of this typedef (NOT the value)
     99 // marks that the wrapper should be considered a method wrapper.
    100 
    101 template <typename Functor>
    102 class RunnableAdapter;
    103 
    104 // Function: Arity 0.
    105 template <typename R>
    106 class RunnableAdapter<R(*)()> {
    107  public:
    108   typedef R (RunType)();
    109 
    110   explicit RunnableAdapter(R(*function)())
    111       : function_(function) {
    112   }
    113 
    114   R Run() {
    115     return function_();
    116   }
    117 
    118  private:
    119   R (*function_)();
    120 };
    121 
    122 // Method: Arity 0.
    123 template <typename R, typename T>
    124 class RunnableAdapter<R(T::*)()> {
    125  public:
    126   typedef R (RunType)(T*);
    127   typedef true_type IsMethod;
    128 
    129   explicit RunnableAdapter(R(T::*method)())
    130       : method_(method) {
    131   }
    132 
    133   R Run(T* object) {
    134     return (object->*method_)();
    135   }
    136 
    137  private:
    138   R (T::*method_)();
    139 };
    140 
    141 // Const Method: Arity 0.
    142 template <typename R, typename T>
    143 class RunnableAdapter<R(T::*)() const> {
    144  public:
    145   typedef R (RunType)(const T*);
    146   typedef true_type IsMethod;
    147 
    148   explicit RunnableAdapter(R(T::*method)() const)
    149       : method_(method) {
    150   }
    151 
    152   R Run(const T* object) {
    153     return (object->*method_)();
    154   }
    155 
    156  private:
    157   R (T::*method_)() const;
    158 };
    159 
    160 // Function: Arity 1.
    161 template <typename R, typename A1>
    162 class RunnableAdapter<R(*)(A1)> {
    163  public:
    164   typedef R (RunType)(A1);
    165 
    166   explicit RunnableAdapter(R(*function)(A1))
    167       : function_(function) {
    168   }
    169 
    170   R Run(typename CallbackParamTraits<A1>::ForwardType a1) {
    171     return function_(CallbackForward(a1));
    172   }
    173 
    174  private:
    175   R (*function_)(A1);
    176 };
    177 
    178 // Method: Arity 1.
    179 template <typename R, typename T, typename A1>
    180 class RunnableAdapter<R(T::*)(A1)> {
    181  public:
    182   typedef R (RunType)(T*, A1);
    183   typedef true_type IsMethod;
    184 
    185   explicit RunnableAdapter(R(T::*method)(A1))
    186       : method_(method) {
    187   }
    188 
    189   R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1) {
    190     return (object->*method_)(CallbackForward(a1));
    191   }
    192 
    193  private:
    194   R (T::*method_)(A1);
    195 };
    196 
    197 // Const Method: Arity 1.
    198 template <typename R, typename T, typename A1>
    199 class RunnableAdapter<R(T::*)(A1) const> {
    200  public:
    201   typedef R (RunType)(const T*, A1);
    202   typedef true_type IsMethod;
    203 
    204   explicit RunnableAdapter(R(T::*method)(A1) const)
    205       : method_(method) {
    206   }
    207 
    208   R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1) {
    209     return (object->*method_)(CallbackForward(a1));
    210   }
    211 
    212  private:
    213   R (T::*method_)(A1) const;
    214 };
    215 
    216 // Function: Arity 2.
    217 template <typename R, typename A1, typename A2>
    218 class RunnableAdapter<R(*)(A1, A2)> {
    219  public:
    220   typedef R (RunType)(A1, A2);
    221 
    222   explicit RunnableAdapter(R(*function)(A1, A2))
    223       : function_(function) {
    224   }
    225 
    226   R Run(typename CallbackParamTraits<A1>::ForwardType a1,
    227       typename CallbackParamTraits<A2>::ForwardType a2) {
    228     return function_(CallbackForward(a1), CallbackForward(a2));
    229   }
    230 
    231  private:
    232   R (*function_)(A1, A2);
    233 };
    234 
    235 // Method: Arity 2.
    236 template <typename R, typename T, typename A1, typename A2>
    237 class RunnableAdapter<R(T::*)(A1, A2)> {
    238  public:
    239   typedef R (RunType)(T*, A1, A2);
    240   typedef true_type IsMethod;
    241 
    242   explicit RunnableAdapter(R(T::*method)(A1, A2))
    243       : method_(method) {
    244   }
    245 
    246   R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
    247       typename CallbackParamTraits<A2>::ForwardType a2) {
    248     return (object->*method_)(CallbackForward(a1), CallbackForward(a2));
    249   }
    250 
    251  private:
    252   R (T::*method_)(A1, A2);
    253 };
    254 
    255 // Const Method: Arity 2.
    256 template <typename R, typename T, typename A1, typename A2>
    257 class RunnableAdapter<R(T::*)(A1, A2) const> {
    258  public:
    259   typedef R (RunType)(const T*, A1, A2);
    260   typedef true_type IsMethod;
    261 
    262   explicit RunnableAdapter(R(T::*method)(A1, A2) const)
    263       : method_(method) {
    264   }
    265 
    266   R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
    267       typename CallbackParamTraits<A2>::ForwardType a2) {
    268     return (object->*method_)(CallbackForward(a1), CallbackForward(a2));
    269   }
    270 
    271  private:
    272   R (T::*method_)(A1, A2) const;
    273 };
    274 
    275 // Function: Arity 3.
    276 template <typename R, typename A1, typename A2, typename A3>
    277 class RunnableAdapter<R(*)(A1, A2, A3)> {
    278  public:
    279   typedef R (RunType)(A1, A2, A3);
    280 
    281   explicit RunnableAdapter(R(*function)(A1, A2, A3))
    282       : function_(function) {
    283   }
    284 
    285   R Run(typename CallbackParamTraits<A1>::ForwardType a1,
    286       typename CallbackParamTraits<A2>::ForwardType a2,
    287       typename CallbackParamTraits<A3>::ForwardType a3) {
    288     return function_(CallbackForward(a1), CallbackForward(a2),
    289         CallbackForward(a3));
    290   }
    291 
    292  private:
    293   R (*function_)(A1, A2, A3);
    294 };
    295 
    296 // Method: Arity 3.
    297 template <typename R, typename T, typename A1, typename A2, typename A3>
    298 class RunnableAdapter<R(T::*)(A1, A2, A3)> {
    299  public:
    300   typedef R (RunType)(T*, A1, A2, A3);
    301   typedef true_type IsMethod;
    302 
    303   explicit RunnableAdapter(R(T::*method)(A1, A2, A3))
    304       : method_(method) {
    305   }
    306 
    307   R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
    308       typename CallbackParamTraits<A2>::ForwardType a2,
    309       typename CallbackParamTraits<A3>::ForwardType a3) {
    310     return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
    311         CallbackForward(a3));
    312   }
    313 
    314  private:
    315   R (T::*method_)(A1, A2, A3);
    316 };
    317 
    318 // Const Method: Arity 3.
    319 template <typename R, typename T, typename A1, typename A2, typename A3>
    320 class RunnableAdapter<R(T::*)(A1, A2, A3) const> {
    321  public:
    322   typedef R (RunType)(const T*, A1, A2, A3);
    323   typedef true_type IsMethod;
    324 
    325   explicit RunnableAdapter(R(T::*method)(A1, A2, A3) const)
    326       : method_(method) {
    327   }
    328 
    329   R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
    330       typename CallbackParamTraits<A2>::ForwardType a2,
    331       typename CallbackParamTraits<A3>::ForwardType a3) {
    332     return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
    333         CallbackForward(a3));
    334   }
    335 
    336  private:
    337   R (T::*method_)(A1, A2, A3) const;
    338 };
    339 
    340 // Function: Arity 4.
    341 template <typename R, typename A1, typename A2, typename A3, typename A4>
    342 class RunnableAdapter<R(*)(A1, A2, A3, A4)> {
    343  public:
    344   typedef R (RunType)(A1, A2, A3, A4);
    345 
    346   explicit RunnableAdapter(R(*function)(A1, A2, A3, A4))
    347       : function_(function) {
    348   }
    349 
    350   R Run(typename CallbackParamTraits<A1>::ForwardType a1,
    351       typename CallbackParamTraits<A2>::ForwardType a2,
    352       typename CallbackParamTraits<A3>::ForwardType a3,
    353       typename CallbackParamTraits<A4>::ForwardType a4) {
    354     return function_(CallbackForward(a1), CallbackForward(a2),
    355         CallbackForward(a3), CallbackForward(a4));
    356   }
    357 
    358  private:
    359   R (*function_)(A1, A2, A3, A4);
    360 };
    361 
    362 // Method: Arity 4.
    363 template <typename R, typename T, typename A1, typename A2, typename A3,
    364     typename A4>
    365 class RunnableAdapter<R(T::*)(A1, A2, A3, A4)> {
    366  public:
    367   typedef R (RunType)(T*, A1, A2, A3, A4);
    368   typedef true_type IsMethod;
    369 
    370   explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4))
    371       : method_(method) {
    372   }
    373 
    374   R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
    375       typename CallbackParamTraits<A2>::ForwardType a2,
    376       typename CallbackParamTraits<A3>::ForwardType a3,
    377       typename CallbackParamTraits<A4>::ForwardType a4) {
    378     return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
    379         CallbackForward(a3), CallbackForward(a4));
    380   }
    381 
    382  private:
    383   R (T::*method_)(A1, A2, A3, A4);
    384 };
    385 
    386 // Const Method: Arity 4.
    387 template <typename R, typename T, typename A1, typename A2, typename A3,
    388     typename A4>
    389 class RunnableAdapter<R(T::*)(A1, A2, A3, A4) const> {
    390  public:
    391   typedef R (RunType)(const T*, A1, A2, A3, A4);
    392   typedef true_type IsMethod;
    393 
    394   explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4) const)
    395       : method_(method) {
    396   }
    397 
    398   R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
    399       typename CallbackParamTraits<A2>::ForwardType a2,
    400       typename CallbackParamTraits<A3>::ForwardType a3,
    401       typename CallbackParamTraits<A4>::ForwardType a4) {
    402     return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
    403         CallbackForward(a3), CallbackForward(a4));
    404   }
    405 
    406  private:
    407   R (T::*method_)(A1, A2, A3, A4) const;
    408 };
    409 
    410 // Function: Arity 5.
    411 template <typename R, typename A1, typename A2, typename A3, typename A4,
    412     typename A5>
    413 class RunnableAdapter<R(*)(A1, A2, A3, A4, A5)> {
    414  public:
    415   typedef R (RunType)(A1, A2, A3, A4, A5);
    416 
    417   explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5))
    418       : function_(function) {
    419   }
    420 
    421   R Run(typename CallbackParamTraits<A1>::ForwardType a1,
    422       typename CallbackParamTraits<A2>::ForwardType a2,
    423       typename CallbackParamTraits<A3>::ForwardType a3,
    424       typename CallbackParamTraits<A4>::ForwardType a4,
    425       typename CallbackParamTraits<A5>::ForwardType a5) {
    426     return function_(CallbackForward(a1), CallbackForward(a2),
    427         CallbackForward(a3), CallbackForward(a4), CallbackForward(a5));
    428   }
    429 
    430  private:
    431   R (*function_)(A1, A2, A3, A4, A5);
    432 };
    433 
    434 // Method: Arity 5.
    435 template <typename R, typename T, typename A1, typename A2, typename A3,
    436     typename A4, typename A5>
    437 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5)> {
    438  public:
    439   typedef R (RunType)(T*, A1, A2, A3, A4, A5);
    440   typedef true_type IsMethod;
    441 
    442   explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5))
    443       : method_(method) {
    444   }
    445 
    446   R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
    447       typename CallbackParamTraits<A2>::ForwardType a2,
    448       typename CallbackParamTraits<A3>::ForwardType a3,
    449       typename CallbackParamTraits<A4>::ForwardType a4,
    450       typename CallbackParamTraits<A5>::ForwardType a5) {
    451     return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
    452         CallbackForward(a3), CallbackForward(a4), CallbackForward(a5));
    453   }
    454 
    455  private:
    456   R (T::*method_)(A1, A2, A3, A4, A5);
    457 };
    458 
    459 // Const Method: Arity 5.
    460 template <typename R, typename T, typename A1, typename A2, typename A3,
    461     typename A4, typename A5>
    462 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5) const> {
    463  public:
    464   typedef R (RunType)(const T*, A1, A2, A3, A4, A5);
    465   typedef true_type IsMethod;
    466 
    467   explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5) const)
    468       : method_(method) {
    469   }
    470 
    471   R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
    472       typename CallbackParamTraits<A2>::ForwardType a2,
    473       typename CallbackParamTraits<A3>::ForwardType a3,
    474       typename CallbackParamTraits<A4>::ForwardType a4,
    475       typename CallbackParamTraits<A5>::ForwardType a5) {
    476     return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
    477         CallbackForward(a3), CallbackForward(a4), CallbackForward(a5));
    478   }
    479 
    480  private:
    481   R (T::*method_)(A1, A2, A3, A4, A5) const;
    482 };
    483 
    484 // Function: Arity 6.
    485 template <typename R, typename A1, typename A2, typename A3, typename A4,
    486     typename A5, typename A6>
    487 class RunnableAdapter<R(*)(A1, A2, A3, A4, A5, A6)> {
    488  public:
    489   typedef R (RunType)(A1, A2, A3, A4, A5, A6);
    490 
    491   explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6))
    492       : function_(function) {
    493   }
    494 
    495   R Run(typename CallbackParamTraits<A1>::ForwardType a1,
    496       typename CallbackParamTraits<A2>::ForwardType a2,
    497       typename CallbackParamTraits<A3>::ForwardType a3,
    498       typename CallbackParamTraits<A4>::ForwardType a4,
    499       typename CallbackParamTraits<A5>::ForwardType a5,
    500       typename CallbackParamTraits<A6>::ForwardType a6) {
    501     return function_(CallbackForward(a1), CallbackForward(a2),
    502         CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
    503         CallbackForward(a6));
    504   }
    505 
    506  private:
    507   R (*function_)(A1, A2, A3, A4, A5, A6);
    508 };
    509 
    510 // Method: Arity 6.
    511 template <typename R, typename T, typename A1, typename A2, typename A3,
    512     typename A4, typename A5, typename A6>
    513 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6)> {
    514  public:
    515   typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6);
    516   typedef true_type IsMethod;
    517 
    518   explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6))
    519       : method_(method) {
    520   }
    521 
    522   R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
    523       typename CallbackParamTraits<A2>::ForwardType a2,
    524       typename CallbackParamTraits<A3>::ForwardType a3,
    525       typename CallbackParamTraits<A4>::ForwardType a4,
    526       typename CallbackParamTraits<A5>::ForwardType a5,
    527       typename CallbackParamTraits<A6>::ForwardType a6) {
    528     return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
    529         CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
    530         CallbackForward(a6));
    531   }
    532 
    533  private:
    534   R (T::*method_)(A1, A2, A3, A4, A5, A6);
    535 };
    536 
    537 // Const Method: Arity 6.
    538 template <typename R, typename T, typename A1, typename A2, typename A3,
    539     typename A4, typename A5, typename A6>
    540 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6) const> {
    541  public:
    542   typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6);
    543   typedef true_type IsMethod;
    544 
    545   explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6) const)
    546       : method_(method) {
    547   }
    548 
    549   R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
    550       typename CallbackParamTraits<A2>::ForwardType a2,
    551       typename CallbackParamTraits<A3>::ForwardType a3,
    552       typename CallbackParamTraits<A4>::ForwardType a4,
    553       typename CallbackParamTraits<A5>::ForwardType a5,
    554       typename CallbackParamTraits<A6>::ForwardType a6) {
    555     return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
    556         CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
    557         CallbackForward(a6));
    558   }
    559 
    560  private:
    561   R (T::*method_)(A1, A2, A3, A4, A5, A6) const;
    562 };
    563 
    564 // Function: Arity 7.
    565 template <typename R, typename A1, typename A2, typename A3, typename A4,
    566     typename A5, typename A6, typename A7>
    567 class RunnableAdapter<R(*)(A1, A2, A3, A4, A5, A6, A7)> {
    568  public:
    569   typedef R (RunType)(A1, A2, A3, A4, A5, A6, A7);
    570 
    571   explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6, A7))
    572       : function_(function) {
    573   }
    574 
    575   R Run(typename CallbackParamTraits<A1>::ForwardType a1,
    576       typename CallbackParamTraits<A2>::ForwardType a2,
    577       typename CallbackParamTraits<A3>::ForwardType a3,
    578       typename CallbackParamTraits<A4>::ForwardType a4,
    579       typename CallbackParamTraits<A5>::ForwardType a5,
    580       typename CallbackParamTraits<A6>::ForwardType a6,
    581       typename CallbackParamTraits<A7>::ForwardType a7) {
    582     return function_(CallbackForward(a1), CallbackForward(a2),
    583         CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
    584         CallbackForward(a6), CallbackForward(a7));
    585   }
    586 
    587  private:
    588   R (*function_)(A1, A2, A3, A4, A5, A6, A7);
    589 };
    590 
    591 // Method: Arity 7.
    592 template <typename R, typename T, typename A1, typename A2, typename A3,
    593     typename A4, typename A5, typename A6, typename A7>
    594 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6, A7)> {
    595  public:
    596   typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6, A7);
    597   typedef true_type IsMethod;
    598 
    599   explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7))
    600       : method_(method) {
    601   }
    602 
    603   R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
    604       typename CallbackParamTraits<A2>::ForwardType a2,
    605       typename CallbackParamTraits<A3>::ForwardType a3,
    606       typename CallbackParamTraits<A4>::ForwardType a4,
    607       typename CallbackParamTraits<A5>::ForwardType a5,
    608       typename CallbackParamTraits<A6>::ForwardType a6,
    609       typename CallbackParamTraits<A7>::ForwardType a7) {
    610     return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
    611         CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
    612         CallbackForward(a6), CallbackForward(a7));
    613   }
    614 
    615  private:
    616   R (T::*method_)(A1, A2, A3, A4, A5, A6, A7);
    617 };
    618 
    619 // Const Method: Arity 7.
    620 template <typename R, typename T, typename A1, typename A2, typename A3,
    621     typename A4, typename A5, typename A6, typename A7>
    622 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6, A7) const> {
    623  public:
    624   typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6, A7);
    625   typedef true_type IsMethod;
    626 
    627   explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7) const)
    628       : method_(method) {
    629   }
    630 
    631   R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
    632       typename CallbackParamTraits<A2>::ForwardType a2,
    633       typename CallbackParamTraits<A3>::ForwardType a3,
    634       typename CallbackParamTraits<A4>::ForwardType a4,
    635       typename CallbackParamTraits<A5>::ForwardType a5,
    636       typename CallbackParamTraits<A6>::ForwardType a6,
    637       typename CallbackParamTraits<A7>::ForwardType a7) {
    638     return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
    639         CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
    640         CallbackForward(a6), CallbackForward(a7));
    641   }
    642 
    643  private:
    644   R (T::*method_)(A1, A2, A3, A4, A5, A6, A7) const;
    645 };
    646 
    647 
    648 // FunctionTraits<>
    649 //
    650 // Breaks a function signature apart into typedefs for easier introspection.
    651 template <typename Sig>
    652 struct FunctionTraits;
    653 
    654 template <typename R>
    655 struct FunctionTraits<R()> {
    656   typedef R ReturnType;
    657 };
    658 
    659 template <typename R, typename A1>
    660 struct FunctionTraits<R(A1)> {
    661   typedef R ReturnType;
    662   typedef A1 A1Type;
    663 };
    664 
    665 template <typename R, typename A1, typename A2>
    666 struct FunctionTraits<R(A1, A2)> {
    667   typedef R ReturnType;
    668   typedef A1 A1Type;
    669   typedef A2 A2Type;
    670 };
    671 
    672 template <typename R, typename A1, typename A2, typename A3>
    673 struct FunctionTraits<R(A1, A2, A3)> {
    674   typedef R ReturnType;
    675   typedef A1 A1Type;
    676   typedef A2 A2Type;
    677   typedef A3 A3Type;
    678 };
    679 
    680 template <typename R, typename A1, typename A2, typename A3, typename A4>
    681 struct FunctionTraits<R(A1, A2, A3, A4)> {
    682   typedef R ReturnType;
    683   typedef A1 A1Type;
    684   typedef A2 A2Type;
    685   typedef A3 A3Type;
    686   typedef A4 A4Type;
    687 };
    688 
    689 template <typename R, typename A1, typename A2, typename A3, typename A4,
    690     typename A5>
    691 struct FunctionTraits<R(A1, A2, A3, A4, A5)> {
    692   typedef R ReturnType;
    693   typedef A1 A1Type;
    694   typedef A2 A2Type;
    695   typedef A3 A3Type;
    696   typedef A4 A4Type;
    697   typedef A5 A5Type;
    698 };
    699 
    700 template <typename R, typename A1, typename A2, typename A3, typename A4,
    701     typename A5, typename A6>
    702 struct FunctionTraits<R(A1, A2, A3, A4, A5, A6)> {
    703   typedef R ReturnType;
    704   typedef A1 A1Type;
    705   typedef A2 A2Type;
    706   typedef A3 A3Type;
    707   typedef A4 A4Type;
    708   typedef A5 A5Type;
    709   typedef A6 A6Type;
    710 };
    711 
    712 template <typename R, typename A1, typename A2, typename A3, typename A4,
    713     typename A5, typename A6, typename A7>
    714 struct FunctionTraits<R(A1, A2, A3, A4, A5, A6, A7)> {
    715   typedef R ReturnType;
    716   typedef A1 A1Type;
    717   typedef A2 A2Type;
    718   typedef A3 A3Type;
    719   typedef A4 A4Type;
    720   typedef A5 A5Type;
    721   typedef A6 A6Type;
    722   typedef A7 A7Type;
    723 };
    724 
    725 
    726 // ForceVoidReturn<>
    727 //
    728 // Set of templates that support forcing the function return type to void.
    729 template <typename Sig>
    730 struct ForceVoidReturn;
    731 
    732 template <typename R>
    733 struct ForceVoidReturn<R()> {
    734   typedef void(RunType)();
    735 };
    736 
    737 template <typename R, typename A1>
    738 struct ForceVoidReturn<R(A1)> {
    739   typedef void(RunType)(A1);
    740 };
    741 
    742 template <typename R, typename A1, typename A2>
    743 struct ForceVoidReturn<R(A1, A2)> {
    744   typedef void(RunType)(A1, A2);
    745 };
    746 
    747 template <typename R, typename A1, typename A2, typename A3>
    748 struct ForceVoidReturn<R(A1, A2, A3)> {
    749   typedef void(RunType)(A1, A2, A3);
    750 };
    751 
    752 template <typename R, typename A1, typename A2, typename A3, typename A4>
    753 struct ForceVoidReturn<R(A1, A2, A3, A4)> {
    754   typedef void(RunType)(A1, A2, A3, A4);
    755 };
    756 
    757 template <typename R, typename A1, typename A2, typename A3, typename A4,
    758     typename A5>
    759 struct ForceVoidReturn<R(A1, A2, A3, A4, A5)> {
    760   typedef void(RunType)(A1, A2, A3, A4, A5);
    761 };
    762 
    763 template <typename R, typename A1, typename A2, typename A3, typename A4,
    764     typename A5, typename A6>
    765 struct ForceVoidReturn<R(A1, A2, A3, A4, A5, A6)> {
    766   typedef void(RunType)(A1, A2, A3, A4, A5, A6);
    767 };
    768 
    769 template <typename R, typename A1, typename A2, typename A3, typename A4,
    770     typename A5, typename A6, typename A7>
    771 struct ForceVoidReturn<R(A1, A2, A3, A4, A5, A6, A7)> {
    772   typedef void(RunType)(A1, A2, A3, A4, A5, A6, A7);
    773 };
    774 
    775 
    776 // FunctorTraits<>
    777 //
    778 // See description at top of file.
    779 template <typename T>
    780 struct FunctorTraits {
    781   typedef RunnableAdapter<T> RunnableType;
    782   typedef typename RunnableType::RunType RunType;
    783 };
    784 
    785 template <typename T>
    786 struct FunctorTraits<IgnoreResultHelper<T> > {
    787   typedef typename FunctorTraits<T>::RunnableType RunnableType;
    788   typedef typename ForceVoidReturn<
    789       typename RunnableType::RunType>::RunType RunType;
    790 };
    791 
    792 template <typename T>
    793 struct FunctorTraits<Callback<T> > {
    794   typedef Callback<T> RunnableType;
    795   typedef typename Callback<T>::RunType RunType;
    796 };
    797 
    798 
    799 // MakeRunnable<>
    800 //
    801 // Converts a passed in functor to a RunnableType using type inference.
    802 
    803 template <typename T>
    804 typename FunctorTraits<T>::RunnableType MakeRunnable(const T& t) {
    805   return RunnableAdapter<T>(t);
    806 }
    807 
    808 template <typename T>
    809 typename FunctorTraits<T>::RunnableType
    810 MakeRunnable(const IgnoreResultHelper<T>& t) {
    811   return MakeRunnable(t.functor_);
    812 }
    813 
    814 template <typename T>
    815 const typename FunctorTraits<Callback<T> >::RunnableType&
    816 MakeRunnable(const Callback<T>& t) {
    817   DCHECK(!t.is_null());
    818   return t;
    819 }
    820 
    821 
    822 // InvokeHelper<>
    823 //
    824 // There are 3 logical InvokeHelper<> specializations: normal, void-return,
    825 // WeakCalls.
    826 //
    827 // The normal type just calls the underlying runnable.
    828 //
    829 // We need a InvokeHelper to handle void return types in order to support
    830 // IgnoreResult().  Normally, if the Runnable's RunType had a void return,
    831 // the template system would just accept "return functor.Run()" ignoring
    832 // the fact that a void function is being used with return. This piece of
    833 // sugar breaks though when the Runnable's RunType is not void.  Thus, we
    834 // need a partial specialization to change the syntax to drop the "return"
    835 // from the invocation call.
    836 //
    837 // WeakCalls similarly need special syntax that is applied to the first
    838 // argument to check if they should no-op themselves.
    839 template <bool IsWeakCall, typename ReturnType, typename Runnable,
    840           typename ArgsType>
    841 struct InvokeHelper;
    842 
    843 template <typename ReturnType, typename Runnable>
    844 struct InvokeHelper<false, ReturnType, Runnable,
    845     void()>  {
    846   static ReturnType MakeItSo(Runnable runnable) {
    847     return runnable.Run();
    848   }
    849 };
    850 
    851 template <typename Runnable>
    852 struct InvokeHelper<false, void, Runnable,
    853     void()>  {
    854   static void MakeItSo(Runnable runnable) {
    855     runnable.Run();
    856   }
    857 };
    858 
    859 template <typename ReturnType, typename Runnable,typename A1>
    860 struct InvokeHelper<false, ReturnType, Runnable,
    861     void(A1)>  {
    862   static ReturnType MakeItSo(Runnable runnable, A1 a1) {
    863     return runnable.Run(CallbackForward(a1));
    864   }
    865 };
    866 
    867 template <typename Runnable,typename A1>
    868 struct InvokeHelper<false, void, Runnable,
    869     void(A1)>  {
    870   static void MakeItSo(Runnable runnable, A1 a1) {
    871     runnable.Run(CallbackForward(a1));
    872   }
    873 };
    874 
    875 template <typename Runnable, typename BoundWeakPtr>
    876 struct InvokeHelper<true, void, Runnable,
    877     void(BoundWeakPtr)>  {
    878   static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr) {
    879     if (!weak_ptr.get()) {
    880       return;
    881     }
    882     runnable.Run(weak_ptr.get());
    883   }
    884 };
    885 
    886 template <typename ReturnType, typename Runnable,typename A1, typename A2>
    887 struct InvokeHelper<false, ReturnType, Runnable,
    888     void(A1, A2)>  {
    889   static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2) {
    890     return runnable.Run(CallbackForward(a1), CallbackForward(a2));
    891   }
    892 };
    893 
    894 template <typename Runnable,typename A1, typename A2>
    895 struct InvokeHelper<false, void, Runnable,
    896     void(A1, A2)>  {
    897   static void MakeItSo(Runnable runnable, A1 a1, A2 a2) {
    898     runnable.Run(CallbackForward(a1), CallbackForward(a2));
    899   }
    900 };
    901 
    902 template <typename Runnable, typename BoundWeakPtr, typename A2>
    903 struct InvokeHelper<true, void, Runnable,
    904     void(BoundWeakPtr, A2)>  {
    905   static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2) {
    906     if (!weak_ptr.get()) {
    907       return;
    908     }
    909     runnable.Run(weak_ptr.get(), CallbackForward(a2));
    910   }
    911 };
    912 
    913 template <typename ReturnType, typename Runnable,typename A1, typename A2,
    914     typename A3>
    915 struct InvokeHelper<false, ReturnType, Runnable,
    916     void(A1, A2, A3)>  {
    917   static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) {
    918     return runnable.Run(CallbackForward(a1), CallbackForward(a2),
    919         CallbackForward(a3));
    920   }
    921 };
    922 
    923 template <typename Runnable,typename A1, typename A2, typename A3>
    924 struct InvokeHelper<false, void, Runnable,
    925     void(A1, A2, A3)>  {
    926   static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) {
    927     runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3));
    928   }
    929 };
    930 
    931 template <typename Runnable, typename BoundWeakPtr, typename A2, typename A3>
    932 struct InvokeHelper<true, void, Runnable,
    933     void(BoundWeakPtr, A2, A3)>  {
    934   static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3) {
    935     if (!weak_ptr.get()) {
    936       return;
    937     }
    938     runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3));
    939   }
    940 };
    941 
    942 template <typename ReturnType, typename Runnable,typename A1, typename A2,
    943     typename A3, typename A4>
    944 struct InvokeHelper<false, ReturnType, Runnable,
    945     void(A1, A2, A3, A4)>  {
    946   static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) {
    947     return runnable.Run(CallbackForward(a1), CallbackForward(a2),
    948         CallbackForward(a3), CallbackForward(a4));
    949   }
    950 };
    951 
    952 template <typename Runnable,typename A1, typename A2, typename A3, typename A4>
    953 struct InvokeHelper<false, void, Runnable,
    954     void(A1, A2, A3, A4)>  {
    955   static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) {
    956     runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3),
    957         CallbackForward(a4));
    958   }
    959 };
    960 
    961 template <typename Runnable, typename BoundWeakPtr, typename A2, typename A3,
    962     typename A4>
    963 struct InvokeHelper<true, void, Runnable,
    964     void(BoundWeakPtr, A2, A3, A4)>  {
    965   static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3,
    966       A4 a4) {
    967     if (!weak_ptr.get()) {
    968       return;
    969     }
    970     runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3),
    971         CallbackForward(a4));
    972   }
    973 };
    974 
    975 template <typename ReturnType, typename Runnable,typename A1, typename A2,
    976     typename A3, typename A4, typename A5>
    977 struct InvokeHelper<false, ReturnType, Runnable,
    978     void(A1, A2, A3, A4, A5)>  {
    979   static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4,
    980       A5 a5) {
    981     return runnable.Run(CallbackForward(a1), CallbackForward(a2),
    982         CallbackForward(a3), CallbackForward(a4), CallbackForward(a5));
    983   }
    984 };
    985 
    986 template <typename Runnable,typename A1, typename A2, typename A3, typename A4,
    987     typename A5>
    988 struct InvokeHelper<false, void, Runnable,
    989     void(A1, A2, A3, A4, A5)>  {
    990   static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
    991     runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3),
    992         CallbackForward(a4), CallbackForward(a5));
    993   }
    994 };
    995 
    996 template <typename Runnable, typename BoundWeakPtr, typename A2, typename A3,
    997     typename A4, typename A5>
    998 struct InvokeHelper<true, void, Runnable,
    999     void(BoundWeakPtr, A2, A3, A4, A5)>  {
   1000   static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3,
   1001       A4 a4, A5 a5) {
   1002     if (!weak_ptr.get()) {
   1003       return;
   1004     }
   1005     runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3),
   1006         CallbackForward(a4), CallbackForward(a5));
   1007   }
   1008 };
   1009 
   1010 template <typename ReturnType, typename Runnable,typename A1, typename A2,
   1011     typename A3, typename A4, typename A5, typename A6>
   1012 struct InvokeHelper<false, ReturnType, Runnable,
   1013     void(A1, A2, A3, A4, A5, A6)>  {
   1014   static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4,
   1015       A5 a5, A6 a6) {
   1016     return runnable.Run(CallbackForward(a1), CallbackForward(a2),
   1017         CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
   1018         CallbackForward(a6));
   1019   }
   1020 };
   1021 
   1022 template <typename Runnable,typename A1, typename A2, typename A3, typename A4,
   1023     typename A5, typename A6>
   1024 struct InvokeHelper<false, void, Runnable,
   1025     void(A1, A2, A3, A4, A5, A6)>  {
   1026   static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5,
   1027       A6 a6) {
   1028     runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3),
   1029         CallbackForward(a4), CallbackForward(a5), CallbackForward(a6));
   1030   }
   1031 };
   1032 
   1033 template <typename Runnable, typename BoundWeakPtr, typename A2, typename A3,
   1034     typename A4, typename A5, typename A6>
   1035 struct InvokeHelper<true, void, Runnable,
   1036     void(BoundWeakPtr, A2, A3, A4, A5, A6)>  {
   1037   static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3,
   1038       A4 a4, A5 a5, A6 a6) {
   1039     if (!weak_ptr.get()) {
   1040       return;
   1041     }
   1042     runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3),
   1043         CallbackForward(a4), CallbackForward(a5), CallbackForward(a6));
   1044   }
   1045 };
   1046 
   1047 template <typename ReturnType, typename Runnable,typename A1, typename A2,
   1048     typename A3, typename A4, typename A5, typename A6, typename A7>
   1049 struct InvokeHelper<false, ReturnType, Runnable,
   1050     void(A1, A2, A3, A4, A5, A6, A7)>  {
   1051   static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4,
   1052       A5 a5, A6 a6, A7 a7) {
   1053     return runnable.Run(CallbackForward(a1), CallbackForward(a2),
   1054         CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
   1055         CallbackForward(a6), CallbackForward(a7));
   1056   }
   1057 };
   1058 
   1059 template <typename Runnable,typename A1, typename A2, typename A3, typename A4,
   1060     typename A5, typename A6, typename A7>
   1061 struct InvokeHelper<false, void, Runnable,
   1062     void(A1, A2, A3, A4, A5, A6, A7)>  {
   1063   static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5,
   1064       A6 a6, A7 a7) {
   1065     runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3),
   1066         CallbackForward(a4), CallbackForward(a5), CallbackForward(a6),
   1067         CallbackForward(a7));
   1068   }
   1069 };
   1070 
   1071 template <typename Runnable, typename BoundWeakPtr, typename A2, typename A3,
   1072     typename A4, typename A5, typename A6, typename A7>
   1073 struct InvokeHelper<true, void, Runnable,
   1074     void(BoundWeakPtr, A2, A3, A4, A5, A6, A7)>  {
   1075   static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3,
   1076       A4 a4, A5 a5, A6 a6, A7 a7) {
   1077     if (!weak_ptr.get()) {
   1078       return;
   1079     }
   1080     runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3),
   1081         CallbackForward(a4), CallbackForward(a5), CallbackForward(a6),
   1082         CallbackForward(a7));
   1083   }
   1084 };
   1085 
   1086 #if !defined(_MSC_VER)
   1087 
   1088 template <typename ReturnType, typename Runnable, typename ArgsType>
   1089 struct InvokeHelper<true, ReturnType, Runnable, ArgsType> {
   1090   // WeakCalls are only supported for functions with a void return type.
   1091   // Otherwise, the function result would be undefined if the the WeakPtr<>
   1092   // is invalidated.
   1093   COMPILE_ASSERT(is_void<ReturnType>::value,
   1094                  weak_ptrs_can_only_bind_to_methods_without_return_values);
   1095 };
   1096 
   1097 #endif
   1098 
   1099 // Invoker<>
   1100 //
   1101 // See description at the top of the file.
   1102 template <int NumBound, typename Storage, typename RunType>
   1103 struct Invoker;
   1104 
   1105 // Arity 0 -> 0.
   1106 template <typename StorageType, typename R>
   1107 struct Invoker<0, StorageType, R()> {
   1108   typedef R(RunType)(BindStateBase*);
   1109 
   1110   typedef R(UnboundRunType)();
   1111 
   1112   static R Run(BindStateBase* base) {
   1113     StorageType* storage = static_cast<StorageType*>(base);
   1114 
   1115     // Local references to make debugger stepping easier. If in a debugger,
   1116     // you really want to warp ahead and step through the
   1117     // InvokeHelper<>::MakeItSo() call below.
   1118 
   1119     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1120            typename StorageType::RunnableType,
   1121            void()>
   1122                ::MakeItSo(storage->runnable_);
   1123   }
   1124 };
   1125 
   1126 // Arity 1 -> 1.
   1127 template <typename StorageType, typename R,typename X1>
   1128 struct Invoker<0, StorageType, R(X1)> {
   1129   typedef R(RunType)(BindStateBase*,
   1130       typename CallbackParamTraits<X1>::ForwardType);
   1131 
   1132   typedef R(UnboundRunType)(X1);
   1133 
   1134   static R Run(BindStateBase* base,
   1135       typename CallbackParamTraits<X1>::ForwardType x1) {
   1136     StorageType* storage = static_cast<StorageType*>(base);
   1137 
   1138     // Local references to make debugger stepping easier. If in a debugger,
   1139     // you really want to warp ahead and step through the
   1140     // InvokeHelper<>::MakeItSo() call below.
   1141 
   1142     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1143            typename StorageType::RunnableType,
   1144            void(typename CallbackParamTraits<X1>::ForwardType x1)>
   1145                ::MakeItSo(storage->runnable_, CallbackForward(x1));
   1146   }
   1147 };
   1148 
   1149 // Arity 1 -> 0.
   1150 template <typename StorageType, typename R,typename X1>
   1151 struct Invoker<1, StorageType, R(X1)> {
   1152   typedef R(RunType)(BindStateBase*);
   1153 
   1154   typedef R(UnboundRunType)();
   1155 
   1156   static R Run(BindStateBase* base) {
   1157     StorageType* storage = static_cast<StorageType*>(base);
   1158 
   1159     // Local references to make debugger stepping easier. If in a debugger,
   1160     // you really want to warp ahead and step through the
   1161     // InvokeHelper<>::MakeItSo() call below.
   1162     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1163 
   1164     typename Bound1UnwrapTraits::ForwardType x1 =
   1165         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1166     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1167            typename StorageType::RunnableType,
   1168            void(typename Bound1UnwrapTraits::ForwardType)>
   1169                ::MakeItSo(storage->runnable_, CallbackForward(x1));
   1170   }
   1171 };
   1172 
   1173 // Arity 2 -> 2.
   1174 template <typename StorageType, typename R,typename X1, typename X2>
   1175 struct Invoker<0, StorageType, R(X1, X2)> {
   1176   typedef R(RunType)(BindStateBase*,
   1177       typename CallbackParamTraits<X1>::ForwardType,
   1178       typename CallbackParamTraits<X2>::ForwardType);
   1179 
   1180   typedef R(UnboundRunType)(X1, X2);
   1181 
   1182   static R Run(BindStateBase* base,
   1183       typename CallbackParamTraits<X1>::ForwardType x1,
   1184       typename CallbackParamTraits<X2>::ForwardType x2) {
   1185     StorageType* storage = static_cast<StorageType*>(base);
   1186 
   1187     // Local references to make debugger stepping easier. If in a debugger,
   1188     // you really want to warp ahead and step through the
   1189     // InvokeHelper<>::MakeItSo() call below.
   1190 
   1191     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1192            typename StorageType::RunnableType,
   1193            void(typename CallbackParamTraits<X1>::ForwardType x1,
   1194                typename CallbackParamTraits<X2>::ForwardType x2)>
   1195                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1196                    CallbackForward(x2));
   1197   }
   1198 };
   1199 
   1200 // Arity 2 -> 1.
   1201 template <typename StorageType, typename R,typename X1, typename X2>
   1202 struct Invoker<1, StorageType, R(X1, X2)> {
   1203   typedef R(RunType)(BindStateBase*,
   1204       typename CallbackParamTraits<X2>::ForwardType);
   1205 
   1206   typedef R(UnboundRunType)(X2);
   1207 
   1208   static R Run(BindStateBase* base,
   1209       typename CallbackParamTraits<X2>::ForwardType x2) {
   1210     StorageType* storage = static_cast<StorageType*>(base);
   1211 
   1212     // Local references to make debugger stepping easier. If in a debugger,
   1213     // you really want to warp ahead and step through the
   1214     // InvokeHelper<>::MakeItSo() call below.
   1215     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1216 
   1217     typename Bound1UnwrapTraits::ForwardType x1 =
   1218         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1219     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1220            typename StorageType::RunnableType,
   1221            void(typename Bound1UnwrapTraits::ForwardType,
   1222                typename CallbackParamTraits<X2>::ForwardType x2)>
   1223                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1224                    CallbackForward(x2));
   1225   }
   1226 };
   1227 
   1228 // Arity 2 -> 0.
   1229 template <typename StorageType, typename R,typename X1, typename X2>
   1230 struct Invoker<2, StorageType, R(X1, X2)> {
   1231   typedef R(RunType)(BindStateBase*);
   1232 
   1233   typedef R(UnboundRunType)();
   1234 
   1235   static R Run(BindStateBase* base) {
   1236     StorageType* storage = static_cast<StorageType*>(base);
   1237 
   1238     // Local references to make debugger stepping easier. If in a debugger,
   1239     // you really want to warp ahead and step through the
   1240     // InvokeHelper<>::MakeItSo() call below.
   1241     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1242     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   1243 
   1244     typename Bound1UnwrapTraits::ForwardType x1 =
   1245         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1246     typename Bound2UnwrapTraits::ForwardType x2 =
   1247         Bound2UnwrapTraits::Unwrap(storage->p2_);
   1248     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1249            typename StorageType::RunnableType,
   1250            void(typename Bound1UnwrapTraits::ForwardType,
   1251                typename Bound2UnwrapTraits::ForwardType)>
   1252                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1253                    CallbackForward(x2));
   1254   }
   1255 };
   1256 
   1257 // Arity 3 -> 3.
   1258 template <typename StorageType, typename R,typename X1, typename X2,
   1259     typename X3>
   1260 struct Invoker<0, StorageType, R(X1, X2, X3)> {
   1261   typedef R(RunType)(BindStateBase*,
   1262       typename CallbackParamTraits<X1>::ForwardType,
   1263       typename CallbackParamTraits<X2>::ForwardType,
   1264       typename CallbackParamTraits<X3>::ForwardType);
   1265 
   1266   typedef R(UnboundRunType)(X1, X2, X3);
   1267 
   1268   static R Run(BindStateBase* base,
   1269       typename CallbackParamTraits<X1>::ForwardType x1,
   1270       typename CallbackParamTraits<X2>::ForwardType x2,
   1271       typename CallbackParamTraits<X3>::ForwardType x3) {
   1272     StorageType* storage = static_cast<StorageType*>(base);
   1273 
   1274     // Local references to make debugger stepping easier. If in a debugger,
   1275     // you really want to warp ahead and step through the
   1276     // InvokeHelper<>::MakeItSo() call below.
   1277 
   1278     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1279            typename StorageType::RunnableType,
   1280            void(typename CallbackParamTraits<X1>::ForwardType x1,
   1281                typename CallbackParamTraits<X2>::ForwardType x2,
   1282                typename CallbackParamTraits<X3>::ForwardType x3)>
   1283                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1284                    CallbackForward(x2), CallbackForward(x3));
   1285   }
   1286 };
   1287 
   1288 // Arity 3 -> 2.
   1289 template <typename StorageType, typename R,typename X1, typename X2,
   1290     typename X3>
   1291 struct Invoker<1, StorageType, R(X1, X2, X3)> {
   1292   typedef R(RunType)(BindStateBase*,
   1293       typename CallbackParamTraits<X2>::ForwardType,
   1294       typename CallbackParamTraits<X3>::ForwardType);
   1295 
   1296   typedef R(UnboundRunType)(X2, X3);
   1297 
   1298   static R Run(BindStateBase* base,
   1299       typename CallbackParamTraits<X2>::ForwardType x2,
   1300       typename CallbackParamTraits<X3>::ForwardType x3) {
   1301     StorageType* storage = static_cast<StorageType*>(base);
   1302 
   1303     // Local references to make debugger stepping easier. If in a debugger,
   1304     // you really want to warp ahead and step through the
   1305     // InvokeHelper<>::MakeItSo() call below.
   1306     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1307 
   1308     typename Bound1UnwrapTraits::ForwardType x1 =
   1309         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1310     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1311            typename StorageType::RunnableType,
   1312            void(typename Bound1UnwrapTraits::ForwardType,
   1313                typename CallbackParamTraits<X2>::ForwardType x2,
   1314                typename CallbackParamTraits<X3>::ForwardType x3)>
   1315                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1316                    CallbackForward(x2), CallbackForward(x3));
   1317   }
   1318 };
   1319 
   1320 // Arity 3 -> 1.
   1321 template <typename StorageType, typename R,typename X1, typename X2,
   1322     typename X3>
   1323 struct Invoker<2, StorageType, R(X1, X2, X3)> {
   1324   typedef R(RunType)(BindStateBase*,
   1325       typename CallbackParamTraits<X3>::ForwardType);
   1326 
   1327   typedef R(UnboundRunType)(X3);
   1328 
   1329   static R Run(BindStateBase* base,
   1330       typename CallbackParamTraits<X3>::ForwardType x3) {
   1331     StorageType* storage = static_cast<StorageType*>(base);
   1332 
   1333     // Local references to make debugger stepping easier. If in a debugger,
   1334     // you really want to warp ahead and step through the
   1335     // InvokeHelper<>::MakeItSo() call below.
   1336     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1337     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   1338 
   1339     typename Bound1UnwrapTraits::ForwardType x1 =
   1340         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1341     typename Bound2UnwrapTraits::ForwardType x2 =
   1342         Bound2UnwrapTraits::Unwrap(storage->p2_);
   1343     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1344            typename StorageType::RunnableType,
   1345            void(typename Bound1UnwrapTraits::ForwardType,
   1346                typename Bound2UnwrapTraits::ForwardType,
   1347                typename CallbackParamTraits<X3>::ForwardType x3)>
   1348                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1349                    CallbackForward(x2), CallbackForward(x3));
   1350   }
   1351 };
   1352 
   1353 // Arity 3 -> 0.
   1354 template <typename StorageType, typename R,typename X1, typename X2,
   1355     typename X3>
   1356 struct Invoker<3, StorageType, R(X1, X2, X3)> {
   1357   typedef R(RunType)(BindStateBase*);
   1358 
   1359   typedef R(UnboundRunType)();
   1360 
   1361   static R Run(BindStateBase* base) {
   1362     StorageType* storage = static_cast<StorageType*>(base);
   1363 
   1364     // Local references to make debugger stepping easier. If in a debugger,
   1365     // you really want to warp ahead and step through the
   1366     // InvokeHelper<>::MakeItSo() call below.
   1367     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1368     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   1369     typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
   1370 
   1371     typename Bound1UnwrapTraits::ForwardType x1 =
   1372         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1373     typename Bound2UnwrapTraits::ForwardType x2 =
   1374         Bound2UnwrapTraits::Unwrap(storage->p2_);
   1375     typename Bound3UnwrapTraits::ForwardType x3 =
   1376         Bound3UnwrapTraits::Unwrap(storage->p3_);
   1377     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1378            typename StorageType::RunnableType,
   1379            void(typename Bound1UnwrapTraits::ForwardType,
   1380                typename Bound2UnwrapTraits::ForwardType,
   1381                typename Bound3UnwrapTraits::ForwardType)>
   1382                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1383                    CallbackForward(x2), CallbackForward(x3));
   1384   }
   1385 };
   1386 
   1387 // Arity 4 -> 4.
   1388 template <typename StorageType, typename R,typename X1, typename X2,
   1389     typename X3, typename X4>
   1390 struct Invoker<0, StorageType, R(X1, X2, X3, X4)> {
   1391   typedef R(RunType)(BindStateBase*,
   1392       typename CallbackParamTraits<X1>::ForwardType,
   1393       typename CallbackParamTraits<X2>::ForwardType,
   1394       typename CallbackParamTraits<X3>::ForwardType,
   1395       typename CallbackParamTraits<X4>::ForwardType);
   1396 
   1397   typedef R(UnboundRunType)(X1, X2, X3, X4);
   1398 
   1399   static R Run(BindStateBase* base,
   1400       typename CallbackParamTraits<X1>::ForwardType x1,
   1401       typename CallbackParamTraits<X2>::ForwardType x2,
   1402       typename CallbackParamTraits<X3>::ForwardType x3,
   1403       typename CallbackParamTraits<X4>::ForwardType x4) {
   1404     StorageType* storage = static_cast<StorageType*>(base);
   1405 
   1406     // Local references to make debugger stepping easier. If in a debugger,
   1407     // you really want to warp ahead and step through the
   1408     // InvokeHelper<>::MakeItSo() call below.
   1409 
   1410     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1411            typename StorageType::RunnableType,
   1412            void(typename CallbackParamTraits<X1>::ForwardType x1,
   1413                typename CallbackParamTraits<X2>::ForwardType x2,
   1414                typename CallbackParamTraits<X3>::ForwardType x3,
   1415                typename CallbackParamTraits<X4>::ForwardType x4)>
   1416                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1417                    CallbackForward(x2), CallbackForward(x3),
   1418                    CallbackForward(x4));
   1419   }
   1420 };
   1421 
   1422 // Arity 4 -> 3.
   1423 template <typename StorageType, typename R,typename X1, typename X2,
   1424     typename X3, typename X4>
   1425 struct Invoker<1, StorageType, R(X1, X2, X3, X4)> {
   1426   typedef R(RunType)(BindStateBase*,
   1427       typename CallbackParamTraits<X2>::ForwardType,
   1428       typename CallbackParamTraits<X3>::ForwardType,
   1429       typename CallbackParamTraits<X4>::ForwardType);
   1430 
   1431   typedef R(UnboundRunType)(X2, X3, X4);
   1432 
   1433   static R Run(BindStateBase* base,
   1434       typename CallbackParamTraits<X2>::ForwardType x2,
   1435       typename CallbackParamTraits<X3>::ForwardType x3,
   1436       typename CallbackParamTraits<X4>::ForwardType x4) {
   1437     StorageType* storage = static_cast<StorageType*>(base);
   1438 
   1439     // Local references to make debugger stepping easier. If in a debugger,
   1440     // you really want to warp ahead and step through the
   1441     // InvokeHelper<>::MakeItSo() call below.
   1442     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1443 
   1444     typename Bound1UnwrapTraits::ForwardType x1 =
   1445         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1446     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1447            typename StorageType::RunnableType,
   1448            void(typename Bound1UnwrapTraits::ForwardType,
   1449                typename CallbackParamTraits<X2>::ForwardType x2,
   1450                typename CallbackParamTraits<X3>::ForwardType x3,
   1451                typename CallbackParamTraits<X4>::ForwardType x4)>
   1452                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1453                    CallbackForward(x2), CallbackForward(x3),
   1454                    CallbackForward(x4));
   1455   }
   1456 };
   1457 
   1458 // Arity 4 -> 2.
   1459 template <typename StorageType, typename R,typename X1, typename X2,
   1460     typename X3, typename X4>
   1461 struct Invoker<2, StorageType, R(X1, X2, X3, X4)> {
   1462   typedef R(RunType)(BindStateBase*,
   1463       typename CallbackParamTraits<X3>::ForwardType,
   1464       typename CallbackParamTraits<X4>::ForwardType);
   1465 
   1466   typedef R(UnboundRunType)(X3, X4);
   1467 
   1468   static R Run(BindStateBase* base,
   1469       typename CallbackParamTraits<X3>::ForwardType x3,
   1470       typename CallbackParamTraits<X4>::ForwardType x4) {
   1471     StorageType* storage = static_cast<StorageType*>(base);
   1472 
   1473     // Local references to make debugger stepping easier. If in a debugger,
   1474     // you really want to warp ahead and step through the
   1475     // InvokeHelper<>::MakeItSo() call below.
   1476     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1477     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   1478 
   1479     typename Bound1UnwrapTraits::ForwardType x1 =
   1480         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1481     typename Bound2UnwrapTraits::ForwardType x2 =
   1482         Bound2UnwrapTraits::Unwrap(storage->p2_);
   1483     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1484            typename StorageType::RunnableType,
   1485            void(typename Bound1UnwrapTraits::ForwardType,
   1486                typename Bound2UnwrapTraits::ForwardType,
   1487                typename CallbackParamTraits<X3>::ForwardType x3,
   1488                typename CallbackParamTraits<X4>::ForwardType x4)>
   1489                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1490                    CallbackForward(x2), CallbackForward(x3),
   1491                    CallbackForward(x4));
   1492   }
   1493 };
   1494 
   1495 // Arity 4 -> 1.
   1496 template <typename StorageType, typename R,typename X1, typename X2,
   1497     typename X3, typename X4>
   1498 struct Invoker<3, StorageType, R(X1, X2, X3, X4)> {
   1499   typedef R(RunType)(BindStateBase*,
   1500       typename CallbackParamTraits<X4>::ForwardType);
   1501 
   1502   typedef R(UnboundRunType)(X4);
   1503 
   1504   static R Run(BindStateBase* base,
   1505       typename CallbackParamTraits<X4>::ForwardType x4) {
   1506     StorageType* storage = static_cast<StorageType*>(base);
   1507 
   1508     // Local references to make debugger stepping easier. If in a debugger,
   1509     // you really want to warp ahead and step through the
   1510     // InvokeHelper<>::MakeItSo() call below.
   1511     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1512     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   1513     typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
   1514 
   1515     typename Bound1UnwrapTraits::ForwardType x1 =
   1516         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1517     typename Bound2UnwrapTraits::ForwardType x2 =
   1518         Bound2UnwrapTraits::Unwrap(storage->p2_);
   1519     typename Bound3UnwrapTraits::ForwardType x3 =
   1520         Bound3UnwrapTraits::Unwrap(storage->p3_);
   1521     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1522            typename StorageType::RunnableType,
   1523            void(typename Bound1UnwrapTraits::ForwardType,
   1524                typename Bound2UnwrapTraits::ForwardType,
   1525                typename Bound3UnwrapTraits::ForwardType,
   1526                typename CallbackParamTraits<X4>::ForwardType x4)>
   1527                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1528                    CallbackForward(x2), CallbackForward(x3),
   1529                    CallbackForward(x4));
   1530   }
   1531 };
   1532 
   1533 // Arity 4 -> 0.
   1534 template <typename StorageType, typename R,typename X1, typename X2,
   1535     typename X3, typename X4>
   1536 struct Invoker<4, StorageType, R(X1, X2, X3, X4)> {
   1537   typedef R(RunType)(BindStateBase*);
   1538 
   1539   typedef R(UnboundRunType)();
   1540 
   1541   static R Run(BindStateBase* base) {
   1542     StorageType* storage = static_cast<StorageType*>(base);
   1543 
   1544     // Local references to make debugger stepping easier. If in a debugger,
   1545     // you really want to warp ahead and step through the
   1546     // InvokeHelper<>::MakeItSo() call below.
   1547     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1548     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   1549     typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
   1550     typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
   1551 
   1552     typename Bound1UnwrapTraits::ForwardType x1 =
   1553         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1554     typename Bound2UnwrapTraits::ForwardType x2 =
   1555         Bound2UnwrapTraits::Unwrap(storage->p2_);
   1556     typename Bound3UnwrapTraits::ForwardType x3 =
   1557         Bound3UnwrapTraits::Unwrap(storage->p3_);
   1558     typename Bound4UnwrapTraits::ForwardType x4 =
   1559         Bound4UnwrapTraits::Unwrap(storage->p4_);
   1560     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1561            typename StorageType::RunnableType,
   1562            void(typename Bound1UnwrapTraits::ForwardType,
   1563                typename Bound2UnwrapTraits::ForwardType,
   1564                typename Bound3UnwrapTraits::ForwardType,
   1565                typename Bound4UnwrapTraits::ForwardType)>
   1566                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1567                    CallbackForward(x2), CallbackForward(x3),
   1568                    CallbackForward(x4));
   1569   }
   1570 };
   1571 
   1572 // Arity 5 -> 5.
   1573 template <typename StorageType, typename R,typename X1, typename X2,
   1574     typename X3, typename X4, typename X5>
   1575 struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5)> {
   1576   typedef R(RunType)(BindStateBase*,
   1577       typename CallbackParamTraits<X1>::ForwardType,
   1578       typename CallbackParamTraits<X2>::ForwardType,
   1579       typename CallbackParamTraits<X3>::ForwardType,
   1580       typename CallbackParamTraits<X4>::ForwardType,
   1581       typename CallbackParamTraits<X5>::ForwardType);
   1582 
   1583   typedef R(UnboundRunType)(X1, X2, X3, X4, X5);
   1584 
   1585   static R Run(BindStateBase* base,
   1586       typename CallbackParamTraits<X1>::ForwardType x1,
   1587       typename CallbackParamTraits<X2>::ForwardType x2,
   1588       typename CallbackParamTraits<X3>::ForwardType x3,
   1589       typename CallbackParamTraits<X4>::ForwardType x4,
   1590       typename CallbackParamTraits<X5>::ForwardType x5) {
   1591     StorageType* storage = static_cast<StorageType*>(base);
   1592 
   1593     // Local references to make debugger stepping easier. If in a debugger,
   1594     // you really want to warp ahead and step through the
   1595     // InvokeHelper<>::MakeItSo() call below.
   1596 
   1597     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1598            typename StorageType::RunnableType,
   1599            void(typename CallbackParamTraits<X1>::ForwardType x1,
   1600                typename CallbackParamTraits<X2>::ForwardType x2,
   1601                typename CallbackParamTraits<X3>::ForwardType x3,
   1602                typename CallbackParamTraits<X4>::ForwardType x4,
   1603                typename CallbackParamTraits<X5>::ForwardType x5)>
   1604                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1605                    CallbackForward(x2), CallbackForward(x3),
   1606                    CallbackForward(x4), CallbackForward(x5));
   1607   }
   1608 };
   1609 
   1610 // Arity 5 -> 4.
   1611 template <typename StorageType, typename R,typename X1, typename X2,
   1612     typename X3, typename X4, typename X5>
   1613 struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5)> {
   1614   typedef R(RunType)(BindStateBase*,
   1615       typename CallbackParamTraits<X2>::ForwardType,
   1616       typename CallbackParamTraits<X3>::ForwardType,
   1617       typename CallbackParamTraits<X4>::ForwardType,
   1618       typename CallbackParamTraits<X5>::ForwardType);
   1619 
   1620   typedef R(UnboundRunType)(X2, X3, X4, X5);
   1621 
   1622   static R Run(BindStateBase* base,
   1623       typename CallbackParamTraits<X2>::ForwardType x2,
   1624       typename CallbackParamTraits<X3>::ForwardType x3,
   1625       typename CallbackParamTraits<X4>::ForwardType x4,
   1626       typename CallbackParamTraits<X5>::ForwardType x5) {
   1627     StorageType* storage = static_cast<StorageType*>(base);
   1628 
   1629     // Local references to make debugger stepping easier. If in a debugger,
   1630     // you really want to warp ahead and step through the
   1631     // InvokeHelper<>::MakeItSo() call below.
   1632     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1633 
   1634     typename Bound1UnwrapTraits::ForwardType x1 =
   1635         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1636     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1637            typename StorageType::RunnableType,
   1638            void(typename Bound1UnwrapTraits::ForwardType,
   1639                typename CallbackParamTraits<X2>::ForwardType x2,
   1640                typename CallbackParamTraits<X3>::ForwardType x3,
   1641                typename CallbackParamTraits<X4>::ForwardType x4,
   1642                typename CallbackParamTraits<X5>::ForwardType x5)>
   1643                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1644                    CallbackForward(x2), CallbackForward(x3),
   1645                    CallbackForward(x4), CallbackForward(x5));
   1646   }
   1647 };
   1648 
   1649 // Arity 5 -> 3.
   1650 template <typename StorageType, typename R,typename X1, typename X2,
   1651     typename X3, typename X4, typename X5>
   1652 struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5)> {
   1653   typedef R(RunType)(BindStateBase*,
   1654       typename CallbackParamTraits<X3>::ForwardType,
   1655       typename CallbackParamTraits<X4>::ForwardType,
   1656       typename CallbackParamTraits<X5>::ForwardType);
   1657 
   1658   typedef R(UnboundRunType)(X3, X4, X5);
   1659 
   1660   static R Run(BindStateBase* base,
   1661       typename CallbackParamTraits<X3>::ForwardType x3,
   1662       typename CallbackParamTraits<X4>::ForwardType x4,
   1663       typename CallbackParamTraits<X5>::ForwardType x5) {
   1664     StorageType* storage = static_cast<StorageType*>(base);
   1665 
   1666     // Local references to make debugger stepping easier. If in a debugger,
   1667     // you really want to warp ahead and step through the
   1668     // InvokeHelper<>::MakeItSo() call below.
   1669     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1670     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   1671 
   1672     typename Bound1UnwrapTraits::ForwardType x1 =
   1673         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1674     typename Bound2UnwrapTraits::ForwardType x2 =
   1675         Bound2UnwrapTraits::Unwrap(storage->p2_);
   1676     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1677            typename StorageType::RunnableType,
   1678            void(typename Bound1UnwrapTraits::ForwardType,
   1679                typename Bound2UnwrapTraits::ForwardType,
   1680                typename CallbackParamTraits<X3>::ForwardType x3,
   1681                typename CallbackParamTraits<X4>::ForwardType x4,
   1682                typename CallbackParamTraits<X5>::ForwardType x5)>
   1683                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1684                    CallbackForward(x2), CallbackForward(x3),
   1685                    CallbackForward(x4), CallbackForward(x5));
   1686   }
   1687 };
   1688 
   1689 // Arity 5 -> 2.
   1690 template <typename StorageType, typename R,typename X1, typename X2,
   1691     typename X3, typename X4, typename X5>
   1692 struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5)> {
   1693   typedef R(RunType)(BindStateBase*,
   1694       typename CallbackParamTraits<X4>::ForwardType,
   1695       typename CallbackParamTraits<X5>::ForwardType);
   1696 
   1697   typedef R(UnboundRunType)(X4, X5);
   1698 
   1699   static R Run(BindStateBase* base,
   1700       typename CallbackParamTraits<X4>::ForwardType x4,
   1701       typename CallbackParamTraits<X5>::ForwardType x5) {
   1702     StorageType* storage = static_cast<StorageType*>(base);
   1703 
   1704     // Local references to make debugger stepping easier. If in a debugger,
   1705     // you really want to warp ahead and step through the
   1706     // InvokeHelper<>::MakeItSo() call below.
   1707     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1708     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   1709     typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
   1710 
   1711     typename Bound1UnwrapTraits::ForwardType x1 =
   1712         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1713     typename Bound2UnwrapTraits::ForwardType x2 =
   1714         Bound2UnwrapTraits::Unwrap(storage->p2_);
   1715     typename Bound3UnwrapTraits::ForwardType x3 =
   1716         Bound3UnwrapTraits::Unwrap(storage->p3_);
   1717     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1718            typename StorageType::RunnableType,
   1719            void(typename Bound1UnwrapTraits::ForwardType,
   1720                typename Bound2UnwrapTraits::ForwardType,
   1721                typename Bound3UnwrapTraits::ForwardType,
   1722                typename CallbackParamTraits<X4>::ForwardType x4,
   1723                typename CallbackParamTraits<X5>::ForwardType x5)>
   1724                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1725                    CallbackForward(x2), CallbackForward(x3),
   1726                    CallbackForward(x4), CallbackForward(x5));
   1727   }
   1728 };
   1729 
   1730 // Arity 5 -> 1.
   1731 template <typename StorageType, typename R,typename X1, typename X2,
   1732     typename X3, typename X4, typename X5>
   1733 struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5)> {
   1734   typedef R(RunType)(BindStateBase*,
   1735       typename CallbackParamTraits<X5>::ForwardType);
   1736 
   1737   typedef R(UnboundRunType)(X5);
   1738 
   1739   static R Run(BindStateBase* base,
   1740       typename CallbackParamTraits<X5>::ForwardType x5) {
   1741     StorageType* storage = static_cast<StorageType*>(base);
   1742 
   1743     // Local references to make debugger stepping easier. If in a debugger,
   1744     // you really want to warp ahead and step through the
   1745     // InvokeHelper<>::MakeItSo() call below.
   1746     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1747     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   1748     typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
   1749     typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
   1750 
   1751     typename Bound1UnwrapTraits::ForwardType x1 =
   1752         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1753     typename Bound2UnwrapTraits::ForwardType x2 =
   1754         Bound2UnwrapTraits::Unwrap(storage->p2_);
   1755     typename Bound3UnwrapTraits::ForwardType x3 =
   1756         Bound3UnwrapTraits::Unwrap(storage->p3_);
   1757     typename Bound4UnwrapTraits::ForwardType x4 =
   1758         Bound4UnwrapTraits::Unwrap(storage->p4_);
   1759     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1760            typename StorageType::RunnableType,
   1761            void(typename Bound1UnwrapTraits::ForwardType,
   1762                typename Bound2UnwrapTraits::ForwardType,
   1763                typename Bound3UnwrapTraits::ForwardType,
   1764                typename Bound4UnwrapTraits::ForwardType,
   1765                typename CallbackParamTraits<X5>::ForwardType x5)>
   1766                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1767                    CallbackForward(x2), CallbackForward(x3),
   1768                    CallbackForward(x4), CallbackForward(x5));
   1769   }
   1770 };
   1771 
   1772 // Arity 5 -> 0.
   1773 template <typename StorageType, typename R,typename X1, typename X2,
   1774     typename X3, typename X4, typename X5>
   1775 struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5)> {
   1776   typedef R(RunType)(BindStateBase*);
   1777 
   1778   typedef R(UnboundRunType)();
   1779 
   1780   static R Run(BindStateBase* base) {
   1781     StorageType* storage = static_cast<StorageType*>(base);
   1782 
   1783     // Local references to make debugger stepping easier. If in a debugger,
   1784     // you really want to warp ahead and step through the
   1785     // InvokeHelper<>::MakeItSo() call below.
   1786     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1787     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   1788     typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
   1789     typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
   1790     typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
   1791 
   1792     typename Bound1UnwrapTraits::ForwardType x1 =
   1793         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1794     typename Bound2UnwrapTraits::ForwardType x2 =
   1795         Bound2UnwrapTraits::Unwrap(storage->p2_);
   1796     typename Bound3UnwrapTraits::ForwardType x3 =
   1797         Bound3UnwrapTraits::Unwrap(storage->p3_);
   1798     typename Bound4UnwrapTraits::ForwardType x4 =
   1799         Bound4UnwrapTraits::Unwrap(storage->p4_);
   1800     typename Bound5UnwrapTraits::ForwardType x5 =
   1801         Bound5UnwrapTraits::Unwrap(storage->p5_);
   1802     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1803            typename StorageType::RunnableType,
   1804            void(typename Bound1UnwrapTraits::ForwardType,
   1805                typename Bound2UnwrapTraits::ForwardType,
   1806                typename Bound3UnwrapTraits::ForwardType,
   1807                typename Bound4UnwrapTraits::ForwardType,
   1808                typename Bound5UnwrapTraits::ForwardType)>
   1809                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1810                    CallbackForward(x2), CallbackForward(x3),
   1811                    CallbackForward(x4), CallbackForward(x5));
   1812   }
   1813 };
   1814 
   1815 // Arity 6 -> 6.
   1816 template <typename StorageType, typename R,typename X1, typename X2,
   1817     typename X3, typename X4, typename X5, typename X6>
   1818 struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6)> {
   1819   typedef R(RunType)(BindStateBase*,
   1820       typename CallbackParamTraits<X1>::ForwardType,
   1821       typename CallbackParamTraits<X2>::ForwardType,
   1822       typename CallbackParamTraits<X3>::ForwardType,
   1823       typename CallbackParamTraits<X4>::ForwardType,
   1824       typename CallbackParamTraits<X5>::ForwardType,
   1825       typename CallbackParamTraits<X6>::ForwardType);
   1826 
   1827   typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6);
   1828 
   1829   static R Run(BindStateBase* base,
   1830       typename CallbackParamTraits<X1>::ForwardType x1,
   1831       typename CallbackParamTraits<X2>::ForwardType x2,
   1832       typename CallbackParamTraits<X3>::ForwardType x3,
   1833       typename CallbackParamTraits<X4>::ForwardType x4,
   1834       typename CallbackParamTraits<X5>::ForwardType x5,
   1835       typename CallbackParamTraits<X6>::ForwardType x6) {
   1836     StorageType* storage = static_cast<StorageType*>(base);
   1837 
   1838     // Local references to make debugger stepping easier. If in a debugger,
   1839     // you really want to warp ahead and step through the
   1840     // InvokeHelper<>::MakeItSo() call below.
   1841 
   1842     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1843            typename StorageType::RunnableType,
   1844            void(typename CallbackParamTraits<X1>::ForwardType x1,
   1845                typename CallbackParamTraits<X2>::ForwardType x2,
   1846                typename CallbackParamTraits<X3>::ForwardType x3,
   1847                typename CallbackParamTraits<X4>::ForwardType x4,
   1848                typename CallbackParamTraits<X5>::ForwardType x5,
   1849                typename CallbackParamTraits<X6>::ForwardType x6)>
   1850                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1851                    CallbackForward(x2), CallbackForward(x3),
   1852                    CallbackForward(x4), CallbackForward(x5),
   1853                    CallbackForward(x6));
   1854   }
   1855 };
   1856 
   1857 // Arity 6 -> 5.
   1858 template <typename StorageType, typename R,typename X1, typename X2,
   1859     typename X3, typename X4, typename X5, typename X6>
   1860 struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6)> {
   1861   typedef R(RunType)(BindStateBase*,
   1862       typename CallbackParamTraits<X2>::ForwardType,
   1863       typename CallbackParamTraits<X3>::ForwardType,
   1864       typename CallbackParamTraits<X4>::ForwardType,
   1865       typename CallbackParamTraits<X5>::ForwardType,
   1866       typename CallbackParamTraits<X6>::ForwardType);
   1867 
   1868   typedef R(UnboundRunType)(X2, X3, X4, X5, X6);
   1869 
   1870   static R Run(BindStateBase* base,
   1871       typename CallbackParamTraits<X2>::ForwardType x2,
   1872       typename CallbackParamTraits<X3>::ForwardType x3,
   1873       typename CallbackParamTraits<X4>::ForwardType x4,
   1874       typename CallbackParamTraits<X5>::ForwardType x5,
   1875       typename CallbackParamTraits<X6>::ForwardType x6) {
   1876     StorageType* storage = static_cast<StorageType*>(base);
   1877 
   1878     // Local references to make debugger stepping easier. If in a debugger,
   1879     // you really want to warp ahead and step through the
   1880     // InvokeHelper<>::MakeItSo() call below.
   1881     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1882 
   1883     typename Bound1UnwrapTraits::ForwardType x1 =
   1884         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1885     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1886            typename StorageType::RunnableType,
   1887            void(typename Bound1UnwrapTraits::ForwardType,
   1888                typename CallbackParamTraits<X2>::ForwardType x2,
   1889                typename CallbackParamTraits<X3>::ForwardType x3,
   1890                typename CallbackParamTraits<X4>::ForwardType x4,
   1891                typename CallbackParamTraits<X5>::ForwardType x5,
   1892                typename CallbackParamTraits<X6>::ForwardType x6)>
   1893                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1894                    CallbackForward(x2), CallbackForward(x3),
   1895                    CallbackForward(x4), CallbackForward(x5),
   1896                    CallbackForward(x6));
   1897   }
   1898 };
   1899 
   1900 // Arity 6 -> 4.
   1901 template <typename StorageType, typename R,typename X1, typename X2,
   1902     typename X3, typename X4, typename X5, typename X6>
   1903 struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6)> {
   1904   typedef R(RunType)(BindStateBase*,
   1905       typename CallbackParamTraits<X3>::ForwardType,
   1906       typename CallbackParamTraits<X4>::ForwardType,
   1907       typename CallbackParamTraits<X5>::ForwardType,
   1908       typename CallbackParamTraits<X6>::ForwardType);
   1909 
   1910   typedef R(UnboundRunType)(X3, X4, X5, X6);
   1911 
   1912   static R Run(BindStateBase* base,
   1913       typename CallbackParamTraits<X3>::ForwardType x3,
   1914       typename CallbackParamTraits<X4>::ForwardType x4,
   1915       typename CallbackParamTraits<X5>::ForwardType x5,
   1916       typename CallbackParamTraits<X6>::ForwardType x6) {
   1917     StorageType* storage = static_cast<StorageType*>(base);
   1918 
   1919     // Local references to make debugger stepping easier. If in a debugger,
   1920     // you really want to warp ahead and step through the
   1921     // InvokeHelper<>::MakeItSo() call below.
   1922     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1923     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   1924 
   1925     typename Bound1UnwrapTraits::ForwardType x1 =
   1926         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1927     typename Bound2UnwrapTraits::ForwardType x2 =
   1928         Bound2UnwrapTraits::Unwrap(storage->p2_);
   1929     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1930            typename StorageType::RunnableType,
   1931            void(typename Bound1UnwrapTraits::ForwardType,
   1932                typename Bound2UnwrapTraits::ForwardType,
   1933                typename CallbackParamTraits<X3>::ForwardType x3,
   1934                typename CallbackParamTraits<X4>::ForwardType x4,
   1935                typename CallbackParamTraits<X5>::ForwardType x5,
   1936                typename CallbackParamTraits<X6>::ForwardType x6)>
   1937                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1938                    CallbackForward(x2), CallbackForward(x3),
   1939                    CallbackForward(x4), CallbackForward(x5),
   1940                    CallbackForward(x6));
   1941   }
   1942 };
   1943 
   1944 // Arity 6 -> 3.
   1945 template <typename StorageType, typename R,typename X1, typename X2,
   1946     typename X3, typename X4, typename X5, typename X6>
   1947 struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6)> {
   1948   typedef R(RunType)(BindStateBase*,
   1949       typename CallbackParamTraits<X4>::ForwardType,
   1950       typename CallbackParamTraits<X5>::ForwardType,
   1951       typename CallbackParamTraits<X6>::ForwardType);
   1952 
   1953   typedef R(UnboundRunType)(X4, X5, X6);
   1954 
   1955   static R Run(BindStateBase* base,
   1956       typename CallbackParamTraits<X4>::ForwardType x4,
   1957       typename CallbackParamTraits<X5>::ForwardType x5,
   1958       typename CallbackParamTraits<X6>::ForwardType x6) {
   1959     StorageType* storage = static_cast<StorageType*>(base);
   1960 
   1961     // Local references to make debugger stepping easier. If in a debugger,
   1962     // you really want to warp ahead and step through the
   1963     // InvokeHelper<>::MakeItSo() call below.
   1964     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   1965     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   1966     typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
   1967 
   1968     typename Bound1UnwrapTraits::ForwardType x1 =
   1969         Bound1UnwrapTraits::Unwrap(storage->p1_);
   1970     typename Bound2UnwrapTraits::ForwardType x2 =
   1971         Bound2UnwrapTraits::Unwrap(storage->p2_);
   1972     typename Bound3UnwrapTraits::ForwardType x3 =
   1973         Bound3UnwrapTraits::Unwrap(storage->p3_);
   1974     return InvokeHelper<StorageType::IsWeakCall::value, R,
   1975            typename StorageType::RunnableType,
   1976            void(typename Bound1UnwrapTraits::ForwardType,
   1977                typename Bound2UnwrapTraits::ForwardType,
   1978                typename Bound3UnwrapTraits::ForwardType,
   1979                typename CallbackParamTraits<X4>::ForwardType x4,
   1980                typename CallbackParamTraits<X5>::ForwardType x5,
   1981                typename CallbackParamTraits<X6>::ForwardType x6)>
   1982                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   1983                    CallbackForward(x2), CallbackForward(x3),
   1984                    CallbackForward(x4), CallbackForward(x5),
   1985                    CallbackForward(x6));
   1986   }
   1987 };
   1988 
   1989 // Arity 6 -> 2.
   1990 template <typename StorageType, typename R,typename X1, typename X2,
   1991     typename X3, typename X4, typename X5, typename X6>
   1992 struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6)> {
   1993   typedef R(RunType)(BindStateBase*,
   1994       typename CallbackParamTraits<X5>::ForwardType,
   1995       typename CallbackParamTraits<X6>::ForwardType);
   1996 
   1997   typedef R(UnboundRunType)(X5, X6);
   1998 
   1999   static R Run(BindStateBase* base,
   2000       typename CallbackParamTraits<X5>::ForwardType x5,
   2001       typename CallbackParamTraits<X6>::ForwardType x6) {
   2002     StorageType* storage = static_cast<StorageType*>(base);
   2003 
   2004     // Local references to make debugger stepping easier. If in a debugger,
   2005     // you really want to warp ahead and step through the
   2006     // InvokeHelper<>::MakeItSo() call below.
   2007     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   2008     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   2009     typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
   2010     typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
   2011 
   2012     typename Bound1UnwrapTraits::ForwardType x1 =
   2013         Bound1UnwrapTraits::Unwrap(storage->p1_);
   2014     typename Bound2UnwrapTraits::ForwardType x2 =
   2015         Bound2UnwrapTraits::Unwrap(storage->p2_);
   2016     typename Bound3UnwrapTraits::ForwardType x3 =
   2017         Bound3UnwrapTraits::Unwrap(storage->p3_);
   2018     typename Bound4UnwrapTraits::ForwardType x4 =
   2019         Bound4UnwrapTraits::Unwrap(storage->p4_);
   2020     return InvokeHelper<StorageType::IsWeakCall::value, R,
   2021            typename StorageType::RunnableType,
   2022            void(typename Bound1UnwrapTraits::ForwardType,
   2023                typename Bound2UnwrapTraits::ForwardType,
   2024                typename Bound3UnwrapTraits::ForwardType,
   2025                typename Bound4UnwrapTraits::ForwardType,
   2026                typename CallbackParamTraits<X5>::ForwardType x5,
   2027                typename CallbackParamTraits<X6>::ForwardType x6)>
   2028                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   2029                    CallbackForward(x2), CallbackForward(x3),
   2030                    CallbackForward(x4), CallbackForward(x5),
   2031                    CallbackForward(x6));
   2032   }
   2033 };
   2034 
   2035 // Arity 6 -> 1.
   2036 template <typename StorageType, typename R,typename X1, typename X2,
   2037     typename X3, typename X4, typename X5, typename X6>
   2038 struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6)> {
   2039   typedef R(RunType)(BindStateBase*,
   2040       typename CallbackParamTraits<X6>::ForwardType);
   2041 
   2042   typedef R(UnboundRunType)(X6);
   2043 
   2044   static R Run(BindStateBase* base,
   2045       typename CallbackParamTraits<X6>::ForwardType x6) {
   2046     StorageType* storage = static_cast<StorageType*>(base);
   2047 
   2048     // Local references to make debugger stepping easier. If in a debugger,
   2049     // you really want to warp ahead and step through the
   2050     // InvokeHelper<>::MakeItSo() call below.
   2051     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   2052     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   2053     typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
   2054     typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
   2055     typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
   2056 
   2057     typename Bound1UnwrapTraits::ForwardType x1 =
   2058         Bound1UnwrapTraits::Unwrap(storage->p1_);
   2059     typename Bound2UnwrapTraits::ForwardType x2 =
   2060         Bound2UnwrapTraits::Unwrap(storage->p2_);
   2061     typename Bound3UnwrapTraits::ForwardType x3 =
   2062         Bound3UnwrapTraits::Unwrap(storage->p3_);
   2063     typename Bound4UnwrapTraits::ForwardType x4 =
   2064         Bound4UnwrapTraits::Unwrap(storage->p4_);
   2065     typename Bound5UnwrapTraits::ForwardType x5 =
   2066         Bound5UnwrapTraits::Unwrap(storage->p5_);
   2067     return InvokeHelper<StorageType::IsWeakCall::value, R,
   2068            typename StorageType::RunnableType,
   2069            void(typename Bound1UnwrapTraits::ForwardType,
   2070                typename Bound2UnwrapTraits::ForwardType,
   2071                typename Bound3UnwrapTraits::ForwardType,
   2072                typename Bound4UnwrapTraits::ForwardType,
   2073                typename Bound5UnwrapTraits::ForwardType,
   2074                typename CallbackParamTraits<X6>::ForwardType x6)>
   2075                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   2076                    CallbackForward(x2), CallbackForward(x3),
   2077                    CallbackForward(x4), CallbackForward(x5),
   2078                    CallbackForward(x6));
   2079   }
   2080 };
   2081 
   2082 // Arity 6 -> 0.
   2083 template <typename StorageType, typename R,typename X1, typename X2,
   2084     typename X3, typename X4, typename X5, typename X6>
   2085 struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6)> {
   2086   typedef R(RunType)(BindStateBase*);
   2087 
   2088   typedef R(UnboundRunType)();
   2089 
   2090   static R Run(BindStateBase* base) {
   2091     StorageType* storage = static_cast<StorageType*>(base);
   2092 
   2093     // Local references to make debugger stepping easier. If in a debugger,
   2094     // you really want to warp ahead and step through the
   2095     // InvokeHelper<>::MakeItSo() call below.
   2096     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   2097     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   2098     typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
   2099     typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
   2100     typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
   2101     typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits;
   2102 
   2103     typename Bound1UnwrapTraits::ForwardType x1 =
   2104         Bound1UnwrapTraits::Unwrap(storage->p1_);
   2105     typename Bound2UnwrapTraits::ForwardType x2 =
   2106         Bound2UnwrapTraits::Unwrap(storage->p2_);
   2107     typename Bound3UnwrapTraits::ForwardType x3 =
   2108         Bound3UnwrapTraits::Unwrap(storage->p3_);
   2109     typename Bound4UnwrapTraits::ForwardType x4 =
   2110         Bound4UnwrapTraits::Unwrap(storage->p4_);
   2111     typename Bound5UnwrapTraits::ForwardType x5 =
   2112         Bound5UnwrapTraits::Unwrap(storage->p5_);
   2113     typename Bound6UnwrapTraits::ForwardType x6 =
   2114         Bound6UnwrapTraits::Unwrap(storage->p6_);
   2115     return InvokeHelper<StorageType::IsWeakCall::value, R,
   2116            typename StorageType::RunnableType,
   2117            void(typename Bound1UnwrapTraits::ForwardType,
   2118                typename Bound2UnwrapTraits::ForwardType,
   2119                typename Bound3UnwrapTraits::ForwardType,
   2120                typename Bound4UnwrapTraits::ForwardType,
   2121                typename Bound5UnwrapTraits::ForwardType,
   2122                typename Bound6UnwrapTraits::ForwardType)>
   2123                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   2124                    CallbackForward(x2), CallbackForward(x3),
   2125                    CallbackForward(x4), CallbackForward(x5),
   2126                    CallbackForward(x6));
   2127   }
   2128 };
   2129 
   2130 // Arity 7 -> 7.
   2131 template <typename StorageType, typename R,typename X1, typename X2,
   2132     typename X3, typename X4, typename X5, typename X6, typename X7>
   2133 struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
   2134   typedef R(RunType)(BindStateBase*,
   2135       typename CallbackParamTraits<X1>::ForwardType,
   2136       typename CallbackParamTraits<X2>::ForwardType,
   2137       typename CallbackParamTraits<X3>::ForwardType,
   2138       typename CallbackParamTraits<X4>::ForwardType,
   2139       typename CallbackParamTraits<X5>::ForwardType,
   2140       typename CallbackParamTraits<X6>::ForwardType,
   2141       typename CallbackParamTraits<X7>::ForwardType);
   2142 
   2143   typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6, X7);
   2144 
   2145   static R Run(BindStateBase* base,
   2146       typename CallbackParamTraits<X1>::ForwardType x1,
   2147       typename CallbackParamTraits<X2>::ForwardType x2,
   2148       typename CallbackParamTraits<X3>::ForwardType x3,
   2149       typename CallbackParamTraits<X4>::ForwardType x4,
   2150       typename CallbackParamTraits<X5>::ForwardType x5,
   2151       typename CallbackParamTraits<X6>::ForwardType x6,
   2152       typename CallbackParamTraits<X7>::ForwardType x7) {
   2153     StorageType* storage = static_cast<StorageType*>(base);
   2154 
   2155     // Local references to make debugger stepping easier. If in a debugger,
   2156     // you really want to warp ahead and step through the
   2157     // InvokeHelper<>::MakeItSo() call below.
   2158 
   2159     return InvokeHelper<StorageType::IsWeakCall::value, R,
   2160            typename StorageType::RunnableType,
   2161            void(typename CallbackParamTraits<X1>::ForwardType x1,
   2162                typename CallbackParamTraits<X2>::ForwardType x2,
   2163                typename CallbackParamTraits<X3>::ForwardType x3,
   2164                typename CallbackParamTraits<X4>::ForwardType x4,
   2165                typename CallbackParamTraits<X5>::ForwardType x5,
   2166                typename CallbackParamTraits<X6>::ForwardType x6,
   2167                typename CallbackParamTraits<X7>::ForwardType x7)>
   2168                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   2169                    CallbackForward(x2), CallbackForward(x3),
   2170                    CallbackForward(x4), CallbackForward(x5),
   2171                    CallbackForward(x6), CallbackForward(x7));
   2172   }
   2173 };
   2174 
   2175 // Arity 7 -> 6.
   2176 template <typename StorageType, typename R,typename X1, typename X2,
   2177     typename X3, typename X4, typename X5, typename X6, typename X7>
   2178 struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
   2179   typedef R(RunType)(BindStateBase*,
   2180       typename CallbackParamTraits<X2>::ForwardType,
   2181       typename CallbackParamTraits<X3>::ForwardType,
   2182       typename CallbackParamTraits<X4>::ForwardType,
   2183       typename CallbackParamTraits<X5>::ForwardType,
   2184       typename CallbackParamTraits<X6>::ForwardType,
   2185       typename CallbackParamTraits<X7>::ForwardType);
   2186 
   2187   typedef R(UnboundRunType)(X2, X3, X4, X5, X6, X7);
   2188 
   2189   static R Run(BindStateBase* base,
   2190       typename CallbackParamTraits<X2>::ForwardType x2,
   2191       typename CallbackParamTraits<X3>::ForwardType x3,
   2192       typename CallbackParamTraits<X4>::ForwardType x4,
   2193       typename CallbackParamTraits<X5>::ForwardType x5,
   2194       typename CallbackParamTraits<X6>::ForwardType x6,
   2195       typename CallbackParamTraits<X7>::ForwardType x7) {
   2196     StorageType* storage = static_cast<StorageType*>(base);
   2197 
   2198     // Local references to make debugger stepping easier. If in a debugger,
   2199     // you really want to warp ahead and step through the
   2200     // InvokeHelper<>::MakeItSo() call below.
   2201     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   2202 
   2203     typename Bound1UnwrapTraits::ForwardType x1 =
   2204         Bound1UnwrapTraits::Unwrap(storage->p1_);
   2205     return InvokeHelper<StorageType::IsWeakCall::value, R,
   2206            typename StorageType::RunnableType,
   2207            void(typename Bound1UnwrapTraits::ForwardType,
   2208                typename CallbackParamTraits<X2>::ForwardType x2,
   2209                typename CallbackParamTraits<X3>::ForwardType x3,
   2210                typename CallbackParamTraits<X4>::ForwardType x4,
   2211                typename CallbackParamTraits<X5>::ForwardType x5,
   2212                typename CallbackParamTraits<X6>::ForwardType x6,
   2213                typename CallbackParamTraits<X7>::ForwardType x7)>
   2214                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   2215                    CallbackForward(x2), CallbackForward(x3),
   2216                    CallbackForward(x4), CallbackForward(x5),
   2217                    CallbackForward(x6), CallbackForward(x7));
   2218   }
   2219 };
   2220 
   2221 // Arity 7 -> 5.
   2222 template <typename StorageType, typename R,typename X1, typename X2,
   2223     typename X3, typename X4, typename X5, typename X6, typename X7>
   2224 struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
   2225   typedef R(RunType)(BindStateBase*,
   2226       typename CallbackParamTraits<X3>::ForwardType,
   2227       typename CallbackParamTraits<X4>::ForwardType,
   2228       typename CallbackParamTraits<X5>::ForwardType,
   2229       typename CallbackParamTraits<X6>::ForwardType,
   2230       typename CallbackParamTraits<X7>::ForwardType);
   2231 
   2232   typedef R(UnboundRunType)(X3, X4, X5, X6, X7);
   2233 
   2234   static R Run(BindStateBase* base,
   2235       typename CallbackParamTraits<X3>::ForwardType x3,
   2236       typename CallbackParamTraits<X4>::ForwardType x4,
   2237       typename CallbackParamTraits<X5>::ForwardType x5,
   2238       typename CallbackParamTraits<X6>::ForwardType x6,
   2239       typename CallbackParamTraits<X7>::ForwardType x7) {
   2240     StorageType* storage = static_cast<StorageType*>(base);
   2241 
   2242     // Local references to make debugger stepping easier. If in a debugger,
   2243     // you really want to warp ahead and step through the
   2244     // InvokeHelper<>::MakeItSo() call below.
   2245     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   2246     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   2247 
   2248     typename Bound1UnwrapTraits::ForwardType x1 =
   2249         Bound1UnwrapTraits::Unwrap(storage->p1_);
   2250     typename Bound2UnwrapTraits::ForwardType x2 =
   2251         Bound2UnwrapTraits::Unwrap(storage->p2_);
   2252     return InvokeHelper<StorageType::IsWeakCall::value, R,
   2253            typename StorageType::RunnableType,
   2254            void(typename Bound1UnwrapTraits::ForwardType,
   2255                typename Bound2UnwrapTraits::ForwardType,
   2256                typename CallbackParamTraits<X3>::ForwardType x3,
   2257                typename CallbackParamTraits<X4>::ForwardType x4,
   2258                typename CallbackParamTraits<X5>::ForwardType x5,
   2259                typename CallbackParamTraits<X6>::ForwardType x6,
   2260                typename CallbackParamTraits<X7>::ForwardType x7)>
   2261                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   2262                    CallbackForward(x2), CallbackForward(x3),
   2263                    CallbackForward(x4), CallbackForward(x5),
   2264                    CallbackForward(x6), CallbackForward(x7));
   2265   }
   2266 };
   2267 
   2268 // Arity 7 -> 4.
   2269 template <typename StorageType, typename R,typename X1, typename X2,
   2270     typename X3, typename X4, typename X5, typename X6, typename X7>
   2271 struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
   2272   typedef R(RunType)(BindStateBase*,
   2273       typename CallbackParamTraits<X4>::ForwardType,
   2274       typename CallbackParamTraits<X5>::ForwardType,
   2275       typename CallbackParamTraits<X6>::ForwardType,
   2276       typename CallbackParamTraits<X7>::ForwardType);
   2277 
   2278   typedef R(UnboundRunType)(X4, X5, X6, X7);
   2279 
   2280   static R Run(BindStateBase* base,
   2281       typename CallbackParamTraits<X4>::ForwardType x4,
   2282       typename CallbackParamTraits<X5>::ForwardType x5,
   2283       typename CallbackParamTraits<X6>::ForwardType x6,
   2284       typename CallbackParamTraits<X7>::ForwardType x7) {
   2285     StorageType* storage = static_cast<StorageType*>(base);
   2286 
   2287     // Local references to make debugger stepping easier. If in a debugger,
   2288     // you really want to warp ahead and step through the
   2289     // InvokeHelper<>::MakeItSo() call below.
   2290     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   2291     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   2292     typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
   2293 
   2294     typename Bound1UnwrapTraits::ForwardType x1 =
   2295         Bound1UnwrapTraits::Unwrap(storage->p1_);
   2296     typename Bound2UnwrapTraits::ForwardType x2 =
   2297         Bound2UnwrapTraits::Unwrap(storage->p2_);
   2298     typename Bound3UnwrapTraits::ForwardType x3 =
   2299         Bound3UnwrapTraits::Unwrap(storage->p3_);
   2300     return InvokeHelper<StorageType::IsWeakCall::value, R,
   2301            typename StorageType::RunnableType,
   2302            void(typename Bound1UnwrapTraits::ForwardType,
   2303                typename Bound2UnwrapTraits::ForwardType,
   2304                typename Bound3UnwrapTraits::ForwardType,
   2305                typename CallbackParamTraits<X4>::ForwardType x4,
   2306                typename CallbackParamTraits<X5>::ForwardType x5,
   2307                typename CallbackParamTraits<X6>::ForwardType x6,
   2308                typename CallbackParamTraits<X7>::ForwardType x7)>
   2309                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   2310                    CallbackForward(x2), CallbackForward(x3),
   2311                    CallbackForward(x4), CallbackForward(x5),
   2312                    CallbackForward(x6), CallbackForward(x7));
   2313   }
   2314 };
   2315 
   2316 // Arity 7 -> 3.
   2317 template <typename StorageType, typename R,typename X1, typename X2,
   2318     typename X3, typename X4, typename X5, typename X6, typename X7>
   2319 struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
   2320   typedef R(RunType)(BindStateBase*,
   2321       typename CallbackParamTraits<X5>::ForwardType,
   2322       typename CallbackParamTraits<X6>::ForwardType,
   2323       typename CallbackParamTraits<X7>::ForwardType);
   2324 
   2325   typedef R(UnboundRunType)(X5, X6, X7);
   2326 
   2327   static R Run(BindStateBase* base,
   2328       typename CallbackParamTraits<X5>::ForwardType x5,
   2329       typename CallbackParamTraits<X6>::ForwardType x6,
   2330       typename CallbackParamTraits<X7>::ForwardType x7) {
   2331     StorageType* storage = static_cast<StorageType*>(base);
   2332 
   2333     // Local references to make debugger stepping easier. If in a debugger,
   2334     // you really want to warp ahead and step through the
   2335     // InvokeHelper<>::MakeItSo() call below.
   2336     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   2337     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   2338     typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
   2339     typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
   2340 
   2341     typename Bound1UnwrapTraits::ForwardType x1 =
   2342         Bound1UnwrapTraits::Unwrap(storage->p1_);
   2343     typename Bound2UnwrapTraits::ForwardType x2 =
   2344         Bound2UnwrapTraits::Unwrap(storage->p2_);
   2345     typename Bound3UnwrapTraits::ForwardType x3 =
   2346         Bound3UnwrapTraits::Unwrap(storage->p3_);
   2347     typename Bound4UnwrapTraits::ForwardType x4 =
   2348         Bound4UnwrapTraits::Unwrap(storage->p4_);
   2349     return InvokeHelper<StorageType::IsWeakCall::value, R,
   2350            typename StorageType::RunnableType,
   2351            void(typename Bound1UnwrapTraits::ForwardType,
   2352                typename Bound2UnwrapTraits::ForwardType,
   2353                typename Bound3UnwrapTraits::ForwardType,
   2354                typename Bound4UnwrapTraits::ForwardType,
   2355                typename CallbackParamTraits<X5>::ForwardType x5,
   2356                typename CallbackParamTraits<X6>::ForwardType x6,
   2357                typename CallbackParamTraits<X7>::ForwardType x7)>
   2358                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   2359                    CallbackForward(x2), CallbackForward(x3),
   2360                    CallbackForward(x4), CallbackForward(x5),
   2361                    CallbackForward(x6), CallbackForward(x7));
   2362   }
   2363 };
   2364 
   2365 // Arity 7 -> 2.
   2366 template <typename StorageType, typename R,typename X1, typename X2,
   2367     typename X3, typename X4, typename X5, typename X6, typename X7>
   2368 struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
   2369   typedef R(RunType)(BindStateBase*,
   2370       typename CallbackParamTraits<X6>::ForwardType,
   2371       typename CallbackParamTraits<X7>::ForwardType);
   2372 
   2373   typedef R(UnboundRunType)(X6, X7);
   2374 
   2375   static R Run(BindStateBase* base,
   2376       typename CallbackParamTraits<X6>::ForwardType x6,
   2377       typename CallbackParamTraits<X7>::ForwardType x7) {
   2378     StorageType* storage = static_cast<StorageType*>(base);
   2379 
   2380     // Local references to make debugger stepping easier. If in a debugger,
   2381     // you really want to warp ahead and step through the
   2382     // InvokeHelper<>::MakeItSo() call below.
   2383     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   2384     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   2385     typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
   2386     typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
   2387     typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
   2388 
   2389     typename Bound1UnwrapTraits::ForwardType x1 =
   2390         Bound1UnwrapTraits::Unwrap(storage->p1_);
   2391     typename Bound2UnwrapTraits::ForwardType x2 =
   2392         Bound2UnwrapTraits::Unwrap(storage->p2_);
   2393     typename Bound3UnwrapTraits::ForwardType x3 =
   2394         Bound3UnwrapTraits::Unwrap(storage->p3_);
   2395     typename Bound4UnwrapTraits::ForwardType x4 =
   2396         Bound4UnwrapTraits::Unwrap(storage->p4_);
   2397     typename Bound5UnwrapTraits::ForwardType x5 =
   2398         Bound5UnwrapTraits::Unwrap(storage->p5_);
   2399     return InvokeHelper<StorageType::IsWeakCall::value, R,
   2400            typename StorageType::RunnableType,
   2401            void(typename Bound1UnwrapTraits::ForwardType,
   2402                typename Bound2UnwrapTraits::ForwardType,
   2403                typename Bound3UnwrapTraits::ForwardType,
   2404                typename Bound4UnwrapTraits::ForwardType,
   2405                typename Bound5UnwrapTraits::ForwardType,
   2406                typename CallbackParamTraits<X6>::ForwardType x6,
   2407                typename CallbackParamTraits<X7>::ForwardType x7)>
   2408                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   2409                    CallbackForward(x2), CallbackForward(x3),
   2410                    CallbackForward(x4), CallbackForward(x5),
   2411                    CallbackForward(x6), CallbackForward(x7));
   2412   }
   2413 };
   2414 
   2415 // Arity 7 -> 1.
   2416 template <typename StorageType, typename R,typename X1, typename X2,
   2417     typename X3, typename X4, typename X5, typename X6, typename X7>
   2418 struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
   2419   typedef R(RunType)(BindStateBase*,
   2420       typename CallbackParamTraits<X7>::ForwardType);
   2421 
   2422   typedef R(UnboundRunType)(X7);
   2423 
   2424   static R Run(BindStateBase* base,
   2425       typename CallbackParamTraits<X7>::ForwardType x7) {
   2426     StorageType* storage = static_cast<StorageType*>(base);
   2427 
   2428     // Local references to make debugger stepping easier. If in a debugger,
   2429     // you really want to warp ahead and step through the
   2430     // InvokeHelper<>::MakeItSo() call below.
   2431     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   2432     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   2433     typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
   2434     typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
   2435     typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
   2436     typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits;
   2437 
   2438     typename Bound1UnwrapTraits::ForwardType x1 =
   2439         Bound1UnwrapTraits::Unwrap(storage->p1_);
   2440     typename Bound2UnwrapTraits::ForwardType x2 =
   2441         Bound2UnwrapTraits::Unwrap(storage->p2_);
   2442     typename Bound3UnwrapTraits::ForwardType x3 =
   2443         Bound3UnwrapTraits::Unwrap(storage->p3_);
   2444     typename Bound4UnwrapTraits::ForwardType x4 =
   2445         Bound4UnwrapTraits::Unwrap(storage->p4_);
   2446     typename Bound5UnwrapTraits::ForwardType x5 =
   2447         Bound5UnwrapTraits::Unwrap(storage->p5_);
   2448     typename Bound6UnwrapTraits::ForwardType x6 =
   2449         Bound6UnwrapTraits::Unwrap(storage->p6_);
   2450     return InvokeHelper<StorageType::IsWeakCall::value, R,
   2451            typename StorageType::RunnableType,
   2452            void(typename Bound1UnwrapTraits::ForwardType,
   2453                typename Bound2UnwrapTraits::ForwardType,
   2454                typename Bound3UnwrapTraits::ForwardType,
   2455                typename Bound4UnwrapTraits::ForwardType,
   2456                typename Bound5UnwrapTraits::ForwardType,
   2457                typename Bound6UnwrapTraits::ForwardType,
   2458                typename CallbackParamTraits<X7>::ForwardType x7)>
   2459                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   2460                    CallbackForward(x2), CallbackForward(x3),
   2461                    CallbackForward(x4), CallbackForward(x5),
   2462                    CallbackForward(x6), CallbackForward(x7));
   2463   }
   2464 };
   2465 
   2466 // Arity 7 -> 0.
   2467 template <typename StorageType, typename R,typename X1, typename X2,
   2468     typename X3, typename X4, typename X5, typename X6, typename X7>
   2469 struct Invoker<7, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
   2470   typedef R(RunType)(BindStateBase*);
   2471 
   2472   typedef R(UnboundRunType)();
   2473 
   2474   static R Run(BindStateBase* base) {
   2475     StorageType* storage = static_cast<StorageType*>(base);
   2476 
   2477     // Local references to make debugger stepping easier. If in a debugger,
   2478     // you really want to warp ahead and step through the
   2479     // InvokeHelper<>::MakeItSo() call below.
   2480     typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
   2481     typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
   2482     typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
   2483     typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
   2484     typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
   2485     typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits;
   2486     typedef typename StorageType::Bound7UnwrapTraits Bound7UnwrapTraits;
   2487 
   2488     typename Bound1UnwrapTraits::ForwardType x1 =
   2489         Bound1UnwrapTraits::Unwrap(storage->p1_);
   2490     typename Bound2UnwrapTraits::ForwardType x2 =
   2491         Bound2UnwrapTraits::Unwrap(storage->p2_);
   2492     typename Bound3UnwrapTraits::ForwardType x3 =
   2493         Bound3UnwrapTraits::Unwrap(storage->p3_);
   2494     typename Bound4UnwrapTraits::ForwardType x4 =
   2495         Bound4UnwrapTraits::Unwrap(storage->p4_);
   2496     typename Bound5UnwrapTraits::ForwardType x5 =
   2497         Bound5UnwrapTraits::Unwrap(storage->p5_);
   2498     typename Bound6UnwrapTraits::ForwardType x6 =
   2499         Bound6UnwrapTraits::Unwrap(storage->p6_);
   2500     typename Bound7UnwrapTraits::ForwardType x7 =
   2501         Bound7UnwrapTraits::Unwrap(storage->p7_);
   2502     return InvokeHelper<StorageType::IsWeakCall::value, R,
   2503            typename StorageType::RunnableType,
   2504            void(typename Bound1UnwrapTraits::ForwardType,
   2505                typename Bound2UnwrapTraits::ForwardType,
   2506                typename Bound3UnwrapTraits::ForwardType,
   2507                typename Bound4UnwrapTraits::ForwardType,
   2508                typename Bound5UnwrapTraits::ForwardType,
   2509                typename Bound6UnwrapTraits::ForwardType,
   2510                typename Bound7UnwrapTraits::ForwardType)>
   2511                ::MakeItSo(storage->runnable_, CallbackForward(x1),
   2512                    CallbackForward(x2), CallbackForward(x3),
   2513                    CallbackForward(x4), CallbackForward(x5),
   2514                    CallbackForward(x6), CallbackForward(x7));
   2515   }
   2516 };
   2517 
   2518 
   2519 // BindState<>
   2520 //
   2521 // This stores all the state passed into Bind() and is also where most
   2522 // of the template resolution magic occurs.
   2523 //
   2524 // Runnable is the functor we are binding arguments to.
   2525 // RunType is type of the Run() function that the Invoker<> should use.
   2526 // Normally, this is the same as the RunType of the Runnable, but it can
   2527 // be different if an adapter like IgnoreResult() has been used.
   2528 //
   2529 // BoundArgsType contains the storage type for all the bound arguments by
   2530 // (ab)using a function type.
   2531 template <typename Runnable, typename RunType, typename BoundArgsType>
   2532 struct BindState;
   2533 
   2534 template <typename Runnable, typename RunType>
   2535 struct BindState<Runnable, RunType, void()> : public BindStateBase {
   2536   typedef Runnable RunnableType;
   2537   typedef false_type IsWeakCall;
   2538   typedef Invoker<0, BindState, RunType> InvokerType;
   2539   typedef typename InvokerType::UnboundRunType UnboundRunType;
   2540   explicit BindState(const Runnable& runnable)
   2541       : runnable_(runnable) {
   2542   }
   2543 
   2544   virtual ~BindState() {  }
   2545 
   2546   RunnableType runnable_;
   2547 };
   2548 
   2549 template <typename Runnable, typename RunType, typename P1>
   2550 struct BindState<Runnable, RunType, void(P1)> : public BindStateBase {
   2551   typedef Runnable RunnableType;
   2552   typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
   2553   typedef Invoker<1, BindState, RunType> InvokerType;
   2554   typedef typename InvokerType::UnboundRunType UnboundRunType;
   2555 
   2556   // Convenience typedefs for bound argument types.
   2557   typedef UnwrapTraits<P1> Bound1UnwrapTraits;
   2558 
   2559   BindState(const Runnable& runnable, const P1& p1)
   2560       : runnable_(runnable),
   2561         p1_(p1) {
   2562     MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
   2563   }
   2564 
   2565   virtual ~BindState() {    MaybeRefcount<HasIsMethodTag<Runnable>::value,
   2566       P1>::Release(p1_);  }
   2567 
   2568   RunnableType runnable_;
   2569   P1 p1_;
   2570 };
   2571 
   2572 template <typename Runnable, typename RunType, typename P1, typename P2>
   2573 struct BindState<Runnable, RunType, void(P1, P2)> : public BindStateBase {
   2574   typedef Runnable RunnableType;
   2575   typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
   2576   typedef Invoker<2, BindState, RunType> InvokerType;
   2577   typedef typename InvokerType::UnboundRunType UnboundRunType;
   2578 
   2579   // Convenience typedefs for bound argument types.
   2580   typedef UnwrapTraits<P1> Bound1UnwrapTraits;
   2581   typedef UnwrapTraits<P2> Bound2UnwrapTraits;
   2582 
   2583   BindState(const Runnable& runnable, const P1& p1, const P2& p2)
   2584       : runnable_(runnable),
   2585         p1_(p1),
   2586         p2_(p2) {
   2587     MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
   2588   }
   2589 
   2590   virtual ~BindState() {    MaybeRefcount<HasIsMethodTag<Runnable>::value,
   2591       P1>::Release(p1_);  }
   2592 
   2593   RunnableType runnable_;
   2594   P1 p1_;
   2595   P2 p2_;
   2596 };
   2597 
   2598 template <typename Runnable, typename RunType, typename P1, typename P2,
   2599     typename P3>
   2600 struct BindState<Runnable, RunType, void(P1, P2, P3)> : public BindStateBase {
   2601   typedef Runnable RunnableType;
   2602   typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
   2603   typedef Invoker<3, BindState, RunType> InvokerType;
   2604   typedef typename InvokerType::UnboundRunType UnboundRunType;
   2605 
   2606   // Convenience typedefs for bound argument types.
   2607   typedef UnwrapTraits<P1> Bound1UnwrapTraits;
   2608   typedef UnwrapTraits<P2> Bound2UnwrapTraits;
   2609   typedef UnwrapTraits<P3> Bound3UnwrapTraits;
   2610 
   2611   BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3)
   2612       : runnable_(runnable),
   2613         p1_(p1),
   2614         p2_(p2),
   2615         p3_(p3) {
   2616     MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
   2617   }
   2618 
   2619   virtual ~BindState() {    MaybeRefcount<HasIsMethodTag<Runnable>::value,
   2620       P1>::Release(p1_);  }
   2621 
   2622   RunnableType runnable_;
   2623   P1 p1_;
   2624   P2 p2_;
   2625   P3 p3_;
   2626 };
   2627 
   2628 template <typename Runnable, typename RunType, typename P1, typename P2,
   2629     typename P3, typename P4>
   2630 struct BindState<Runnable, RunType, void(P1, P2, P3,
   2631     P4)> : public BindStateBase {
   2632   typedef Runnable RunnableType;
   2633   typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
   2634   typedef Invoker<4, BindState, RunType> InvokerType;
   2635   typedef typename InvokerType::UnboundRunType UnboundRunType;
   2636 
   2637   // Convenience typedefs for bound argument types.
   2638   typedef UnwrapTraits<P1> Bound1UnwrapTraits;
   2639   typedef UnwrapTraits<P2> Bound2UnwrapTraits;
   2640   typedef UnwrapTraits<P3> Bound3UnwrapTraits;
   2641   typedef UnwrapTraits<P4> Bound4UnwrapTraits;
   2642 
   2643   BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
   2644       const P4& p4)
   2645       : runnable_(runnable),
   2646         p1_(p1),
   2647         p2_(p2),
   2648         p3_(p3),
   2649         p4_(p4) {
   2650     MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
   2651   }
   2652 
   2653   virtual ~BindState() {    MaybeRefcount<HasIsMethodTag<Runnable>::value,
   2654       P1>::Release(p1_);  }
   2655 
   2656   RunnableType runnable_;
   2657   P1 p1_;
   2658   P2 p2_;
   2659   P3 p3_;
   2660   P4 p4_;
   2661 };
   2662 
   2663 template <typename Runnable, typename RunType, typename P1, typename P2,
   2664     typename P3, typename P4, typename P5>
   2665 struct BindState<Runnable, RunType, void(P1, P2, P3, P4,
   2666     P5)> : public BindStateBase {
   2667   typedef Runnable RunnableType;
   2668   typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
   2669   typedef Invoker<5, BindState, RunType> InvokerType;
   2670   typedef typename InvokerType::UnboundRunType UnboundRunType;
   2671 
   2672   // Convenience typedefs for bound argument types.
   2673   typedef UnwrapTraits<P1> Bound1UnwrapTraits;
   2674   typedef UnwrapTraits<P2> Bound2UnwrapTraits;
   2675   typedef UnwrapTraits<P3> Bound3UnwrapTraits;
   2676   typedef UnwrapTraits<P4> Bound4UnwrapTraits;
   2677   typedef UnwrapTraits<P5> Bound5UnwrapTraits;
   2678 
   2679   BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
   2680       const P4& p4, const P5& p5)
   2681       : runnable_(runnable),
   2682         p1_(p1),
   2683         p2_(p2),
   2684         p3_(p3),
   2685         p4_(p4),
   2686         p5_(p5) {
   2687     MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
   2688   }
   2689 
   2690   virtual ~BindState() {    MaybeRefcount<HasIsMethodTag<Runnable>::value,
   2691       P1>::Release(p1_);  }
   2692 
   2693   RunnableType runnable_;
   2694   P1 p1_;
   2695   P2 p2_;
   2696   P3 p3_;
   2697   P4 p4_;
   2698   P5 p5_;
   2699 };
   2700 
   2701 template <typename Runnable, typename RunType, typename P1, typename P2,
   2702     typename P3, typename P4, typename P5, typename P6>
   2703 struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5,
   2704     P6)> : public BindStateBase {
   2705   typedef Runnable RunnableType;
   2706   typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
   2707   typedef Invoker<6, BindState, RunType> InvokerType;
   2708   typedef typename InvokerType::UnboundRunType UnboundRunType;
   2709 
   2710   // Convenience typedefs for bound argument types.
   2711   typedef UnwrapTraits<P1> Bound1UnwrapTraits;
   2712   typedef UnwrapTraits<P2> Bound2UnwrapTraits;
   2713   typedef UnwrapTraits<P3> Bound3UnwrapTraits;
   2714   typedef UnwrapTraits<P4> Bound4UnwrapTraits;
   2715   typedef UnwrapTraits<P5> Bound5UnwrapTraits;
   2716   typedef UnwrapTraits<P6> Bound6UnwrapTraits;
   2717 
   2718   BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
   2719       const P4& p4, const P5& p5, const P6& p6)
   2720       : runnable_(runnable),
   2721         p1_(p1),
   2722         p2_(p2),
   2723         p3_(p3),
   2724         p4_(p4),
   2725         p5_(p5),
   2726         p6_(p6) {
   2727     MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
   2728   }
   2729 
   2730   virtual ~BindState() {    MaybeRefcount<HasIsMethodTag<Runnable>::value,
   2731       P1>::Release(p1_);  }
   2732 
   2733   RunnableType runnable_;
   2734   P1 p1_;
   2735   P2 p2_;
   2736   P3 p3_;
   2737   P4 p4_;
   2738   P5 p5_;
   2739   P6 p6_;
   2740 };
   2741 
   2742 template <typename Runnable, typename RunType, typename P1, typename P2,
   2743     typename P3, typename P4, typename P5, typename P6, typename P7>
   2744 struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6,
   2745     P7)> : public BindStateBase {
   2746   typedef Runnable RunnableType;
   2747   typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
   2748   typedef Invoker<7, BindState, RunType> InvokerType;
   2749   typedef typename InvokerType::UnboundRunType UnboundRunType;
   2750 
   2751   // Convenience typedefs for bound argument types.
   2752   typedef UnwrapTraits<P1> Bound1UnwrapTraits;
   2753   typedef UnwrapTraits<P2> Bound2UnwrapTraits;
   2754   typedef UnwrapTraits<P3> Bound3UnwrapTraits;
   2755   typedef UnwrapTraits<P4> Bound4UnwrapTraits;
   2756   typedef UnwrapTraits<P5> Bound5UnwrapTraits;
   2757   typedef UnwrapTraits<P6> Bound6UnwrapTraits;
   2758   typedef UnwrapTraits<P7> Bound7UnwrapTraits;
   2759 
   2760   BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
   2761       const P4& p4, const P5& p5, const P6& p6, const P7& p7)
   2762       : runnable_(runnable),
   2763         p1_(p1),
   2764         p2_(p2),
   2765         p3_(p3),
   2766         p4_(p4),
   2767         p5_(p5),
   2768         p6_(p6),
   2769         p7_(p7) {
   2770     MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
   2771   }
   2772 
   2773   virtual ~BindState() {    MaybeRefcount<HasIsMethodTag<Runnable>::value,
   2774       P1>::Release(p1_);  }
   2775 
   2776   RunnableType runnable_;
   2777   P1 p1_;
   2778   P2 p2_;
   2779   P3 p3_;
   2780   P4 p4_;
   2781   P5 p5_;
   2782   P6 p6_;
   2783   P7 p7_;
   2784 };
   2785 
   2786 }  // namespace internal
   2787 }  // namespace base
   2788 
   2789 #endif  // BASE_BIND_INTERNAL_H_
   2790