OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file contains utility functions and classes that help the | 5 // This file contains utility functions and classes that help the |
6 // implementation, and management of the Callback objects. | 6 // implementation, and management of the Callback objects. |
7 | 7 |
8 #ifndef BASE_CALLBACK_INTERNAL_H_ | 8 #ifndef BASE_CALLBACK_INTERNAL_H_ |
9 #define BASE_CALLBACK_INTERNAL_H_ | 9 #define BASE_CALLBACK_INTERNAL_H_ |
10 | 10 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 // TODO(ajwong): We might be able to use SFINAE to search for the existence of | 130 // TODO(ajwong): We might be able to use SFINAE to search for the existence of |
131 // a Pass() function in the type and avoid the whitelist in CallbackParamTraits | 131 // a Pass() function in the type and avoid the whitelist in CallbackParamTraits |
132 // and CallbackForward. | 132 // and CallbackForward. |
133 template <typename T, typename D> | 133 template <typename T, typename D> |
134 struct CallbackParamTraits<scoped_ptr<T, D> > { | 134 struct CallbackParamTraits<scoped_ptr<T, D> > { |
135 typedef scoped_ptr<T, D> ForwardType; | 135 typedef scoped_ptr<T, D> ForwardType; |
136 typedef scoped_ptr<T, D> StorageType; | 136 typedef scoped_ptr<T, D> StorageType; |
137 }; | 137 }; |
138 | 138 |
139 template <typename T> | 139 template <typename T> |
140 struct CallbackParamTraits<scoped_array<T> > { | 140 struct CallbackParamTraits<scoped_ptr<T[]> > { |
awong
2013/01/16 18:56:06
Does this compile?
If we make this change, we rem
tfarina
2013/01/16 19:00:28
I compiled only base_unittests.
| |
141 typedef scoped_array<T> ForwardType; | 141 typedef scoped_ptr<T[]> ForwardType; |
142 typedef scoped_array<T> StorageType; | 142 typedef scoped_ptr<T[]> StorageType; |
143 }; | 143 }; |
144 | 144 |
145 template <typename T, typename R> | 145 template <typename T, typename R> |
146 struct CallbackParamTraits<scoped_ptr_malloc<T, R> > { | 146 struct CallbackParamTraits<scoped_ptr_malloc<T, R> > { |
147 typedef scoped_ptr_malloc<T, R> ForwardType; | 147 typedef scoped_ptr_malloc<T, R> ForwardType; |
148 typedef scoped_ptr_malloc<T, R> StorageType; | 148 typedef scoped_ptr_malloc<T, R> StorageType; |
149 }; | 149 }; |
150 | 150 |
151 template <typename T> | 151 template <typename T> |
152 struct CallbackParamTraits<ScopedVector<T> > { | 152 struct CallbackParamTraits<ScopedVector<T> > { |
(...skipping 17 matching lines...) Expand all Loading... | |
170 // simulate std::forward() and forward the result of one Callback as a | 170 // simulate std::forward() and forward the result of one Callback as a |
171 // parameter to another callback. This is to support Callbacks that return | 171 // parameter to another callback. This is to support Callbacks that return |
172 // the movable-but-not-copyable types whitelisted above. | 172 // the movable-but-not-copyable types whitelisted above. |
173 template <typename T> | 173 template <typename T> |
174 T& CallbackForward(T& t) { return t; } | 174 T& CallbackForward(T& t) { return t; } |
175 | 175 |
176 template <typename T, typename D> | 176 template <typename T, typename D> |
177 scoped_ptr<T, D> CallbackForward(scoped_ptr<T, D>& p) { return p.Pass(); } | 177 scoped_ptr<T, D> CallbackForward(scoped_ptr<T, D>& p) { return p.Pass(); } |
178 | 178 |
179 template <typename T> | 179 template <typename T> |
180 scoped_array<T> CallbackForward(scoped_array<T>& p) { return p.Pass(); } | 180 scoped_ptr<T[]> CallbackForward(scoped_ptr<T[]>& p) { return p.Pass(); } |
181 | 181 |
182 template <typename T, typename R> | 182 template <typename T, typename R> |
183 scoped_ptr_malloc<T, R> CallbackForward(scoped_ptr_malloc<T, R>& p) { | 183 scoped_ptr_malloc<T, R> CallbackForward(scoped_ptr_malloc<T, R>& p) { |
184 return p.Pass(); | 184 return p.Pass(); |
185 } | 185 } |
186 | 186 |
187 template <typename T> | 187 template <typename T> |
188 ScopedVector<T> CallbackForward(ScopedVector<T>& p) { return p.Pass(); } | 188 ScopedVector<T> CallbackForward(ScopedVector<T>& p) { return p.Pass(); } |
189 | 189 |
190 } // namespace internal | 190 } // namespace internal |
191 } // namespace base | 191 } // namespace base |
192 | 192 |
193 #endif // BASE_CALLBACK_INTERNAL_H_ | 193 #endif // BASE_CALLBACK_INTERNAL_H_ |
OLD | NEW |