| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 RTC_DCHECK(buf.IsConsistent()); | 112 RTC_DCHECK(buf.IsConsistent()); |
| 113 if (&buf != this) { | 113 if (&buf != this) { |
| 114 buffer_ = buf.buffer_; | 114 buffer_ = buf.buffer_; |
| 115 } | 115 } |
| 116 return *this; | 116 return *this; |
| 117 } | 117 } |
| 118 | 118 |
| 119 CopyOnWriteBuffer& operator=(CopyOnWriteBuffer&& buf) { | 119 CopyOnWriteBuffer& operator=(CopyOnWriteBuffer&& buf) { |
| 120 RTC_DCHECK(IsConsistent()); | 120 RTC_DCHECK(IsConsistent()); |
| 121 RTC_DCHECK(buf.IsConsistent()); | 121 RTC_DCHECK(buf.IsConsistent()); |
| 122 // TODO(jbauch): use std::move once scoped_refptr supports it (issue 5556) | 122 buffer_ = std::move(buf.buffer_); |
| 123 buffer_.swap(buf.buffer_); | |
| 124 buf.buffer_ = nullptr; | |
| 125 return *this; | 123 return *this; |
| 126 } | 124 } |
| 127 | 125 |
| 128 bool operator==(const CopyOnWriteBuffer& buf) const { | 126 bool operator==(const CopyOnWriteBuffer& buf) const { |
| 129 // Must either use the same buffer internally or have the same contents. | 127 // Must either use the same buffer internally or have the same contents. |
| 130 RTC_DCHECK(IsConsistent()); | 128 RTC_DCHECK(IsConsistent()); |
| 131 RTC_DCHECK(buf.IsConsistent()); | 129 RTC_DCHECK(buf.IsConsistent()); |
| 132 return buffer_.get() == buf.buffer_.get() || | 130 return buffer_.get() == buf.buffer_.get() || |
| 133 (buffer_.get() && buf.buffer_.get() && | 131 (buffer_.get() && buf.buffer_.get() && |
| 134 *buffer_.get() == *buf.buffer_.get()); | 132 *buffer_.get() == *buf.buffer_.get()); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 return (!buffer_ || buffer_->capacity() > 0); | 281 return (!buffer_ || buffer_->capacity() > 0); |
| 284 } | 282 } |
| 285 | 283 |
| 286 // buffer_ is either null, or points to an rtc::Buffer with capacity > 0. | 284 // buffer_ is either null, or points to an rtc::Buffer with capacity > 0. |
| 287 scoped_refptr<RefCountedObject<Buffer>> buffer_; | 285 scoped_refptr<RefCountedObject<Buffer>> buffer_; |
| 288 }; | 286 }; |
| 289 | 287 |
| 290 } // namespace rtc | 288 } // namespace rtc |
| 291 | 289 |
| 292 #endif // WEBRTC_BASE_COPYONWRITEBUFFER_H_ | 290 #endif // WEBRTC_BASE_COPYONWRITEBUFFER_H_ |
| OLD | NEW |