Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2911)

Unified Diff: base/callback.h

Issue 2034633002: Decouple Invoker from BindState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more inline Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/callback.h
diff --git a/base/callback.h b/base/callback.h
index abb907bef950e2303f51f26304a8bbbb6e8fdf92..f2859104be11150410f2eb25fa5c2fe9f349708a 100644
--- a/base/callback.h
+++ b/base/callback.h
@@ -345,31 +345,23 @@
// please include "base/callback_forward.h" instead.
namespace base {
-namespace internal {
-template <typename Runnable, typename RunType, typename... BoundArgsType>
-struct BindState;
-} // namespace internal
template <typename R, typename... Args, internal::CopyMode copy_mode>
class Callback<R(Args...), copy_mode>
: public internal::CallbackBase<copy_mode> {
+ private:
+ using PolymorphicInvoke = R (*)(internal::BindStateBase*, Args&&...);
public:
+
// MSVC 2013 doesn't support Type Alias of function types.
// Revisit this after we update it to newer version.
Nico 2016/06/02 17:27:44 we could revisit this now
tzik 2016/06/03 13:29:52 Let me do it in a separate CL.
typedef R RunType(Args...);
Callback() : internal::CallbackBase<copy_mode>(nullptr) {}
- template <typename Runnable, typename BindRunType, typename... BoundArgs>
- explicit Callback(
- internal::BindState<Runnable, BindRunType, BoundArgs...>* bind_state)
+ Callback(internal::BindStateBase* bind_state,
+ PolymorphicInvoke invoke_func)
: internal::CallbackBase<copy_mode>(bind_state) {
- // Force the assignment to a local variable of PolymorphicInvoke
- // so the compiler will typecheck that the passed in Run() method has
- // the correct type.
- PolymorphicInvoke invoke_func =
- &internal::BindState<Runnable, BindRunType, BoundArgs...>
- ::InvokerType::Run;
using InvokeFuncStorage =
typename internal::CallbackBase<copy_mode>::InvokeFuncStorage;
this->polymorphic_invoke_ =
@@ -396,9 +388,6 @@ class Callback<R(Args...), copy_mode>
reinterpret_cast<PolymorphicInvoke>(this->polymorphic_invoke_);
return f(this->bind_state_.get(), std::forward<Args>(args)...);
}
-
- private:
- using PolymorphicInvoke = R (*)(internal::BindStateBase*, Args&&...);
};
} // namespace base
« base/bind_internal.h ('K') | « base/bind_internal.h ('k') | base/callback_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698