summaryrefslogtreecommitdiffstats
path: root/chromium/base/bind.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/base/bind.h')
-rw-r--r--chromium/base/bind.h49
1 files changed, 8 insertions, 41 deletions
diff --git a/chromium/base/bind.h b/chromium/base/bind.h
index 46dbb913bee..ed5a94a8c2f 100644
--- a/chromium/base/bind.h
+++ b/chromium/base/bind.h
@@ -46,47 +46,11 @@
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;
-
- // Use RunnableType::RunType instead of RunType above because our
- // checks below for bound references need to know what the actual
- // functor is going to interpret the argument as.
- using BoundRunType = typename RunnableType::RunType;
-
- using BoundArgs =
- internal::TakeTypeListItem<sizeof...(Args),
- internal::ExtractArgs<BoundRunType>>;
-
- // Do not allow binding a non-const reference parameter. Non-const reference
- // parameters are disallowed by the Google style guide. Also, binding a
- // non-const reference parameter can make for subtle bugs because the
- // invoked function will receive a reference to the stored copy of the
- // argument and not the original.
- static_assert(!internal::HasNonConstReferenceItem<BoundArgs>::value,
- "do not bind functions with nonconst ref");
const bool is_method = internal::HasIsMethodTag<RunnableType>::value;
@@ -100,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