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

Unified Diff: net/spdy/spdy_protocol.h

Issue 2365683002: Add support for zero-copy transfer of unchanged bytes. (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_protocol.h
diff --git a/net/spdy/spdy_protocol.h b/net/spdy/spdy_protocol.h
index 61aa908c728d1eaa596b6527e580bf937a898f00..cb6296b08aaebc4b1f7437ff3afe09cbf1c0d2be 100644
--- a/net/spdy/spdy_protocol.h
+++ b/net/spdy/spdy_protocol.h
@@ -1197,6 +1197,23 @@ class SpdySerializedFrame {
// Returns the actual size of the underlying buffer.
size_t size() const { return size_; }
+ // Returns a buffer containing the contents of the frame, of which the caller
+ // takes ownership, and clears this SpdySerializedFrame.
+ char* ReleaseBuffer() {
+ char* buffer;
+ if (owns_buffer_) {
+ // If the buffer is owned, relinquish ownership to the caller.
+ buffer = frame_;
+ owns_buffer_ = false;
+ } else {
+ // Otherwise, we need to make a copy to give to the caller.
+ buffer = new char[size_];
+ memcpy(buffer, frame_, size_);
+ }
+ *this = SpdySerializedFrame();
+ return buffer;
+ }
+
protected:
char* frame_;
« 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