| OLD | NEW |
| 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 // This defines a set of argument wrappers and related factory methods that | 5 // This defines a set of argument wrappers and related factory methods that |
| 6 // can be used specify the refcounting and reference semantics of arguments | 6 // can be used specify the refcounting and reference semantics of arguments |
| 7 // that are bound by the Bind() function in base/bind.h. | 7 // that are bound by the Bind() function in base/bind.h. |
| 8 // | 8 // |
| 9 // It also defines a set of simple functions and utilities that people want | 9 // It also defines a set of simple functions and utilities that people want |
| 10 // when using Callback<> and Bind(). | 10 // when using Callback<> and Bind(). |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 244 |
| 245 template <void(BaseMixin::*)(void)> struct Helper {}; | 245 template <void(BaseMixin::*)(void)> struct Helper {}; |
| 246 | 246 |
| 247 template <typename C> | 247 template <typename C> |
| 248 static No& Check(Helper<&C::AddRef>*); | 248 static No& Check(Helper<&C::AddRef>*); |
| 249 | 249 |
| 250 template <typename > | 250 template <typename > |
| 251 static Yes& Check(...); | 251 static Yes& Check(...); |
| 252 | 252 |
| 253 public: | 253 public: |
| 254 static const bool value = sizeof(Check<Base>(0)) == sizeof(Yes); | 254 enum { value = sizeof(Check<Base>(0)) == sizeof(Yes) }; |
| 255 }; | 255 }; |
| 256 | 256 |
| 257 // Helpers to assert that arguments of a recounted type are bound with a | 257 // Helpers to assert that arguments of a recounted type are bound with a |
| 258 // scoped_refptr. | 258 // scoped_refptr. |
| 259 template <bool IsClasstype, typename T> | 259 template <bool IsClasstype, typename T> |
| 260 struct UnsafeBindtoRefCountedArgHelper : false_type { | 260 struct UnsafeBindtoRefCountedArgHelper : false_type { |
| 261 }; | 261 }; |
| 262 | 262 |
| 263 template <typename T> | 263 template <typename T> |
| 264 struct UnsafeBindtoRefCountedArgHelper<true, T> | 264 struct UnsafeBindtoRefCountedArgHelper<true, T> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 279 typedef char Yes[1]; | 279 typedef char Yes[1]; |
| 280 typedef char No[2]; | 280 typedef char No[2]; |
| 281 | 281 |
| 282 template <typename U> | 282 template <typename U> |
| 283 static Yes& Check(typename U::IsMethod*); | 283 static Yes& Check(typename U::IsMethod*); |
| 284 | 284 |
| 285 template <typename U> | 285 template <typename U> |
| 286 static No& Check(...); | 286 static No& Check(...); |
| 287 | 287 |
| 288 public: | 288 public: |
| 289 static const bool value = sizeof(Check<T>(0)) == sizeof(Yes); | 289 enum { value = sizeof(Check<T>(0)) == sizeof(Yes) }; |
| 290 }; | 290 }; |
| 291 | 291 |
| 292 template <typename T> | 292 template <typename T> |
| 293 class UnretainedWrapper { | 293 class UnretainedWrapper { |
| 294 public: | 294 public: |
| 295 explicit UnretainedWrapper(T* o) : ptr_(o) {} | 295 explicit UnretainedWrapper(T* o) : ptr_(o) {} |
| 296 T* get() const { return ptr_; } | 296 T* get() const { return ptr_; } |
| 297 private: | 297 private: |
| 298 T* ptr_; | 298 T* ptr_; |
| 299 }; | 299 }; |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 BASE_EXPORT void DoNothing(); | 535 BASE_EXPORT void DoNothing(); |
| 536 | 536 |
| 537 template<typename T> | 537 template<typename T> |
| 538 void DeletePointer(T* obj) { | 538 void DeletePointer(T* obj) { |
| 539 delete obj; | 539 delete obj; |
| 540 } | 540 } |
| 541 | 541 |
| 542 } // namespace base | 542 } // namespace base |
| 543 | 543 |
| 544 #endif // BASE_BIND_HELPERS_H_ | 544 #endif // BASE_BIND_HELPERS_H_ |
| OLD | NEW |