Commit d2bafaa1 authored by bnc's avatar bnc Committed by Commit bot

Add support for zero-copy transfer of unchanged bytes.

This CL lands server change 133740552 by agt.

BUG=488484

Review-Url: https://codereview.chromium.org/2365683002
Cr-Commit-Position: refs/heads/master@{#420737}
parent e233f018
...@@ -1197,6 +1197,23 @@ class SpdySerializedFrame { ...@@ -1197,6 +1197,23 @@ class SpdySerializedFrame {
// Returns the actual size of the underlying buffer. // Returns the actual size of the underlying buffer.
size_t size() const { return size_; } 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: protected:
char* frame_; char* frame_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment