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

Unified Diff: webrtc/base/buffer.h

Issue 1817753003: Revert of Use CopyOnWriteBuffer instead of Buffer to avoid unnecessary copies. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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/api/webrtcsession_unittest.cc ('k') | webrtc/base/buffer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/buffer.h
diff --git a/webrtc/base/buffer.h b/webrtc/base/buffer.h
index 658b06e75bb7140f121b1dc602e222025eaa8ce3..e9c47ee84e02168b6df52bb5c071613c1c9a9067 100644
--- a/webrtc/base/buffer.h
+++ b/webrtc/base/buffer.h
@@ -50,6 +50,7 @@
class Buffer {
public:
Buffer(); // An empty buffer.
+ Buffer(const Buffer& buf); // Copy size and contents of an existing buffer.
Buffer(Buffer&& buf); // Move contents from an existing buffer.
// Construct a buffer with the specified number of uninitialized bytes.
@@ -97,6 +98,12 @@
size_t capacity() const {
RTC_DCHECK(IsConsistent());
return capacity_;
+ }
+
+ Buffer& operator=(const Buffer& buf) {
+ if (&buf != this)
+ SetData(buf.data(), buf.size());
+ return *this;
}
Buffer& operator=(Buffer&& buf) {
@@ -273,8 +280,6 @@
size_t size_;
size_t capacity_;
std::unique_ptr<uint8_t[]> data_;
-
- RTC_DISALLOW_COPY_AND_ASSIGN(Buffer);
};
} // namespace rtc
« no previous file with comments | « webrtc/api/webrtcsession_unittest.cc ('k') | webrtc/base/buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698