| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 if (ptr_) | 82 if (ptr_) |
| 83 ptr_->AddRef(); | 83 ptr_->AddRef(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 template <typename U> | 86 template <typename U> |
| 87 scoped_refptr(const scoped_refptr<U>& r) : ptr_(r.get()) { | 87 scoped_refptr(const scoped_refptr<U>& r) : ptr_(r.get()) { |
| 88 if (ptr_) | 88 if (ptr_) |
| 89 ptr_->AddRef(); | 89 ptr_->AddRef(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 // Move constructors. |
| 93 scoped_refptr(scoped_refptr<T>&& r) : ptr_(r.release()) {} |
| 94 |
| 95 template <typename U> |
| 96 scoped_refptr(scoped_refptr<U>&& r) : ptr_(r.release()) {} |
| 97 |
| 92 ~scoped_refptr() { | 98 ~scoped_refptr() { |
| 93 if (ptr_) | 99 if (ptr_) |
| 94 ptr_->Release(); | 100 ptr_->Release(); |
| 95 } | 101 } |
| 96 | 102 |
| 97 T* get() const { return ptr_; } | 103 T* get() const { return ptr_; } |
| 98 operator T*() const { return ptr_; } | 104 operator T*() const { return ptr_; } |
| 99 T* operator->() const { return ptr_; } | 105 T* operator->() const { return ptr_; } |
| 100 | 106 |
| 101 // Release a pointer. | 107 // Release a pointer. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 swap(&r.ptr_); | 144 swap(&r.ptr_); |
| 139 } | 145 } |
| 140 | 146 |
| 141 protected: | 147 protected: |
| 142 T* ptr_; | 148 T* ptr_; |
| 143 }; | 149 }; |
| 144 | 150 |
| 145 } // namespace rtc | 151 } // namespace rtc |
| 146 | 152 |
| 147 #endif // WEBRTC_BASE_SCOPED_REF_PTR_H_ | 153 #endif // WEBRTC_BASE_SCOPED_REF_PTR_H_ |
| OLD | NEW |