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

Unified Diff: webrtc/base/copyonwritebuffer.cc

Issue 1697743003: Add CopyOnWriteBuffer class (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: More feedback from kwiberg Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/copyonwritebuffer.h ('k') | webrtc/base/copyonwritebuffer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/copyonwritebuffer.cc
diff --git a/webrtc/base/copyonwritebuffer.cc b/webrtc/base/copyonwritebuffer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..293faec001b1bfb577a37ef226e3c4c34df8d184
--- /dev/null
+++ b/webrtc/base/copyonwritebuffer.cc
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2016 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/base/copyonwritebuffer.h"
+
+namespace rtc {
+
+CopyOnWriteBuffer::CopyOnWriteBuffer() {
+ RTC_DCHECK(IsConsistent());
+}
+
+CopyOnWriteBuffer::CopyOnWriteBuffer(const CopyOnWriteBuffer& buf)
+ : buffer_(buf.buffer_) {
+}
+
+CopyOnWriteBuffer::CopyOnWriteBuffer(CopyOnWriteBuffer&& buf) {
+ // TODO(jbauch): use std::move once scoped_refptr supports it (issue 5556)
+ std::swap(buffer_, buf.buffer_);
+}
+
+CopyOnWriteBuffer::CopyOnWriteBuffer(size_t size)
+ : buffer_(size > 0 ? new RefCountedObject<Buffer>(size) : nullptr) {
+ RTC_DCHECK(IsConsistent());
+}
+
+CopyOnWriteBuffer::CopyOnWriteBuffer(size_t size, size_t capacity)
+ : buffer_(size > 0 || capacity > 0
+ ? new RefCountedObject<Buffer>(size, capacity)
+ : nullptr) {
+ RTC_DCHECK(IsConsistent());
+}
+
+CopyOnWriteBuffer::~CopyOnWriteBuffer() = default;
+
+} // namespace rtc
« no previous file with comments | « webrtc/base/copyonwritebuffer.h ('k') | webrtc/base/copyonwritebuffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698