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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 mutable T scoper_; | 419 mutable T scoper_; |
420 }; | 420 }; |
421 | 421 |
422 // Unwrap the stored parameters for the wrappers above. | 422 // Unwrap the stored parameters for the wrappers above. |
423 template <typename T> | 423 template <typename T> |
424 const T& Unwrap(const T& o) { | 424 const T& Unwrap(const T& o) { |
425 return o; | 425 return o; |
426 } | 426 } |
427 | 427 |
428 template <typename T> | 428 template <typename T> |
429 T* Unwrap(UnretainedWrapper<T> unretained) { | 429 T* Unwrap(const UnretainedWrapper<T>& unretained) { |
430 return unretained.get(); | 430 return unretained.get(); |
431 } | 431 } |
432 | 432 |
433 template <typename T> | 433 template <typename T> |
434 const T& Unwrap(ConstRefWrapper<T> const_ref) { | 434 const T& Unwrap(const ConstRefWrapper<T>& const_ref) { |
435 return const_ref.get(); | 435 return const_ref.get(); |
436 } | 436 } |
437 | 437 |
438 template <typename T> | 438 template <typename T> |
439 T* Unwrap(const RetainedRefWrapper<T>& o) { | 439 T* Unwrap(const RetainedRefWrapper<T>& o) { |
440 return o.get(); | 440 return o.get(); |
441 } | 441 } |
442 | 442 |
443 template <typename T> | 443 template <typename T> |
444 const WeakPtr<T>& Unwrap(const WeakPtr<T>& o) { | 444 const WeakPtr<T>& Unwrap(const WeakPtr<T>& o) { |
445 return o; | 445 return o; |
446 } | 446 } |
447 | 447 |
448 template <typename T> | 448 template <typename T> |
449 T* Unwrap(const OwnedWrapper<T>& o) { | 449 T* Unwrap(const OwnedWrapper<T>& o) { |
450 return o.get(); | 450 return o.get(); |
451 } | 451 } |
452 | 452 |
453 template <typename T> | 453 template <typename T> |
454 T Unwrap(PassedWrapper<T>& o) { | 454 T Unwrap(const PassedWrapper<T>& o) { |
455 return o.Take(); | 455 return o.Take(); |
456 } | 456 } |
457 | 457 |
458 // IsWeakMethod is a helper that determine if we are binding a WeakPtr<> to a | 458 // IsWeakMethod is a helper that determine if we are binding a WeakPtr<> to a |
459 // method. It is used internally by Bind() to select the correct | 459 // method. It is used internally by Bind() to select the correct |
460 // InvokeHelper that will no-op itself in the event the WeakPtr<> for | 460 // InvokeHelper that will no-op itself in the event the WeakPtr<> for |
461 // the target object is invalidated. | 461 // the target object is invalidated. |
462 // | 462 // |
463 // The first argument should be the type of the object that will be received by | 463 // The first argument should be the type of the object that will be received by |
464 // the method. | 464 // the method. |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 | 642 |
643 template <typename T> | 643 template <typename T> |
644 struct IsWeakReceiver<internal::ConstRefWrapper<T>> : IsWeakReceiver<T> {}; | 644 struct IsWeakReceiver<internal::ConstRefWrapper<T>> : IsWeakReceiver<T> {}; |
645 | 645 |
646 template <typename T> | 646 template <typename T> |
647 struct IsWeakReceiver<WeakPtr<T>> : std::true_type {}; | 647 struct IsWeakReceiver<WeakPtr<T>> : std::true_type {}; |
648 | 648 |
649 } // namespace base | 649 } // namespace base |
650 | 650 |
651 #endif // BASE_BIND_HELPERS_H_ | 651 #endif // BASE_BIND_HELPERS_H_ |
OLD | NEW |