1 // This file was GENERATED by command: 2 // pump.py bind.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_H_ 11 #define BASE_BIND_H_ 12 13 #include "base/bind_internal.h" 14 #include "base/callback_internal.h" 15 16 // ----------------------------------------------------------------------------- 17 // Usage documentation 18 // ----------------------------------------------------------------------------- 19 // 20 // See base/callback.h for documentation. 21 // 22 // 23 // ----------------------------------------------------------------------------- 24 // Implementation notes 25 // ----------------------------------------------------------------------------- 26 // 27 // If you're reading the implementation, before proceeding further, you should 28 // read the top comment of base/bind_internal.h for a definition of common 29 // terms and concepts. 30 // 31 // RETURN TYPES 32 // 33 // Though Bind()'s result is meant to be stored in a Callback<> type, it 34 // cannot actually return the exact type without requiring a large amount 35 // of extra template specializations. The problem is that in order to 36 // discern the correct specialization of Callback<>, Bind would need to 37 // unwrap the function signature to determine the signature's arity, and 38 // whether or not it is a method. 39 // 40 // Each unique combination of (arity, function_type, num_prebound) where 41 // function_type is one of {function, method, const_method} would require 42 // one specialization. We eventually have to do a similar number of 43 // specializations anyways in the implementation (see the Invoker<>, 44 // classes). However, it is avoidable in Bind if we return the result 45 // via an indirection like we do below. 46 // 47 // TODO(ajwong): We might be able to avoid this now, but need to test. 48 // 49 // It is possible to move most of the COMPILE_ASSERT asserts into BindState<>, 50 // but it feels a little nicer to have the asserts here so people do not 51 // need to crack open bind_internal.h. On the other hand, it makes Bind() 52 // harder to read. 53 54 namespace base { 55 56 template <typename Functor> 57 base::Callback< 58 typename internal::BindState< 59 typename internal::FunctorTraits<Functor>::RunnableType, 60 typename internal::FunctorTraits<Functor>::RunType, 61 void()> 62 ::UnboundRunType> 63 Bind(Functor functor) { 64 // Typedefs for how to store and run the functor. 65 typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; 66 typedef typename internal::FunctorTraits<Functor>::RunType RunType; 67 68 // Use RunnableType::RunType instead of RunType above because our 69 // checks should below for bound references need to know what the actual 70 // functor is going to interpret the argument as. 71 typedef internal::FunctionTraits<typename RunnableType::RunType> 72 BoundFunctorTraits; 73 74 typedef internal::BindState<RunnableType, RunType, void()> BindState; 75 76 77 return Callback<typename BindState::UnboundRunType>( 78 new BindState(internal::MakeRunnable(functor))); 79 } 80 81 template <typename Functor, typename P1> 82 base::Callback< 83 typename internal::BindState< 84 typename internal::FunctorTraits<Functor>::RunnableType, 85 typename internal::FunctorTraits<Functor>::RunType, 86 void(typename internal::CallbackParamTraits<P1>::StorageType)> 87 ::UnboundRunType> 88 Bind(Functor functor, const P1& p1) { 89 // Typedefs for how to store and run the functor. 90 typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; 91 typedef typename internal::FunctorTraits<Functor>::RunType RunType; 92 93 // Use RunnableType::RunType instead of RunType above because our 94 // checks should below for bound references need to know what the actual 95 // functor is going to interpret the argument as. 96 typedef internal::FunctionTraits<typename RunnableType::RunType> 97 BoundFunctorTraits; 98 99 // Do not allow binding a non-const reference parameter. Non-const reference 100 // parameters are disallowed by the Google style guide. Also, binding a 101 // non-const reference parameter can make for subtle bugs because the 102 // invoked function will receive a reference to the stored copy of the 103 // argument and not the original. 104 COMPILE_ASSERT( 105 !(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ), 106 do_not_bind_functions_with_nonconst_ref); 107 108 // For methods, we need to be careful for parameter 1. We do not require 109 // a scoped_refptr because BindState<> itself takes care of AddRef() for 110 // methods. We also disallow binding of an array as the method's target 111 // object. 112 COMPILE_ASSERT( 113 internal::HasIsMethodTag<RunnableType>::value || 114 !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value, 115 p1_is_refcounted_type_and_needs_scoped_refptr); 116 COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || 117 !is_array<P1>::value, 118 first_bound_argument_to_method_cannot_be_array); 119 typedef internal::BindState<RunnableType, RunType, 120 void(typename internal::CallbackParamTraits<P1>::StorageType)> BindState; 121 122 123 return Callback<typename BindState::UnboundRunType>( 124 new BindState(internal::MakeRunnable(functor), p1)); 125 } 126 127 template <typename Functor, typename P1, typename P2> 128 base::Callback< 129 typename internal::BindState< 130 typename internal::FunctorTraits<Functor>::RunnableType, 131 typename internal::FunctorTraits<Functor>::RunType, 132 void(typename internal::CallbackParamTraits<P1>::StorageType, 133 typename internal::CallbackParamTraits<P2>::StorageType)> 134 ::UnboundRunType> 135 Bind(Functor functor, const P1& p1, const P2& p2) { 136 // Typedefs for how to store and run the functor. 137 typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; 138 typedef typename internal::FunctorTraits<Functor>::RunType RunType; 139 140 // Use RunnableType::RunType instead of RunType above because our 141 // checks should below for bound references need to know what the actual 142 // functor is going to interpret the argument as. 143 typedef internal::FunctionTraits<typename RunnableType::RunType> 144 BoundFunctorTraits; 145 146 // Do not allow binding a non-const reference parameter. Non-const reference 147 // parameters are disallowed by the Google style guide. Also, binding a 148 // non-const reference parameter can make for subtle bugs because the 149 // invoked function will receive a reference to the stored copy of the 150 // argument and not the original. 151 COMPILE_ASSERT( 152 !(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value || 153 is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ), 154 do_not_bind_functions_with_nonconst_ref); 155 156 // For methods, we need to be careful for parameter 1. We do not require 157 // a scoped_refptr because BindState<> itself takes care of AddRef() for 158 // methods. We also disallow binding of an array as the method's target 159 // object. 160 COMPILE_ASSERT( 161 internal::HasIsMethodTag<RunnableType>::value || 162 !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value, 163 p1_is_refcounted_type_and_needs_scoped_refptr); 164 COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || 165 !is_array<P1>::value, 166 first_bound_argument_to_method_cannot_be_array); 167 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value, 168 p2_is_refcounted_type_and_needs_scoped_refptr); 169 typedef internal::BindState<RunnableType, RunType, 170 void(typename internal::CallbackParamTraits<P1>::StorageType, 171 typename internal::CallbackParamTraits<P2>::StorageType)> BindState; 172 173 174 return Callback<typename BindState::UnboundRunType>( 175 new BindState(internal::MakeRunnable(functor), p1, p2)); 176 } 177 178 template <typename Functor, typename P1, typename P2, typename P3> 179 base::Callback< 180 typename internal::BindState< 181 typename internal::FunctorTraits<Functor>::RunnableType, 182 typename internal::FunctorTraits<Functor>::RunType, 183 void(typename internal::CallbackParamTraits<P1>::StorageType, 184 typename internal::CallbackParamTraits<P2>::StorageType, 185 typename internal::CallbackParamTraits<P3>::StorageType)> 186 ::UnboundRunType> 187 Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3) { 188 // Typedefs for how to store and run the functor. 189 typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; 190 typedef typename internal::FunctorTraits<Functor>::RunType RunType; 191 192 // Use RunnableType::RunType instead of RunType above because our 193 // checks should below for bound references need to know what the actual 194 // functor is going to interpret the argument as. 195 typedef internal::FunctionTraits<typename RunnableType::RunType> 196 BoundFunctorTraits; 197 198 // Do not allow binding a non-const reference parameter. Non-const reference 199 // parameters are disallowed by the Google style guide. Also, binding a 200 // non-const reference parameter can make for subtle bugs because the 201 // invoked function will receive a reference to the stored copy of the 202 // argument and not the original. 203 COMPILE_ASSERT( 204 !(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value || 205 is_non_const_reference<typename BoundFunctorTraits::A2Type>::value || 206 is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ), 207 do_not_bind_functions_with_nonconst_ref); 208 209 // For methods, we need to be careful for parameter 1. We do not require 210 // a scoped_refptr because BindState<> itself takes care of AddRef() for 211 // methods. We also disallow binding of an array as the method's target 212 // object. 213 COMPILE_ASSERT( 214 internal::HasIsMethodTag<RunnableType>::value || 215 !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value, 216 p1_is_refcounted_type_and_needs_scoped_refptr); 217 COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || 218 !is_array<P1>::value, 219 first_bound_argument_to_method_cannot_be_array); 220 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value, 221 p2_is_refcounted_type_and_needs_scoped_refptr); 222 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P3>::value, 223 p3_is_refcounted_type_and_needs_scoped_refptr); 224 typedef internal::BindState<RunnableType, RunType, 225 void(typename internal::CallbackParamTraits<P1>::StorageType, 226 typename internal::CallbackParamTraits<P2>::StorageType, 227 typename internal::CallbackParamTraits<P3>::StorageType)> BindState; 228 229 230 return Callback<typename BindState::UnboundRunType>( 231 new BindState(internal::MakeRunnable(functor), p1, p2, p3)); 232 } 233 234 template <typename Functor, typename P1, typename P2, typename P3, typename P4> 235 base::Callback< 236 typename internal::BindState< 237 typename internal::FunctorTraits<Functor>::RunnableType, 238 typename internal::FunctorTraits<Functor>::RunType, 239 void(typename internal::CallbackParamTraits<P1>::StorageType, 240 typename internal::CallbackParamTraits<P2>::StorageType, 241 typename internal::CallbackParamTraits<P3>::StorageType, 242 typename internal::CallbackParamTraits<P4>::StorageType)> 243 ::UnboundRunType> 244 Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4) { 245 // Typedefs for how to store and run the functor. 246 typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; 247 typedef typename internal::FunctorTraits<Functor>::RunType RunType; 248 249 // Use RunnableType::RunType instead of RunType above because our 250 // checks should below for bound references need to know what the actual 251 // functor is going to interpret the argument as. 252 typedef internal::FunctionTraits<typename RunnableType::RunType> 253 BoundFunctorTraits; 254 255 // Do not allow binding a non-const reference parameter. Non-const reference 256 // parameters are disallowed by the Google style guide. Also, binding a 257 // non-const reference parameter can make for subtle bugs because the 258 // invoked function will receive a reference to the stored copy of the 259 // argument and not the original. 260 COMPILE_ASSERT( 261 !(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value || 262 is_non_const_reference<typename BoundFunctorTraits::A2Type>::value || 263 is_non_const_reference<typename BoundFunctorTraits::A3Type>::value || 264 is_non_const_reference<typename BoundFunctorTraits::A4Type>::value ), 265 do_not_bind_functions_with_nonconst_ref); 266 267 // For methods, we need to be careful for parameter 1. We do not require 268 // a scoped_refptr because BindState<> itself takes care of AddRef() for 269 // methods. We also disallow binding of an array as the method's target 270 // object. 271 COMPILE_ASSERT( 272 internal::HasIsMethodTag<RunnableType>::value || 273 !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value, 274 p1_is_refcounted_type_and_needs_scoped_refptr); 275 COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || 276 !is_array<P1>::value, 277 first_bound_argument_to_method_cannot_be_array); 278 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value, 279 p2_is_refcounted_type_and_needs_scoped_refptr); 280 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P3>::value, 281 p3_is_refcounted_type_and_needs_scoped_refptr); 282 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P4>::value, 283 p4_is_refcounted_type_and_needs_scoped_refptr); 284 typedef internal::BindState<RunnableType, RunType, 285 void(typename internal::CallbackParamTraits<P1>::StorageType, 286 typename internal::CallbackParamTraits<P2>::StorageType, 287 typename internal::CallbackParamTraits<P3>::StorageType, 288 typename internal::CallbackParamTraits<P4>::StorageType)> BindState; 289 290 291 return Callback<typename BindState::UnboundRunType>( 292 new BindState(internal::MakeRunnable(functor), p1, p2, p3, p4)); 293 } 294 295 template <typename Functor, typename P1, typename P2, typename P3, typename P4, 296 typename P5> 297 base::Callback< 298 typename internal::BindState< 299 typename internal::FunctorTraits<Functor>::RunnableType, 300 typename internal::FunctorTraits<Functor>::RunType, 301 void(typename internal::CallbackParamTraits<P1>::StorageType, 302 typename internal::CallbackParamTraits<P2>::StorageType, 303 typename internal::CallbackParamTraits<P3>::StorageType, 304 typename internal::CallbackParamTraits<P4>::StorageType, 305 typename internal::CallbackParamTraits<P5>::StorageType)> 306 ::UnboundRunType> 307 Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4, 308 const P5& p5) { 309 // Typedefs for how to store and run the functor. 310 typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; 311 typedef typename internal::FunctorTraits<Functor>::RunType RunType; 312 313 // Use RunnableType::RunType instead of RunType above because our 314 // checks should below for bound references need to know what the actual 315 // functor is going to interpret the argument as. 316 typedef internal::FunctionTraits<typename RunnableType::RunType> 317 BoundFunctorTraits; 318 319 // Do not allow binding a non-const reference parameter. Non-const reference 320 // parameters are disallowed by the Google style guide. Also, binding a 321 // non-const reference parameter can make for subtle bugs because the 322 // invoked function will receive a reference to the stored copy of the 323 // argument and not the original. 324 COMPILE_ASSERT( 325 !(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value || 326 is_non_const_reference<typename BoundFunctorTraits::A2Type>::value || 327 is_non_const_reference<typename BoundFunctorTraits::A3Type>::value || 328 is_non_const_reference<typename BoundFunctorTraits::A4Type>::value || 329 is_non_const_reference<typename BoundFunctorTraits::A5Type>::value ), 330 do_not_bind_functions_with_nonconst_ref); 331 332 // For methods, we need to be careful for parameter 1. We do not require 333 // a scoped_refptr because BindState<> itself takes care of AddRef() for 334 // methods. We also disallow binding of an array as the method's target 335 // object. 336 COMPILE_ASSERT( 337 internal::HasIsMethodTag<RunnableType>::value || 338 !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value, 339 p1_is_refcounted_type_and_needs_scoped_refptr); 340 COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || 341 !is_array<P1>::value, 342 first_bound_argument_to_method_cannot_be_array); 343 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value, 344 p2_is_refcounted_type_and_needs_scoped_refptr); 345 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P3>::value, 346 p3_is_refcounted_type_and_needs_scoped_refptr); 347 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P4>::value, 348 p4_is_refcounted_type_and_needs_scoped_refptr); 349 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P5>::value, 350 p5_is_refcounted_type_and_needs_scoped_refptr); 351 typedef internal::BindState<RunnableType, RunType, 352 void(typename internal::CallbackParamTraits<P1>::StorageType, 353 typename internal::CallbackParamTraits<P2>::StorageType, 354 typename internal::CallbackParamTraits<P3>::StorageType, 355 typename internal::CallbackParamTraits<P4>::StorageType, 356 typename internal::CallbackParamTraits<P5>::StorageType)> BindState; 357 358 359 return Callback<typename BindState::UnboundRunType>( 360 new BindState(internal::MakeRunnable(functor), p1, p2, p3, p4, p5)); 361 } 362 363 template <typename Functor, typename P1, typename P2, typename P3, typename P4, 364 typename P5, typename P6> 365 base::Callback< 366 typename internal::BindState< 367 typename internal::FunctorTraits<Functor>::RunnableType, 368 typename internal::FunctorTraits<Functor>::RunType, 369 void(typename internal::CallbackParamTraits<P1>::StorageType, 370 typename internal::CallbackParamTraits<P2>::StorageType, 371 typename internal::CallbackParamTraits<P3>::StorageType, 372 typename internal::CallbackParamTraits<P4>::StorageType, 373 typename internal::CallbackParamTraits<P5>::StorageType, 374 typename internal::CallbackParamTraits<P6>::StorageType)> 375 ::UnboundRunType> 376 Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4, 377 const P5& p5, const P6& p6) { 378 // Typedefs for how to store and run the functor. 379 typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; 380 typedef typename internal::FunctorTraits<Functor>::RunType RunType; 381 382 // Use RunnableType::RunType instead of RunType above because our 383 // checks should below for bound references need to know what the actual 384 // functor is going to interpret the argument as. 385 typedef internal::FunctionTraits<typename RunnableType::RunType> 386 BoundFunctorTraits; 387 388 // Do not allow binding a non-const reference parameter. Non-const reference 389 // parameters are disallowed by the Google style guide. Also, binding a 390 // non-const reference parameter can make for subtle bugs because the 391 // invoked function will receive a reference to the stored copy of the 392 // argument and not the original. 393 COMPILE_ASSERT( 394 !(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value || 395 is_non_const_reference<typename BoundFunctorTraits::A2Type>::value || 396 is_non_const_reference<typename BoundFunctorTraits::A3Type>::value || 397 is_non_const_reference<typename BoundFunctorTraits::A4Type>::value || 398 is_non_const_reference<typename BoundFunctorTraits::A5Type>::value || 399 is_non_const_reference<typename BoundFunctorTraits::A6Type>::value ), 400 do_not_bind_functions_with_nonconst_ref); 401 402 // For methods, we need to be careful for parameter 1. We do not require 403 // a scoped_refptr because BindState<> itself takes care of AddRef() for 404 // methods. We also disallow binding of an array as the method's target 405 // object. 406 COMPILE_ASSERT( 407 internal::HasIsMethodTag<RunnableType>::value || 408 !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value, 409 p1_is_refcounted_type_and_needs_scoped_refptr); 410 COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || 411 !is_array<P1>::value, 412 first_bound_argument_to_method_cannot_be_array); 413 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value, 414 p2_is_refcounted_type_and_needs_scoped_refptr); 415 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P3>::value, 416 p3_is_refcounted_type_and_needs_scoped_refptr); 417 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P4>::value, 418 p4_is_refcounted_type_and_needs_scoped_refptr); 419 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P5>::value, 420 p5_is_refcounted_type_and_needs_scoped_refptr); 421 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P6>::value, 422 p6_is_refcounted_type_and_needs_scoped_refptr); 423 typedef internal::BindState<RunnableType, RunType, 424 void(typename internal::CallbackParamTraits<P1>::StorageType, 425 typename internal::CallbackParamTraits<P2>::StorageType, 426 typename internal::CallbackParamTraits<P3>::StorageType, 427 typename internal::CallbackParamTraits<P4>::StorageType, 428 typename internal::CallbackParamTraits<P5>::StorageType, 429 typename internal::CallbackParamTraits<P6>::StorageType)> BindState; 430 431 432 return Callback<typename BindState::UnboundRunType>( 433 new BindState(internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6)); 434 } 435 436 template <typename Functor, typename P1, typename P2, typename P3, typename P4, 437 typename P5, typename P6, typename P7> 438 base::Callback< 439 typename internal::BindState< 440 typename internal::FunctorTraits<Functor>::RunnableType, 441 typename internal::FunctorTraits<Functor>::RunType, 442 void(typename internal::CallbackParamTraits<P1>::StorageType, 443 typename internal::CallbackParamTraits<P2>::StorageType, 444 typename internal::CallbackParamTraits<P3>::StorageType, 445 typename internal::CallbackParamTraits<P4>::StorageType, 446 typename internal::CallbackParamTraits<P5>::StorageType, 447 typename internal::CallbackParamTraits<P6>::StorageType, 448 typename internal::CallbackParamTraits<P7>::StorageType)> 449 ::UnboundRunType> 450 Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4, 451 const P5& p5, const P6& p6, const P7& p7) { 452 // Typedefs for how to store and run the functor. 453 typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; 454 typedef typename internal::FunctorTraits<Functor>::RunType RunType; 455 456 // Use RunnableType::RunType instead of RunType above because our 457 // checks should below for bound references need to know what the actual 458 // functor is going to interpret the argument as. 459 typedef internal::FunctionTraits<typename RunnableType::RunType> 460 BoundFunctorTraits; 461 462 // Do not allow binding a non-const reference parameter. Non-const reference 463 // parameters are disallowed by the Google style guide. Also, binding a 464 // non-const reference parameter can make for subtle bugs because the 465 // invoked function will receive a reference to the stored copy of the 466 // argument and not the original. 467 COMPILE_ASSERT( 468 !(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value || 469 is_non_const_reference<typename BoundFunctorTraits::A2Type>::value || 470 is_non_const_reference<typename BoundFunctorTraits::A3Type>::value || 471 is_non_const_reference<typename BoundFunctorTraits::A4Type>::value || 472 is_non_const_reference<typename BoundFunctorTraits::A5Type>::value || 473 is_non_const_reference<typename BoundFunctorTraits::A6Type>::value || 474 is_non_const_reference<typename BoundFunctorTraits::A7Type>::value ), 475 do_not_bind_functions_with_nonconst_ref); 476 477 // For methods, we need to be careful for parameter 1. We do not require 478 // a scoped_refptr because BindState<> itself takes care of AddRef() for 479 // methods. We also disallow binding of an array as the method's target 480 // object. 481 COMPILE_ASSERT( 482 internal::HasIsMethodTag<RunnableType>::value || 483 !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value, 484 p1_is_refcounted_type_and_needs_scoped_refptr); 485 COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || 486 !is_array<P1>::value, 487 first_bound_argument_to_method_cannot_be_array); 488 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value, 489 p2_is_refcounted_type_and_needs_scoped_refptr); 490 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P3>::value, 491 p3_is_refcounted_type_and_needs_scoped_refptr); 492 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P4>::value, 493 p4_is_refcounted_type_and_needs_scoped_refptr); 494 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P5>::value, 495 p5_is_refcounted_type_and_needs_scoped_refptr); 496 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P6>::value, 497 p6_is_refcounted_type_and_needs_scoped_refptr); 498 COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P7>::value, 499 p7_is_refcounted_type_and_needs_scoped_refptr); 500 typedef internal::BindState<RunnableType, RunType, 501 void(typename internal::CallbackParamTraits<P1>::StorageType, 502 typename internal::CallbackParamTraits<P2>::StorageType, 503 typename internal::CallbackParamTraits<P3>::StorageType, 504 typename internal::CallbackParamTraits<P4>::StorageType, 505 typename internal::CallbackParamTraits<P5>::StorageType, 506 typename internal::CallbackParamTraits<P6>::StorageType, 507 typename internal::CallbackParamTraits<P7>::StorageType)> BindState; 508 509 510 return Callback<typename BindState::UnboundRunType>( 511 new BindState(internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6, 512 p7)); 513 } 514 515 } // namespace base 516 517 #endif // BASE_BIND_H_ 518