| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 template <typename U> | 49 template <typename U> |
| 50 RefPtr(const RefPtr<U>& o, EnsurePtrConvertibleArgDecl(U, T)) | 50 RefPtr(const RefPtr<U>& o, EnsurePtrConvertibleArgDecl(U, T)) |
| 51 : ptr_(o.Get()) { | 51 : ptr_(o.Get()) { |
| 52 RefIfNotNull(ptr_); | 52 RefIfNotNull(ptr_); |
| 53 } | 53 } |
| 54 RefPtr(RefPtr&& o) : ptr_(o.ptr_) { o.ptr_ = nullptr; } | 54 RefPtr(RefPtr&& o) : ptr_(o.ptr_) { o.ptr_ = nullptr; } |
| 55 | 55 |
| 56 // See comments in PassRefPtr.h for an explanation of why this takes a const | 56 // See comments in PassRefPtr.h for an explanation of why this takes a const |
| 57 // reference. | 57 // reference. |
| 58 template <typename U> | 58 template <typename U> |
| 59 RefPtr(const PassRefPtr<U>&, EnsurePtrConvertibleArgDecl(U, T)); | 59 RefPtr(PassRefPtr<U>&&, EnsurePtrConvertibleArgDecl(U, T)); |
| 60 | 60 |
| 61 // Hash table deleted values, which are only constructed and never copied or | 61 // Hash table deleted values, which are only constructed and never copied or |
| 62 // destroyed. | 62 // destroyed. |
| 63 RefPtr(HashTableDeletedValueType) : ptr_(HashTableDeletedValue()) {} | 63 RefPtr(HashTableDeletedValueType) : ptr_(HashTableDeletedValue()) {} |
| 64 bool IsHashTableDeletedValue() const { | 64 bool IsHashTableDeletedValue() const { |
| 65 return ptr_ == HashTableDeletedValue(); | 65 return ptr_ == HashTableDeletedValue(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 ALWAYS_INLINE ~RefPtr() { DerefIfNotNull(ptr_); } | 68 ALWAYS_INLINE ~RefPtr() { DerefIfNotNull(ptr_); } |
| 69 | 69 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 97 void Swap(RefPtr&); | 97 void Swap(RefPtr&); |
| 98 | 98 |
| 99 static T* HashTableDeletedValue() { return reinterpret_cast<T*>(-1); } | 99 static T* HashTableDeletedValue() { return reinterpret_cast<T*>(-1); } |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 T* ptr_; | 102 T* ptr_; |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 template <typename T> | 105 template <typename T> |
| 106 template <typename U> | 106 template <typename U> |
| 107 inline RefPtr<T>::RefPtr(const PassRefPtr<U>& o, | 107 inline RefPtr<T>::RefPtr(PassRefPtr<U>&& o, EnsurePtrConvertibleArgDefn(U, T)) |
| 108 EnsurePtrConvertibleArgDefn(U, T)) | |
| 109 : ptr_(o.LeakRef()) {} | 108 : ptr_(o.LeakRef()) {} |
| 110 | 109 |
| 111 template <typename T> | 110 template <typename T> |
| 112 inline T* RefPtr<T>::LeakRef() { | 111 inline T* RefPtr<T>::LeakRef() { |
| 113 T* ptr = ptr_; | 112 T* ptr = ptr_; |
| 114 ptr_ = nullptr; | 113 ptr_ = nullptr; |
| 115 return ptr; | 114 return ptr; |
| 116 } | 115 } |
| 117 | 116 |
| 118 template <typename T> | 117 template <typename T> |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 210 |
| 212 private: | 211 private: |
| 213 T* ptr_; | 212 T* ptr_; |
| 214 }; | 213 }; |
| 215 | 214 |
| 216 } // namespace WTF | 215 } // namespace WTF |
| 217 | 216 |
| 218 using WTF::RefPtr; | 217 using WTF::RefPtr; |
| 219 | 218 |
| 220 #endif // WTF_RefPtr_h | 219 #endif // WTF_RefPtr_h |
| OLD | NEW |