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

Side by Side Diff: net/spdy/spdy_protocol.h

Issue 2365683002: Add support for zero-copy transfer of unchanged bytes. (Closed)
Patch Set: Created 4 years, 2 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains some protocol structures for use with SPDY 3 and HTTP 2 5 // This file contains some protocol structures for use with SPDY 3 and HTTP 2
6 // The SPDY 3 spec can be found at: 6 // The SPDY 3 spec can be found at:
7 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3 7 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3
8 8
9 #ifndef NET_SPDY_SPDY_PROTOCOL_H_ 9 #ifndef NET_SPDY_SPDY_PROTOCOL_H_
10 #define NET_SPDY_SPDY_PROTOCOL_H_ 10 #define NET_SPDY_SPDY_PROTOCOL_H_
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 } 1190 }
1191 } 1191 }
1192 1192
1193 // Provides access to the frame bytes, which is a buffer containing the frame 1193 // Provides access to the frame bytes, which is a buffer containing the frame
1194 // packed as expected for sending over the wire. 1194 // packed as expected for sending over the wire.
1195 char* data() const { return frame_; } 1195 char* data() const { return frame_; }
1196 1196
1197 // Returns the actual size of the underlying buffer. 1197 // Returns the actual size of the underlying buffer.
1198 size_t size() const { return size_; } 1198 size_t size() const { return size_; }
1199 1199
1200 // Returns a buffer containing the contents of the frame, of which the caller
1201 // takes ownership, and clears this SpdySerializedFrame.
1202 char* ReleaseBuffer() {
1203 char* buffer;
1204 if (owns_buffer_) {
1205 // If the buffer is owned, relinquish ownership to the caller.
1206 buffer = frame_;
1207 owns_buffer_ = false;
1208 } else {
1209 // Otherwise, we need to make a copy to give to the caller.
1210 buffer = new char[size_];
1211 memcpy(buffer, frame_, size_);
1212 }
1213 *this = SpdySerializedFrame();
1214 return buffer;
1215 }
1216
1200 protected: 1217 protected:
1201 char* frame_; 1218 char* frame_;
1202 1219
1203 private: 1220 private:
1204 size_t size_; 1221 size_t size_;
1205 bool owns_buffer_; 1222 bool owns_buffer_;
1206 DISALLOW_COPY_AND_ASSIGN(SpdySerializedFrame); 1223 DISALLOW_COPY_AND_ASSIGN(SpdySerializedFrame);
1207 }; 1224 };
1208 1225
1209 // This interface is for classes that want to process SpdyFrameIRs without 1226 // This interface is for classes that want to process SpdyFrameIRs without
(...skipping 21 matching lines...) Expand all
1231 SpdyFrameVisitor() {} 1248 SpdyFrameVisitor() {}
1232 virtual ~SpdyFrameVisitor() {} 1249 virtual ~SpdyFrameVisitor() {}
1233 1250
1234 private: 1251 private:
1235 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); 1252 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor);
1236 }; 1253 };
1237 1254
1238 } // namespace net 1255 } // namespace net
1239 1256
1240 #endif // NET_SPDY_SPDY_PROTOCOL_H_ 1257 #endif // NET_SPDY_SPDY_PROTOCOL_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