Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: webrtc/base/copyonwritebuffer.h

Issue 2189013002: Fix CopyOnWriteBuffer::cdata to return const pointer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 CloneDataIfReferenced(buffer_->capacity()); 83 CloneDataIfReferenced(buffer_->capacity());
84 return buffer_->data<T>(); 84 return buffer_->data<T>();
85 } 85 }
86 86
87 // Get const pointer to the data. This will not create a copy of the 87 // Get const pointer to the data. This will not create a copy of the
88 // underlying data if it is shared with other buffers. 88 // underlying data if it is shared with other buffers.
89 template <typename T = uint8_t, 89 template <typename T = uint8_t,
90 typename std::enable_if< 90 typename std::enable_if<
91 internal::BufferCompat<uint8_t, T>::value>::type* = nullptr> 91 internal::BufferCompat<uint8_t, T>::value>::type* = nullptr>
92 T* cdata() const { 92 const T* cdata() const {
93 RTC_DCHECK(IsConsistent()); 93 RTC_DCHECK(IsConsistent());
94 if (!buffer_) { 94 if (!buffer_) {
95 return nullptr; 95 return nullptr;
96 } 96 }
97 return buffer_->data<T>(); 97 return buffer_->data<T>();
98 } 98 }
99 99
100 size_t size() const { 100 size_t size() const {
101 RTC_DCHECK(IsConsistent()); 101 RTC_DCHECK(IsConsistent());
102 return buffer_ ? buffer_->size() : 0; 102 return buffer_ ? buffer_->size() : 0;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 return (!buffer_ || buffer_->capacity() > 0); 283 return (!buffer_ || buffer_->capacity() > 0);
284 } 284 }
285 285
286 // buffer_ is either null, or points to an rtc::Buffer with capacity > 0. 286 // buffer_ is either null, or points to an rtc::Buffer with capacity > 0.
287 scoped_refptr<RefCountedObject<Buffer>> buffer_; 287 scoped_refptr<RefCountedObject<Buffer>> buffer_;
288 }; 288 };
289 289
290 } // namespace rtc 290 } // namespace rtc
291 291
292 #endif // WEBRTC_BASE_COPYONWRITEBUFFER_H_ 292 #endif // WEBRTC_BASE_COPYONWRITEBUFFER_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698