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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // | 129 // |
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> |
| 140 struct CallbackParamTraits<scoped_array<T> > { |
| 141 typedef scoped_array<T> ForwardType; |
| 142 typedef scoped_array<T> StorageType; |
| 143 }; |
| 144 |
139 template <typename T, typename R> | 145 template <typename T, typename R> |
140 struct CallbackParamTraits<scoped_ptr_malloc<T, R> > { | 146 struct CallbackParamTraits<scoped_ptr_malloc<T, R> > { |
141 typedef scoped_ptr_malloc<T, R> ForwardType; | 147 typedef scoped_ptr_malloc<T, R> ForwardType; |
142 typedef scoped_ptr_malloc<T, R> StorageType; | 148 typedef scoped_ptr_malloc<T, R> StorageType; |
143 }; | 149 }; |
144 | 150 |
145 template <typename T> | 151 template <typename T> |
146 struct CallbackParamTraits<ScopedVector<T> > { | 152 struct CallbackParamTraits<ScopedVector<T> > { |
147 typedef ScopedVector<T> ForwardType; | 153 typedef ScopedVector<T> ForwardType; |
148 typedef ScopedVector<T> StorageType; | 154 typedef ScopedVector<T> StorageType; |
(...skipping 14 matching lines...) Expand all Loading... |
163 // In addition to Callback/Bind, this is used by PostTaskAndReplyWithResult to | 169 // In addition to Callback/Bind, this is used by PostTaskAndReplyWithResult to |
164 // 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 |
165 // parameter to another callback. This is to support Callbacks that return | 171 // parameter to another callback. This is to support Callbacks that return |
166 // the movable-but-not-copyable types whitelisted above. | 172 // the movable-but-not-copyable types whitelisted above. |
167 template <typename T> | 173 template <typename T> |
168 T& CallbackForward(T& t) { return t; } | 174 T& CallbackForward(T& t) { return t; } |
169 | 175 |
170 template <typename T, typename D> | 176 template <typename T, typename D> |
171 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(); } |
172 | 178 |
| 179 template <typename T> |
| 180 scoped_array<T> CallbackForward(scoped_array<T>& p) { return p.Pass(); } |
| 181 |
173 template <typename T, typename R> | 182 template <typename T, typename R> |
174 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) { |
175 return p.Pass(); | 184 return p.Pass(); |
176 } | 185 } |
177 | 186 |
178 template <typename T> | 187 template <typename T> |
179 ScopedVector<T> CallbackForward(ScopedVector<T>& p) { return p.Pass(); } | 188 ScopedVector<T> CallbackForward(ScopedVector<T>& p) { return p.Pass(); } |
180 | 189 |
181 } // namespace internal | 190 } // namespace internal |
182 } // namespace base | 191 } // namespace base |
183 | 192 |
184 #endif // BASE_CALLBACK_INTERNAL_H_ | 193 #endif // BASE_CALLBACK_INTERNAL_H_ |
OLD | NEW |