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

Side by Side Diff: base/bind.h

Issue 1699123002: Unify BindState refcount management into the bound arguments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: +comment Created 4 years, 10 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_helpers.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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 namespace internal { 49 namespace internal {
50 50
51 // Don't use Alias Template directly here to avoid a compile error on MSVC2013. 51 // Don't use Alias Template directly here to avoid a compile error on MSVC2013.
52 template <typename Functor, typename... Args> 52 template <typename Functor, typename... Args>
53 struct MakeUnboundRunTypeImpl { 53 struct MakeUnboundRunTypeImpl {
54 using Type = 54 using Type =
55 typename BindState< 55 typename BindState<
56 typename FunctorTraits<Functor>::RunnableType, 56 typename FunctorTraits<Functor>::RunnableType,
57 typename FunctorTraits<Functor>::RunType, 57 typename FunctorTraits<Functor>::RunType,
58 typename std::decay<Args>::type...>::UnboundRunType; 58 Args...>::UnboundRunType;
59 }; 59 };
60 60
61 } // namespace internal 61 } // namespace internal
62 62
63 template <typename Functor, typename... Args> 63 template <typename Functor, typename... Args>
64 using MakeUnboundRunType = 64 using MakeUnboundRunType =
65 typename internal::MakeUnboundRunTypeImpl<Functor, Args...>::Type; 65 typename internal::MakeUnboundRunTypeImpl<Functor, Args...>::Type;
66 66
67 template <typename Functor, typename... Args> 67 template <typename Functor, typename... Args>
68 base::Callback<MakeUnboundRunType<Functor, Args...>> 68 base::Callback<MakeUnboundRunType<Functor, Args...>>
(...skipping 24 matching lines...) Expand all
93 // For methods, we need to be careful for parameter 1. We do not require 93 // For methods, we need to be careful for parameter 1. We do not require
94 // a scoped_refptr because BindState<> itself takes care of AddRef() for 94 // a scoped_refptr because BindState<> itself takes care of AddRef() for
95 // methods. We also disallow binding of an array as the method's target 95 // methods. We also disallow binding of an array as the method's target
96 // object. 96 // object.
97 static_assert(!internal::BindsArrayToFirstArg<is_method, Args...>::value, 97 static_assert(!internal::BindsArrayToFirstArg<is_method, Args...>::value,
98 "first bound argument to method cannot be array"); 98 "first bound argument to method cannot be array");
99 static_assert( 99 static_assert(
100 !internal::HasRefCountedParamAsRawPtr<is_method, Args...>::value, 100 !internal::HasRefCountedParamAsRawPtr<is_method, Args...>::value,
101 "a parameter is a refcounted type and needs scoped_refptr"); 101 "a parameter is a refcounted type and needs scoped_refptr");
102 102
103 using BindState = internal::BindState< 103 using BindState = internal::BindState<RunnableType, RunType, Args...>;
104 RunnableType, RunType, typename std::decay<Args>::type...>;
105 104
106 return Callback<typename BindState::UnboundRunType>( 105 return Callback<typename BindState::UnboundRunType>(
107 new BindState(internal::MakeRunnable(functor), 106 new BindState(internal::MakeRunnable(functor),
108 std::forward<Args>(args)...)); 107 std::forward<Args>(args)...));
109 } 108 }
110 109
111 } // namespace base 110 } // namespace base
112 111
113 #endif // BASE_BIND_H_ 112 #endif // BASE_BIND_H_
OLDNEW
« 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