OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_CALLBACK_OLD_H_ | 5 #ifndef BASE_CALLBACK_OLD_H_ |
6 #define BASE_CALLBACK_OLD_H_ | 6 #define BASE_CALLBACK_OLD_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/tuple.h" | 9 #include "base/tuple.h" |
10 #include "base/raw_scoped_refptr_mismatch_checker.h" | 10 #include "base/raw_scoped_refptr_mismatch_checker.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 template <class T, typename Arg1, typename Arg2, | 194 template <class T, typename Arg1, typename Arg2, |
195 typename Arg3, typename Arg4, typename Arg5> | 195 typename Arg3, typename Arg4, typename Arg5> |
196 typename Callback5<Arg1, Arg2, Arg3, Arg4, Arg5>::Type* NewCallback( | 196 typename Callback5<Arg1, Arg2, Arg3, Arg4, Arg5>::Type* NewCallback( |
197 T* object, | 197 T* object, |
198 void (T::*method)(Arg1, Arg2, Arg3, Arg4, Arg5)) { | 198 void (T::*method)(Arg1, Arg2, Arg3, Arg4, Arg5)) { |
199 return new CallbackImpl<T, void (T::*)(Arg1, Arg2, Arg3, Arg4, Arg5), | 199 return new CallbackImpl<T, void (T::*)(Arg1, Arg2, Arg3, Arg4, Arg5), |
200 Tuple5<Arg1, Arg2, Arg3, Arg4, Arg5> >(object, method); | 200 Tuple5<Arg1, Arg2, Arg3, Arg4, Arg5> >(object, method); |
201 } | 201 } |
202 | 202 |
| 203 // 6-arg implementation |
| 204 template <typename Arg1, typename Arg2, typename Arg3, |
| 205 typename Arg4, typename Arg5, typename Arg6> |
| 206 struct Callback6 { |
| 207 typedef CallbackRunner<Tuple6<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6> > Type; |
| 208 }; |
| 209 |
| 210 template <class T, typename Arg1, typename Arg2, typename Arg3, |
| 211 typename Arg4, typename Arg5, typename Arg6> |
| 212 typename Callback6<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>::Type* NewCallback( |
| 213 T* object, |
| 214 void (T::*method)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)) { |
| 215 return new CallbackImpl<T, void (T::*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6), |
| 216 Tuple6<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6> >(object, method); |
| 217 } |
| 218 |
203 // An UnboundMethod is a wrapper for a method where the actual object is | 219 // An UnboundMethod is a wrapper for a method where the actual object is |
204 // provided at Run dispatch time. | 220 // provided at Run dispatch time. |
205 template <class T, class Method, class Params> | 221 template <class T, class Method, class Params> |
206 class UnboundMethod { | 222 class UnboundMethod { |
207 public: | 223 public: |
208 UnboundMethod(Method m, const Params& p) : m_(m), p_(p) { | 224 UnboundMethod(Method m, const Params& p) : m_(m), p_(p) { |
209 COMPILE_ASSERT( | 225 COMPILE_ASSERT( |
210 (base::internal::ParamsUseScopedRefptrCorrectly<Params>::value), | 226 (base::internal::ParamsUseScopedRefptrCorrectly<Params>::value), |
211 badunboundmethodparams); | 227 badunboundmethodparams); |
212 } | 228 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 }; | 261 }; |
246 | 262 |
247 template <class T, typename ReturnValue> | 263 template <class T, typename ReturnValue> |
248 typename CallbackWithReturnValue<ReturnValue>::Type* | 264 typename CallbackWithReturnValue<ReturnValue>::Type* |
249 NewCallbackWithReturnValue(T* object, ReturnValue (T::*method)()) { | 265 NewCallbackWithReturnValue(T* object, ReturnValue (T::*method)()) { |
250 return new CallbackWithReturnValueImpl<T, ReturnValue (T::*)(), ReturnValue>( | 266 return new CallbackWithReturnValueImpl<T, ReturnValue (T::*)(), ReturnValue>( |
251 object, method); | 267 object, method); |
252 } | 268 } |
253 | 269 |
254 #endif // BASE_CALLBACK_OLD_H_ | 270 #endif // BASE_CALLBACK_OLD_H_ |
OLD | NEW |