1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/sandbox/chromium/base/bind.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,517 @@ 1.4 +// This file was GENERATED by command: 1.5 +// pump.py bind.h.pump 1.6 +// DO NOT EDIT BY HAND!!! 1.7 + 1.8 + 1.9 +// Copyright (c) 2011 The Chromium Authors. All rights reserved. 1.10 +// Use of this source code is governed by a BSD-style license that can be 1.11 +// found in the LICENSE file. 1.12 + 1.13 +#ifndef BASE_BIND_H_ 1.14 +#define BASE_BIND_H_ 1.15 + 1.16 +#include "base/bind_internal.h" 1.17 +#include "base/callback_internal.h" 1.18 + 1.19 +// ----------------------------------------------------------------------------- 1.20 +// Usage documentation 1.21 +// ----------------------------------------------------------------------------- 1.22 +// 1.23 +// See base/callback.h for documentation. 1.24 +// 1.25 +// 1.26 +// ----------------------------------------------------------------------------- 1.27 +// Implementation notes 1.28 +// ----------------------------------------------------------------------------- 1.29 +// 1.30 +// If you're reading the implementation, before proceeding further, you should 1.31 +// read the top comment of base/bind_internal.h for a definition of common 1.32 +// terms and concepts. 1.33 +// 1.34 +// RETURN TYPES 1.35 +// 1.36 +// Though Bind()'s result is meant to be stored in a Callback<> type, it 1.37 +// cannot actually return the exact type without requiring a large amount 1.38 +// of extra template specializations. The problem is that in order to 1.39 +// discern the correct specialization of Callback<>, Bind would need to 1.40 +// unwrap the function signature to determine the signature's arity, and 1.41 +// whether or not it is a method. 1.42 +// 1.43 +// Each unique combination of (arity, function_type, num_prebound) where 1.44 +// function_type is one of {function, method, const_method} would require 1.45 +// one specialization. We eventually have to do a similar number of 1.46 +// specializations anyways in the implementation (see the Invoker<>, 1.47 +// classes). However, it is avoidable in Bind if we return the result 1.48 +// via an indirection like we do below. 1.49 +// 1.50 +// TODO(ajwong): We might be able to avoid this now, but need to test. 1.51 +// 1.52 +// It is possible to move most of the COMPILE_ASSERT asserts into BindState<>, 1.53 +// but it feels a little nicer to have the asserts here so people do not 1.54 +// need to crack open bind_internal.h. On the other hand, it makes Bind() 1.55 +// harder to read. 1.56 + 1.57 +namespace base { 1.58 + 1.59 +template <typename Functor> 1.60 +base::Callback< 1.61 + typename internal::BindState< 1.62 + typename internal::FunctorTraits<Functor>::RunnableType, 1.63 + typename internal::FunctorTraits<Functor>::RunType, 1.64 + void()> 1.65 + ::UnboundRunType> 1.66 +Bind(Functor functor) { 1.67 + // Typedefs for how to store and run the functor. 1.68 + typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; 1.69 + typedef typename internal::FunctorTraits<Functor>::RunType RunType; 1.70 + 1.71 + // Use RunnableType::RunType instead of RunType above because our 1.72 + // checks should below for bound references need to know what the actual 1.73 + // functor is going to interpret the argument as. 1.74 + typedef internal::FunctionTraits<typename RunnableType::RunType> 1.75 + BoundFunctorTraits; 1.76 + 1.77 + typedef internal::BindState<RunnableType, RunType, void()> BindState; 1.78 + 1.79 + 1.80 + return Callback<typename BindState::UnboundRunType>( 1.81 + new BindState(internal::MakeRunnable(functor))); 1.82 +} 1.83 + 1.84 +template <typename Functor, typename P1> 1.85 +base::Callback< 1.86 + typename internal::BindState< 1.87 + typename internal::FunctorTraits<Functor>::RunnableType, 1.88 + typename internal::FunctorTraits<Functor>::RunType, 1.89 + void(typename internal::CallbackParamTraits<P1>::StorageType)> 1.90 + ::UnboundRunType> 1.91 +Bind(Functor functor, const P1& p1) { 1.92 + // Typedefs for how to store and run the functor. 1.93 + typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; 1.94 + typedef typename internal::FunctorTraits<Functor>::RunType RunType; 1.95 + 1.96 + // Use RunnableType::RunType instead of RunType above because our 1.97 + // checks should below for bound references need to know what the actual 1.98 + // functor is going to interpret the argument as. 1.99 + typedef internal::FunctionTraits<typename RunnableType::RunType> 1.100 + BoundFunctorTraits; 1.101 + 1.102 + // Do not allow binding a non-const reference parameter. Non-const reference 1.103 + // parameters are disallowed by the Google style guide. Also, binding a 1.104 + // non-const reference parameter can make for subtle bugs because the 1.105 + // invoked function will receive a reference to the stored copy of the 1.106 + // argument and not the original. 1.107 + COMPILE_ASSERT( 1.108 + !(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ), 1.109 + do_not_bind_functions_with_nonconst_ref); 1.110 + 1.111 + // For methods, we need to be careful for parameter 1. We do not require 1.112 + // a scoped_refptr because BindState<> itself takes care of AddRef() for 1.113 + // methods. We also disallow binding of an array as the method's target 1.114 + // object. 1.115 + COMPILE_ASSERT( 1.116 + internal::HasIsMethodTag<RunnableType>::value || 1.117 + !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value, 1.118 + p1_is_refcounted_type_and_needs_scoped_refptr); 1.119 + COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || 1.120 + !is_array<P1>::value, 1.121 + first_bound_argument_to_method_cannot_be_array); 1.122 + typedef internal::BindState<RunnableType, RunType, 1.123 + void(typename internal::CallbackParamTraits<P1>::StorageType)> BindState; 1.124 + 1.125 + 1.126 + return Callback<typename BindState::UnboundRunType>( 1.127 + new BindState(internal::MakeRunnable(functor), p1)); 1.128 +} 1.129 + 1.130 +template <typename Functor, typename P1, typename P2> 1.131 +base::Callback< 1.132 + typename internal::BindState< 1.133 + typename internal::FunctorTraits<Functor>::RunnableType, 1.134 + typename internal::FunctorTraits<Functor>::RunType, 1.135 + void(typename internal::CallbackParamTraits<P1>::StorageType, 1.136 + typename internal::CallbackParamTraits<P2>::StorageType)> 1.137 + ::UnboundRunType> 1.138 +Bind(Functor functor, const P1& p1, const P2& p2) { 1.139 + // Typedefs for how to store and run the functor. 1.140 + typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; 1.141 + typedef typename internal::FunctorTraits<Functor>::RunType RunType; 1.142 + 1.143 + // Use RunnableType::RunType instead of RunType above because our 1.144 + // checks should below for bound references need to know what the actual 1.145 + // functor is going to interpret the argument as. 1.146 + typedef internal::FunctionTraits<typename RunnableType::RunType> 1.147 + BoundFunctorTraits; 1.148 + 1.149 + // Do not allow binding a non-const reference parameter. Non-const reference 1.150 + // parameters are disallowed by the Google style guide. Also, binding a 1.151 + // non-const reference parameter can make for subtle bugs because the 1.152 + // invoked function will receive a reference to the stored copy of the 1.153 + // argument and not the original. 1.154 + COMPILE_ASSERT( 1.155 + !(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value || 1.156 + is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ), 1.157 + do_not_bind_functions_with_nonconst_ref); 1.158 + 1.159 + // For methods, we need to be careful for parameter 1. We do not require 1.160 + // a scoped_refptr because BindState<> itself takes care of AddRef() for 1.161 + // methods. We also disallow binding of an array as the method's target 1.162 + // object. 1.163 + COMPILE_ASSERT( 1.164 + internal::HasIsMethodTag<RunnableType>::value || 1.165 + !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value, 1.166 + p1_is_refcounted_type_and_needs_scoped_refptr); 1.167 + COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || 1.168 + !is_array<P1>::value, 1.169 + first_bound_argument_to_method_cannot_be_array); 1.170 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value, 1.171 + p2_is_refcounted_type_and_needs_scoped_refptr); 1.172 + typedef internal::BindState<RunnableType, RunType, 1.173 + void(typename internal::CallbackParamTraits<P1>::StorageType, 1.174 + typename internal::CallbackParamTraits<P2>::StorageType)> BindState; 1.175 + 1.176 + 1.177 + return Callback<typename BindState::UnboundRunType>( 1.178 + new BindState(internal::MakeRunnable(functor), p1, p2)); 1.179 +} 1.180 + 1.181 +template <typename Functor, typename P1, typename P2, typename P3> 1.182 +base::Callback< 1.183 + typename internal::BindState< 1.184 + typename internal::FunctorTraits<Functor>::RunnableType, 1.185 + typename internal::FunctorTraits<Functor>::RunType, 1.186 + void(typename internal::CallbackParamTraits<P1>::StorageType, 1.187 + typename internal::CallbackParamTraits<P2>::StorageType, 1.188 + typename internal::CallbackParamTraits<P3>::StorageType)> 1.189 + ::UnboundRunType> 1.190 +Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3) { 1.191 + // Typedefs for how to store and run the functor. 1.192 + typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; 1.193 + typedef typename internal::FunctorTraits<Functor>::RunType RunType; 1.194 + 1.195 + // Use RunnableType::RunType instead of RunType above because our 1.196 + // checks should below for bound references need to know what the actual 1.197 + // functor is going to interpret the argument as. 1.198 + typedef internal::FunctionTraits<typename RunnableType::RunType> 1.199 + BoundFunctorTraits; 1.200 + 1.201 + // Do not allow binding a non-const reference parameter. Non-const reference 1.202 + // parameters are disallowed by the Google style guide. Also, binding a 1.203 + // non-const reference parameter can make for subtle bugs because the 1.204 + // invoked function will receive a reference to the stored copy of the 1.205 + // argument and not the original. 1.206 + COMPILE_ASSERT( 1.207 + !(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value || 1.208 + is_non_const_reference<typename BoundFunctorTraits::A2Type>::value || 1.209 + is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ), 1.210 + do_not_bind_functions_with_nonconst_ref); 1.211 + 1.212 + // For methods, we need to be careful for parameter 1. We do not require 1.213 + // a scoped_refptr because BindState<> itself takes care of AddRef() for 1.214 + // methods. We also disallow binding of an array as the method's target 1.215 + // object. 1.216 + COMPILE_ASSERT( 1.217 + internal::HasIsMethodTag<RunnableType>::value || 1.218 + !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value, 1.219 + p1_is_refcounted_type_and_needs_scoped_refptr); 1.220 + COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || 1.221 + !is_array<P1>::value, 1.222 + first_bound_argument_to_method_cannot_be_array); 1.223 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value, 1.224 + p2_is_refcounted_type_and_needs_scoped_refptr); 1.225 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P3>::value, 1.226 + p3_is_refcounted_type_and_needs_scoped_refptr); 1.227 + typedef internal::BindState<RunnableType, RunType, 1.228 + void(typename internal::CallbackParamTraits<P1>::StorageType, 1.229 + typename internal::CallbackParamTraits<P2>::StorageType, 1.230 + typename internal::CallbackParamTraits<P3>::StorageType)> BindState; 1.231 + 1.232 + 1.233 + return Callback<typename BindState::UnboundRunType>( 1.234 + new BindState(internal::MakeRunnable(functor), p1, p2, p3)); 1.235 +} 1.236 + 1.237 +template <typename Functor, typename P1, typename P2, typename P3, typename P4> 1.238 +base::Callback< 1.239 + typename internal::BindState< 1.240 + typename internal::FunctorTraits<Functor>::RunnableType, 1.241 + typename internal::FunctorTraits<Functor>::RunType, 1.242 + void(typename internal::CallbackParamTraits<P1>::StorageType, 1.243 + typename internal::CallbackParamTraits<P2>::StorageType, 1.244 + typename internal::CallbackParamTraits<P3>::StorageType, 1.245 + typename internal::CallbackParamTraits<P4>::StorageType)> 1.246 + ::UnboundRunType> 1.247 +Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4) { 1.248 + // Typedefs for how to store and run the functor. 1.249 + typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; 1.250 + typedef typename internal::FunctorTraits<Functor>::RunType RunType; 1.251 + 1.252 + // Use RunnableType::RunType instead of RunType above because our 1.253 + // checks should below for bound references need to know what the actual 1.254 + // functor is going to interpret the argument as. 1.255 + typedef internal::FunctionTraits<typename RunnableType::RunType> 1.256 + BoundFunctorTraits; 1.257 + 1.258 + // Do not allow binding a non-const reference parameter. Non-const reference 1.259 + // parameters are disallowed by the Google style guide. Also, binding a 1.260 + // non-const reference parameter can make for subtle bugs because the 1.261 + // invoked function will receive a reference to the stored copy of the 1.262 + // argument and not the original. 1.263 + COMPILE_ASSERT( 1.264 + !(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value || 1.265 + is_non_const_reference<typename BoundFunctorTraits::A2Type>::value || 1.266 + is_non_const_reference<typename BoundFunctorTraits::A3Type>::value || 1.267 + is_non_const_reference<typename BoundFunctorTraits::A4Type>::value ), 1.268 + do_not_bind_functions_with_nonconst_ref); 1.269 + 1.270 + // For methods, we need to be careful for parameter 1. We do not require 1.271 + // a scoped_refptr because BindState<> itself takes care of AddRef() for 1.272 + // methods. We also disallow binding of an array as the method's target 1.273 + // object. 1.274 + COMPILE_ASSERT( 1.275 + internal::HasIsMethodTag<RunnableType>::value || 1.276 + !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value, 1.277 + p1_is_refcounted_type_and_needs_scoped_refptr); 1.278 + COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || 1.279 + !is_array<P1>::value, 1.280 + first_bound_argument_to_method_cannot_be_array); 1.281 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value, 1.282 + p2_is_refcounted_type_and_needs_scoped_refptr); 1.283 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P3>::value, 1.284 + p3_is_refcounted_type_and_needs_scoped_refptr); 1.285 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P4>::value, 1.286 + p4_is_refcounted_type_and_needs_scoped_refptr); 1.287 + typedef internal::BindState<RunnableType, RunType, 1.288 + void(typename internal::CallbackParamTraits<P1>::StorageType, 1.289 + typename internal::CallbackParamTraits<P2>::StorageType, 1.290 + typename internal::CallbackParamTraits<P3>::StorageType, 1.291 + typename internal::CallbackParamTraits<P4>::StorageType)> BindState; 1.292 + 1.293 + 1.294 + return Callback<typename BindState::UnboundRunType>( 1.295 + new BindState(internal::MakeRunnable(functor), p1, p2, p3, p4)); 1.296 +} 1.297 + 1.298 +template <typename Functor, typename P1, typename P2, typename P3, typename P4, 1.299 + typename P5> 1.300 +base::Callback< 1.301 + typename internal::BindState< 1.302 + typename internal::FunctorTraits<Functor>::RunnableType, 1.303 + typename internal::FunctorTraits<Functor>::RunType, 1.304 + void(typename internal::CallbackParamTraits<P1>::StorageType, 1.305 + typename internal::CallbackParamTraits<P2>::StorageType, 1.306 + typename internal::CallbackParamTraits<P3>::StorageType, 1.307 + typename internal::CallbackParamTraits<P4>::StorageType, 1.308 + typename internal::CallbackParamTraits<P5>::StorageType)> 1.309 + ::UnboundRunType> 1.310 +Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4, 1.311 + const P5& p5) { 1.312 + // Typedefs for how to store and run the functor. 1.313 + typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; 1.314 + typedef typename internal::FunctorTraits<Functor>::RunType RunType; 1.315 + 1.316 + // Use RunnableType::RunType instead of RunType above because our 1.317 + // checks should below for bound references need to know what the actual 1.318 + // functor is going to interpret the argument as. 1.319 + typedef internal::FunctionTraits<typename RunnableType::RunType> 1.320 + BoundFunctorTraits; 1.321 + 1.322 + // Do not allow binding a non-const reference parameter. Non-const reference 1.323 + // parameters are disallowed by the Google style guide. Also, binding a 1.324 + // non-const reference parameter can make for subtle bugs because the 1.325 + // invoked function will receive a reference to the stored copy of the 1.326 + // argument and not the original. 1.327 + COMPILE_ASSERT( 1.328 + !(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value || 1.329 + is_non_const_reference<typename BoundFunctorTraits::A2Type>::value || 1.330 + is_non_const_reference<typename BoundFunctorTraits::A3Type>::value || 1.331 + is_non_const_reference<typename BoundFunctorTraits::A4Type>::value || 1.332 + is_non_const_reference<typename BoundFunctorTraits::A5Type>::value ), 1.333 + do_not_bind_functions_with_nonconst_ref); 1.334 + 1.335 + // For methods, we need to be careful for parameter 1. We do not require 1.336 + // a scoped_refptr because BindState<> itself takes care of AddRef() for 1.337 + // methods. We also disallow binding of an array as the method's target 1.338 + // object. 1.339 + COMPILE_ASSERT( 1.340 + internal::HasIsMethodTag<RunnableType>::value || 1.341 + !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value, 1.342 + p1_is_refcounted_type_and_needs_scoped_refptr); 1.343 + COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || 1.344 + !is_array<P1>::value, 1.345 + first_bound_argument_to_method_cannot_be_array); 1.346 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value, 1.347 + p2_is_refcounted_type_and_needs_scoped_refptr); 1.348 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P3>::value, 1.349 + p3_is_refcounted_type_and_needs_scoped_refptr); 1.350 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P4>::value, 1.351 + p4_is_refcounted_type_and_needs_scoped_refptr); 1.352 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P5>::value, 1.353 + p5_is_refcounted_type_and_needs_scoped_refptr); 1.354 + typedef internal::BindState<RunnableType, RunType, 1.355 + void(typename internal::CallbackParamTraits<P1>::StorageType, 1.356 + typename internal::CallbackParamTraits<P2>::StorageType, 1.357 + typename internal::CallbackParamTraits<P3>::StorageType, 1.358 + typename internal::CallbackParamTraits<P4>::StorageType, 1.359 + typename internal::CallbackParamTraits<P5>::StorageType)> BindState; 1.360 + 1.361 + 1.362 + return Callback<typename BindState::UnboundRunType>( 1.363 + new BindState(internal::MakeRunnable(functor), p1, p2, p3, p4, p5)); 1.364 +} 1.365 + 1.366 +template <typename Functor, typename P1, typename P2, typename P3, typename P4, 1.367 + typename P5, typename P6> 1.368 +base::Callback< 1.369 + typename internal::BindState< 1.370 + typename internal::FunctorTraits<Functor>::RunnableType, 1.371 + typename internal::FunctorTraits<Functor>::RunType, 1.372 + void(typename internal::CallbackParamTraits<P1>::StorageType, 1.373 + typename internal::CallbackParamTraits<P2>::StorageType, 1.374 + typename internal::CallbackParamTraits<P3>::StorageType, 1.375 + typename internal::CallbackParamTraits<P4>::StorageType, 1.376 + typename internal::CallbackParamTraits<P5>::StorageType, 1.377 + typename internal::CallbackParamTraits<P6>::StorageType)> 1.378 + ::UnboundRunType> 1.379 +Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4, 1.380 + const P5& p5, const P6& p6) { 1.381 + // Typedefs for how to store and run the functor. 1.382 + typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; 1.383 + typedef typename internal::FunctorTraits<Functor>::RunType RunType; 1.384 + 1.385 + // Use RunnableType::RunType instead of RunType above because our 1.386 + // checks should below for bound references need to know what the actual 1.387 + // functor is going to interpret the argument as. 1.388 + typedef internal::FunctionTraits<typename RunnableType::RunType> 1.389 + BoundFunctorTraits; 1.390 + 1.391 + // Do not allow binding a non-const reference parameter. Non-const reference 1.392 + // parameters are disallowed by the Google style guide. Also, binding a 1.393 + // non-const reference parameter can make for subtle bugs because the 1.394 + // invoked function will receive a reference to the stored copy of the 1.395 + // argument and not the original. 1.396 + COMPILE_ASSERT( 1.397 + !(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value || 1.398 + is_non_const_reference<typename BoundFunctorTraits::A2Type>::value || 1.399 + is_non_const_reference<typename BoundFunctorTraits::A3Type>::value || 1.400 + is_non_const_reference<typename BoundFunctorTraits::A4Type>::value || 1.401 + is_non_const_reference<typename BoundFunctorTraits::A5Type>::value || 1.402 + is_non_const_reference<typename BoundFunctorTraits::A6Type>::value ), 1.403 + do_not_bind_functions_with_nonconst_ref); 1.404 + 1.405 + // For methods, we need to be careful for parameter 1. We do not require 1.406 + // a scoped_refptr because BindState<> itself takes care of AddRef() for 1.407 + // methods. We also disallow binding of an array as the method's target 1.408 + // object. 1.409 + COMPILE_ASSERT( 1.410 + internal::HasIsMethodTag<RunnableType>::value || 1.411 + !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value, 1.412 + p1_is_refcounted_type_and_needs_scoped_refptr); 1.413 + COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || 1.414 + !is_array<P1>::value, 1.415 + first_bound_argument_to_method_cannot_be_array); 1.416 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value, 1.417 + p2_is_refcounted_type_and_needs_scoped_refptr); 1.418 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P3>::value, 1.419 + p3_is_refcounted_type_and_needs_scoped_refptr); 1.420 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P4>::value, 1.421 + p4_is_refcounted_type_and_needs_scoped_refptr); 1.422 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P5>::value, 1.423 + p5_is_refcounted_type_and_needs_scoped_refptr); 1.424 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P6>::value, 1.425 + p6_is_refcounted_type_and_needs_scoped_refptr); 1.426 + typedef internal::BindState<RunnableType, RunType, 1.427 + void(typename internal::CallbackParamTraits<P1>::StorageType, 1.428 + typename internal::CallbackParamTraits<P2>::StorageType, 1.429 + typename internal::CallbackParamTraits<P3>::StorageType, 1.430 + typename internal::CallbackParamTraits<P4>::StorageType, 1.431 + typename internal::CallbackParamTraits<P5>::StorageType, 1.432 + typename internal::CallbackParamTraits<P6>::StorageType)> BindState; 1.433 + 1.434 + 1.435 + return Callback<typename BindState::UnboundRunType>( 1.436 + new BindState(internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6)); 1.437 +} 1.438 + 1.439 +template <typename Functor, typename P1, typename P2, typename P3, typename P4, 1.440 + typename P5, typename P6, typename P7> 1.441 +base::Callback< 1.442 + typename internal::BindState< 1.443 + typename internal::FunctorTraits<Functor>::RunnableType, 1.444 + typename internal::FunctorTraits<Functor>::RunType, 1.445 + void(typename internal::CallbackParamTraits<P1>::StorageType, 1.446 + typename internal::CallbackParamTraits<P2>::StorageType, 1.447 + typename internal::CallbackParamTraits<P3>::StorageType, 1.448 + typename internal::CallbackParamTraits<P4>::StorageType, 1.449 + typename internal::CallbackParamTraits<P5>::StorageType, 1.450 + typename internal::CallbackParamTraits<P6>::StorageType, 1.451 + typename internal::CallbackParamTraits<P7>::StorageType)> 1.452 + ::UnboundRunType> 1.453 +Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4, 1.454 + const P5& p5, const P6& p6, const P7& p7) { 1.455 + // Typedefs for how to store and run the functor. 1.456 + typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType; 1.457 + typedef typename internal::FunctorTraits<Functor>::RunType RunType; 1.458 + 1.459 + // Use RunnableType::RunType instead of RunType above because our 1.460 + // checks should below for bound references need to know what the actual 1.461 + // functor is going to interpret the argument as. 1.462 + typedef internal::FunctionTraits<typename RunnableType::RunType> 1.463 + BoundFunctorTraits; 1.464 + 1.465 + // Do not allow binding a non-const reference parameter. Non-const reference 1.466 + // parameters are disallowed by the Google style guide. Also, binding a 1.467 + // non-const reference parameter can make for subtle bugs because the 1.468 + // invoked function will receive a reference to the stored copy of the 1.469 + // argument and not the original. 1.470 + COMPILE_ASSERT( 1.471 + !(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value || 1.472 + is_non_const_reference<typename BoundFunctorTraits::A2Type>::value || 1.473 + is_non_const_reference<typename BoundFunctorTraits::A3Type>::value || 1.474 + is_non_const_reference<typename BoundFunctorTraits::A4Type>::value || 1.475 + is_non_const_reference<typename BoundFunctorTraits::A5Type>::value || 1.476 + is_non_const_reference<typename BoundFunctorTraits::A6Type>::value || 1.477 + is_non_const_reference<typename BoundFunctorTraits::A7Type>::value ), 1.478 + do_not_bind_functions_with_nonconst_ref); 1.479 + 1.480 + // For methods, we need to be careful for parameter 1. We do not require 1.481 + // a scoped_refptr because BindState<> itself takes care of AddRef() for 1.482 + // methods. We also disallow binding of an array as the method's target 1.483 + // object. 1.484 + COMPILE_ASSERT( 1.485 + internal::HasIsMethodTag<RunnableType>::value || 1.486 + !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value, 1.487 + p1_is_refcounted_type_and_needs_scoped_refptr); 1.488 + COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value || 1.489 + !is_array<P1>::value, 1.490 + first_bound_argument_to_method_cannot_be_array); 1.491 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value, 1.492 + p2_is_refcounted_type_and_needs_scoped_refptr); 1.493 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P3>::value, 1.494 + p3_is_refcounted_type_and_needs_scoped_refptr); 1.495 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P4>::value, 1.496 + p4_is_refcounted_type_and_needs_scoped_refptr); 1.497 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P5>::value, 1.498 + p5_is_refcounted_type_and_needs_scoped_refptr); 1.499 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P6>::value, 1.500 + p6_is_refcounted_type_and_needs_scoped_refptr); 1.501 + COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P7>::value, 1.502 + p7_is_refcounted_type_and_needs_scoped_refptr); 1.503 + typedef internal::BindState<RunnableType, RunType, 1.504 + void(typename internal::CallbackParamTraits<P1>::StorageType, 1.505 + typename internal::CallbackParamTraits<P2>::StorageType, 1.506 + typename internal::CallbackParamTraits<P3>::StorageType, 1.507 + typename internal::CallbackParamTraits<P4>::StorageType, 1.508 + typename internal::CallbackParamTraits<P5>::StorageType, 1.509 + typename internal::CallbackParamTraits<P6>::StorageType, 1.510 + typename internal::CallbackParamTraits<P7>::StorageType)> BindState; 1.511 + 1.512 + 1.513 + return Callback<typename BindState::UnboundRunType>( 1.514 + new BindState(internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6, 1.515 + p7)); 1.516 +} 1.517 + 1.518 +} // namespace base 1.519 + 1.520 +#endif // BASE_BIND_H_