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