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

Unified Diff: base/bind.h

Issue 2034633002: Decouple Invoker from BindState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove base::internal::MakeUnboundRunType Created 4 years, 6 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_helpers.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 fe4419a16f1a72d742633d1eb507ac8694424369..ed5a94a8c2ffb89784dbdca68f0a3da327d4d8bf 100644
--- a/base/bind.h
+++ b/base/bind.h
@@ -46,30 +46,12 @@
namespace base {
-namespace internal {
-
-// Don't use Alias Template directly here to avoid a compile error on MSVC2013.
-template <typename Functor, typename... Args>
-struct MakeUnboundRunTypeImpl {
- using Type =
- typename BindState<
- typename FunctorTraits<Functor>::RunnableType,
- typename FunctorTraits<Functor>::RunType,
- Args...>::UnboundRunType;
-};
-
-} // namespace internal
-
template <typename Functor, typename... Args>
-using MakeUnboundRunType =
- typename internal::MakeUnboundRunTypeImpl<Functor, Args...>::Type;
-
-template <typename Functor, typename... Args>
-base::Callback<MakeUnboundRunType<Functor, Args...>>
+inline base::Callback<MakeUnboundRunType<Functor, Args...>>
Bind(Functor functor, Args&&... args) {
// Type aliases for how to store and run the functor.
using RunnableType = typename internal::FunctorTraits<Functor>::RunnableType;
- using RunType = typename internal::FunctorTraits<Functor>::RunType;
+
const bool is_method = internal::HasIsMethodTag<RunnableType>::value;
// For methods, we need to be careful for parameter 1. We do not require
@@ -82,11 +64,14 @@ Bind(Functor functor, Args&&... args) {
!internal::HasRefCountedParamAsRawPtr<is_method, Args...>::value,
"a parameter is a refcounted type and needs scoped_refptr");
- using BindState = internal::BindState<RunnableType, RunType, Args...>;
+ using BindState = internal::BindState<RunnableType, Args...>;
+ using UnboundRunType = MakeUnboundRunType<Functor, Args...>;
+ using CallbackType = Callback<UnboundRunType>;
+ using Invoker = internal::Invoker<BindState, UnboundRunType>;
- return Callback<typename BindState::UnboundRunType>(
- new BindState(internal::MakeRunnable(functor),
- std::forward<Args>(args)...));
+ return CallbackType(new BindState(internal::MakeRunnable(functor),
+ std::forward<Args>(args)...),
+ &Invoker::Run);
}
} // namespace base
« no previous file with comments | « no previous file | base/bind_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698