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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/bind_internal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_BIND_H_ 5 #ifndef BASE_BIND_H_
6 #define BASE_BIND_H_ 6 #define BASE_BIND_H_
7 7
8 #include "base/bind_internal.h" 8 #include "base/bind_internal.h"
9 9
10 // ----------------------------------------------------------------------------- 10 // -----------------------------------------------------------------------------
(...skipping 13 matching lines...) Expand all
24 24
25 namespace base { 25 namespace base {
26 26
27 template <typename Functor, typename... Args> 27 template <typename Functor, typename... Args>
28 inline base::Callback<MakeUnboundRunType<Functor, Args...>> Bind( 28 inline base::Callback<MakeUnboundRunType<Functor, Args...>> Bind(
29 Functor&& functor, 29 Functor&& functor,
30 Args&&... args) { 30 Args&&... args) {
31 using BindState = internal::MakeBindStateType<Functor, Args...>; 31 using BindState = internal::MakeBindStateType<Functor, Args...>;
32 using UnboundRunType = MakeUnboundRunType<Functor, Args...>; 32 using UnboundRunType = MakeUnboundRunType<Functor, Args...>;
33 using Invoker = internal::Invoker<BindState, UnboundRunType>; 33 using Invoker = internal::Invoker<BindState, UnboundRunType>;
34 using CallbackType = Callback<UnboundRunType>;
34 35
35 using CallbackType = Callback<UnboundRunType>; 36 // Store the invoke func into PolymorphicInvoke before casting it to
36 return CallbackType(new BindState(std::forward<Functor>(functor), 37 // InvokeFuncStorage, so that we can ensure its type matches to
37 std::forward<Args>(args)...), 38 // PolymorphicInvoke, to which CallbackType will cast back.
38 &Invoker::Run); 39 using PolymorphicInvoke = typename CallbackType::PolymorphicInvoke;
40 PolymorphicInvoke invoke_func = &Invoker::Run;
41
42 using InvokeFuncStorage = internal::BindStateBase::InvokeFuncStorage;
43 return CallbackType(new BindState(
44 reinterpret_cast<InvokeFuncStorage>(invoke_func),
45 std::forward<Functor>(functor),
46 std::forward<Args>(args)...));
39 } 47 }
40 48
41 } // namespace base 49 } // namespace base
42 50
43 #endif // BASE_BIND_H_ 51 #endif // BASE_BIND_H_
OLDNEW
« 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