OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/callback_internal.h" | 9 #include "base/callback_internal.h" |
10 #include "base/template_util.h" | 10 #include "base/template_util.h" |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 PolymorphicInvoke invoke_func = | 379 PolymorphicInvoke invoke_func = |
380 &internal::BindState<Runnable, BindRunType, BoundArgsType...> | 380 &internal::BindState<Runnable, BindRunType, BoundArgsType...> |
381 ::InvokerType::Run; | 381 ::InvokerType::Run; |
382 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); | 382 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); |
383 } | 383 } |
384 | 384 |
385 bool Equals(const Callback& other) const { | 385 bool Equals(const Callback& other) const { |
386 return CallbackBase::Equals(other); | 386 return CallbackBase::Equals(other); |
387 } | 387 } |
388 | 388 |
389 R Run(typename internal::CallbackParamTraits<Args>::ForwardType... args) | 389 R Run(Args... args) const { |
dcheng
2016/03/02 00:25:45
So this costs an extra copy now, since we don't ha
tzik
2016/03/02 01:04:21
Acknowledged. Updating.
tzik
2016/03/02 12:44:51
Done.
| |
390 const { | |
391 PolymorphicInvoke f = | 390 PolymorphicInvoke f = |
392 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | 391 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); |
393 | 392 return f(bind_state_.get(), std::forward<Args>(args)...); |
394 return f(bind_state_.get(), internal::CallbackForward(args)...); | |
395 } | 393 } |
396 | 394 |
397 private: | 395 private: |
398 using PolymorphicInvoke = | 396 using PolymorphicInvoke = R (*)(internal::BindStateBase*, Args&&...); |
399 R(*)(internal::BindStateBase*, | |
400 typename internal::CallbackParamTraits<Args>::ForwardType...); | |
401 }; | 397 }; |
402 | 398 |
403 } // namespace base | 399 } // namespace base |
404 | 400 |
405 #endif // BASE_CALLBACK_H_ | 401 #endif // BASE_CALLBACK_H_ |
OLD | NEW |