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

Unified Diff: base/bind.h

Issue 2317563002: Move CallbackBase::polymorphic_invoke_ into BindStateBase (Closed)
Patch Set: rebase Created 4 years, 3 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
« no previous file with comments | « no previous file | base/bind_internal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/bind.h
diff --git a/base/bind.h b/base/bind.h
index 50b941e45992b145dde1b45e9718c47b3d9956f4..86f624e49c80ae376112a73f88ef007e44d7342c 100644
--- a/base/bind.h
+++ b/base/bind.h
@@ -31,11 +31,19 @@ inline base::Callback<MakeUnboundRunType<Functor, Args...>> Bind(
using BindState = internal::MakeBindStateType<Functor, Args...>;
using UnboundRunType = MakeUnboundRunType<Functor, Args...>;
using Invoker = internal::Invoker<BindState, UnboundRunType>;
-
using CallbackType = Callback<UnboundRunType>;
- return CallbackType(new BindState(std::forward<Functor>(functor),
- std::forward<Args>(args)...),
- &Invoker::Run);
+
+ // Store the invoke func into PolymorphicInvoke before casting it to
+ // InvokeFuncStorage, so that we can ensure its type matches to
+ // PolymorphicInvoke, to which CallbackType will cast back.
+ using PolymorphicInvoke = typename CallbackType::PolymorphicInvoke;
+ PolymorphicInvoke invoke_func = &Invoker::Run;
+
+ using InvokeFuncStorage = internal::BindStateBase::InvokeFuncStorage;
+ return CallbackType(new BindState(
+ reinterpret_cast<InvokeFuncStorage>(invoke_func),
+ std::forward<Functor>(functor),
+ std::forward<Args>(args)...));
}
} // namespace base
« no previous file with comments | « no previous file | base/bind_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698