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_H_ | 5 #ifndef BASE_CALLBACK_H_ |
6 #define BASE_CALLBACK_H_ | 6 #define BASE_CALLBACK_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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // An UnboundMethod is a wrapper for a method where the actual object is | 203 // An UnboundMethod is a wrapper for a method where the actual object is |
204 // provided at Run dispatch time. | 204 // provided at Run dispatch time. |
205 template <class T, class Method, class Params> | 205 template <class T, class Method, class Params> |
206 class UnboundMethod { | 206 class UnboundMethod { |
207 public: | 207 public: |
208 UnboundMethod(Method m, const Params& p) : m_(m), p_(p) { | 208 UnboundMethod(Method m, const Params& p) : m_(m), p_(p) { |
209 COMPILE_ASSERT( | 209 COMPILE_ASSERT((MethodUsesScopedRefptrCorrectly<Method, Params>::value), |
210 (base::internal::ParamsUseScopedRefptrCorrectly<Params>::value), | 210 badunboundmethodparams); |
211 badunboundmethodparams); | |
212 } | 211 } |
213 void Run(T* obj) const { | 212 void Run(T* obj) const { |
214 DispatchToMethod(obj, m_, p_); | 213 DispatchToMethod(obj, m_, p_); |
215 } | 214 } |
216 private: | 215 private: |
217 Method m_; | 216 Method m_; |
218 Params p_; | 217 Params p_; |
219 }; | 218 }; |
220 | 219 |
221 // Return value implementation with no args. | 220 // Return value implementation with no args. |
(...skipping 23 matching lines...) Expand all Loading... |
245 }; | 244 }; |
246 | 245 |
247 template <class T, typename ReturnValue> | 246 template <class T, typename ReturnValue> |
248 typename CallbackWithReturnValue<ReturnValue>::Type* | 247 typename CallbackWithReturnValue<ReturnValue>::Type* |
249 NewCallbackWithReturnValue(T* object, ReturnValue (T::*method)()) { | 248 NewCallbackWithReturnValue(T* object, ReturnValue (T::*method)()) { |
250 return new CallbackWithReturnValueImpl<T, ReturnValue (T::*)(), ReturnValue>( | 249 return new CallbackWithReturnValueImpl<T, ReturnValue (T::*)(), ReturnValue>( |
251 object, method); | 250 object, method); |
252 } | 251 } |
253 | 252 |
254 #endif // BASE_CALLBACK_H | 253 #endif // BASE_CALLBACK_H |
OLD | NEW |