| 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 #ifndef BASE_MEMORY_REF_COUNTED_H_ | 5 #ifndef BASE_MEMORY_REF_COUNTED_H_ |
| 6 #define BASE_MEMORY_REF_COUNTED_H_ | 6 #define BASE_MEMORY_REF_COUNTED_H_ |
| 7 | 7 |
| 8 #include <cassert> | 8 #include <cassert> |
| 9 #include <iosfwd> | 9 #include <iosfwd> |
| 10 | 10 |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 ptr->Release(); | 409 ptr->Release(); |
| 410 } | 410 } |
| 411 | 411 |
| 412 // Handy utility for creating a scoped_refptr<T> out of a T* explicitly without | 412 // Handy utility for creating a scoped_refptr<T> out of a T* explicitly without |
| 413 // having to retype all the template arguments | 413 // having to retype all the template arguments |
| 414 template <typename T> | 414 template <typename T> |
| 415 scoped_refptr<T> make_scoped_refptr(T* t) { | 415 scoped_refptr<T> make_scoped_refptr(T* t) { |
| 416 return scoped_refptr<T>(t); | 416 return scoped_refptr<T>(t); |
| 417 } | 417 } |
| 418 | 418 |
| 419 // Temporary operator overloads to facilitate the transition. See | |
| 420 // https://crbug.com/110610. | |
| 421 template <typename T, typename U> | 419 template <typename T, typename U> |
| 422 bool operator==(const scoped_refptr<T>& lhs, const U* rhs) { | 420 bool operator==(const scoped_refptr<T>& lhs, const U* rhs) { |
| 423 return lhs.get() == rhs; | 421 return lhs.get() == rhs; |
| 424 } | 422 } |
| 425 | 423 |
| 426 template <typename T, typename U> | 424 template <typename T, typename U> |
| 427 bool operator==(const T* lhs, const scoped_refptr<U>& rhs) { | 425 bool operator==(const T* lhs, const scoped_refptr<U>& rhs) { |
| 428 return lhs == rhs.get(); | 426 return lhs == rhs.get(); |
| 429 } | 427 } |
| 430 | 428 |
| 431 template <typename T, typename U> | 429 template <typename T, typename U> |
| 432 bool operator!=(const scoped_refptr<T>& lhs, const U* rhs) { | 430 bool operator!=(const scoped_refptr<T>& lhs, const U* rhs) { |
| 433 return !operator==(lhs, rhs); | 431 return !operator==(lhs, rhs); |
| 434 } | 432 } |
| 435 | 433 |
| 436 template <typename T, typename U> | 434 template <typename T, typename U> |
| 437 bool operator!=(const T* lhs, const scoped_refptr<U>& rhs) { | 435 bool operator!=(const T* lhs, const scoped_refptr<U>& rhs) { |
| 438 return !operator==(lhs, rhs); | 436 return !operator==(lhs, rhs); |
| 439 } | 437 } |
| 440 | 438 |
| 441 template <typename T> | 439 template <typename T> |
| 442 std::ostream& operator<<(std::ostream& out, const scoped_refptr<T>& p) { | 440 std::ostream& operator<<(std::ostream& out, const scoped_refptr<T>& p) { |
| 443 return out << p.get(); | 441 return out << p.get(); |
| 444 } | 442 } |
| 445 | 443 |
| 446 #endif // BASE_MEMORY_REF_COUNTED_H_ | 444 #endif // BASE_MEMORY_REF_COUNTED_H_ |
| OLD | NEW |