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

Side by Side Diff: net/quic/quic_protocol.h

Issue 12334063: Land recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more EXPECT_FALSE Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_packet_generator_test.cc ('k') | net/quic/quic_protocol.cc » ('j') | 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 #ifndef NET_QUIC_QUIC_PROTOCOL_H_ 5 #ifndef NET_QUIC_QUIC_PROTOCOL_H_
6 #define NET_QUIC_QUIC_PROTOCOL_H_ 6 #define NET_QUIC_QUIC_PROTOCOL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 17 matching lines...) Expand all
28 using ::operator<<; 28 using ::operator<<;
29 29
30 class QuicPacket; 30 class QuicPacket;
31 31
32 typedef uint64 QuicGuid; 32 typedef uint64 QuicGuid;
33 typedef uint32 QuicStreamId; 33 typedef uint32 QuicStreamId;
34 typedef uint64 QuicStreamOffset; 34 typedef uint64 QuicStreamOffset;
35 typedef uint64 QuicPacketSequenceNumber; 35 typedef uint64 QuicPacketSequenceNumber;
36 typedef QuicPacketSequenceNumber QuicFecGroupNumber; 36 typedef QuicPacketSequenceNumber QuicFecGroupNumber;
37 typedef uint64 QuicPublicResetNonceProof; 37 typedef uint64 QuicPublicResetNonceProof;
38 typedef uint8 QuicPacketEntropyHash;
38 39
39 // TODO(rch): Consider Quic specific names for these constants. 40 // TODO(rch): Consider Quic specific names for these constants.
40 // Maximum size in bytes of a QUIC packet. 41 // Maximum size in bytes of a QUIC packet.
41 const QuicByteCount kMaxPacketSize = 1200; 42 const QuicByteCount kMaxPacketSize = 1200;
42 43
43 // Maximum number of open streams per connection. 44 // Maximum number of open streams per connection.
44 const size_t kDefaultMaxStreamsPerConnection = 100; 45 const size_t kDefaultMaxStreamsPerConnection = 100;
45 46
46 // Number of bytes reserved for guid in the packet header. 47 // Number of bytes reserved for guid in the packet header.
47 const size_t kQuicGuidSize = 8; 48 const size_t kQuicGuidSize = 8;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // Limit on the delta between stream IDs. 99 // Limit on the delta between stream IDs.
99 const QuicStreamId kMaxStreamIdDelta = 100; 100 const QuicStreamId kMaxStreamIdDelta = 100;
100 101
101 // Reserved ID for the crypto stream. 102 // Reserved ID for the crypto stream.
102 // TODO(rch): ensure that this is not usable by any other streams. 103 // TODO(rch): ensure that this is not usable by any other streams.
103 const QuicStreamId kCryptoStreamId = 1; 104 const QuicStreamId kCryptoStreamId = 1;
104 105
105 // Value which indicates this packet is not FEC protected. 106 // Value which indicates this packet is not FEC protected.
106 const uint8 kNoFecOffset = 0xFF; 107 const uint8 kNoFecOffset = 0xFF;
107 108
108 typedef std::pair<QuicPacketSequenceNumber, QuicPacket*> PacketPair;
109
110 const int64 kDefaultTimeoutUs = 600000000; // 10 minutes. 109 const int64 kDefaultTimeoutUs = 600000000; // 10 minutes.
111 110
112 enum QuicFrameType { 111 enum QuicFrameType {
113 PADDING_FRAME = 0, 112 PADDING_FRAME = 0,
114 STREAM_FRAME, 113 STREAM_FRAME,
115 ACK_FRAME, 114 ACK_FRAME,
116 CONGESTION_FEEDBACK_FRAME, 115 CONGESTION_FEEDBACK_FRAME,
117 RST_STREAM_FRAME, 116 RST_STREAM_FRAME,
118 CONNECTION_CLOSE_FRAME, 117 CONNECTION_CLOSE_FRAME,
118 GOAWAY_FRAME,
119 NUM_FRAME_TYPES 119 NUM_FRAME_TYPES
120 }; 120 };
121 121
122 enum QuicPacketPublicFlags { 122 enum QuicPacketPublicFlags {
123 PACKET_PUBLIC_FLAGS_NONE = 0, 123 PACKET_PUBLIC_FLAGS_NONE = 0,
124 PACKET_PUBLIC_FLAGS_VERSION = 1, 124 PACKET_PUBLIC_FLAGS_VERSION = 1 << 0,
125 PACKET_PUBLIC_FLAGS_RST = 2, // Packet is a public reset packet. 125 PACKET_PUBLIC_FLAGS_RST = 1 << 1, // Packet is a public reset packet.
126 PACKET_PUBLIC_FLAGS_MAX = 3 // Both bit set. 126 PACKET_PUBLIC_FLAGS_MAX = (1 << 2) - 1 // All bits set.
127 }; 127 };
128 128
129 enum QuicPacketPrivateFlags { 129 enum QuicPacketPrivateFlags {
130 PACKET_PRIVATE_FLAGS_NONE = 0, 130 PACKET_PRIVATE_FLAGS_NONE = 0,
131 PACKET_PRIVATE_FLAGS_FEC = 1, // Payload is FEC as opposed to frames. 131 PACKET_PRIVATE_FLAGS_FEC = 1 << 0, // Payload is FEC as opposed to frames.
132 PACKET_PRIVATE_FLAGS_MAX = PACKET_PRIVATE_FLAGS_FEC 132 PACKET_PRIVATE_FLAGS_ENTROPY = 1 << 1,
133 PACKET_PRIVATE_FLAGS_FEC_ENTROPY = 1 << 2,
134 PACKET_PRIVATE_FLAGS_MAX = (1 << 3) - 1 // All bits set.
133 }; 135 };
134 136
135 enum QuicVersion { 137 enum QuicVersion {
136 QUIC_VERSION_1 = 0 138 QUIC_VERSION_1 = 0
137 }; 139 };
138 140
139 enum QuicErrorCode { 141 enum QuicErrorCode {
140 // Stream errors. 142 // Stream errors.
141 QUIC_NO_ERROR = 0, 143 QUIC_NO_ERROR = 0,
142 144
(...skipping 11 matching lines...) Expand all
154 // Control frame is malformed. 156 // Control frame is malformed.
155 QUIC_INVALID_PACKET_HEADER, 157 QUIC_INVALID_PACKET_HEADER,
156 // Frame data is malformed. 158 // Frame data is malformed.
157 QUIC_INVALID_FRAME_DATA, 159 QUIC_INVALID_FRAME_DATA,
158 // FEC data is malformed. 160 // FEC data is malformed.
159 QUIC_INVALID_FEC_DATA, 161 QUIC_INVALID_FEC_DATA,
160 // Stream rst data is malformed 162 // Stream rst data is malformed
161 QUIC_INVALID_RST_STREAM_DATA, 163 QUIC_INVALID_RST_STREAM_DATA,
162 // Connection close data is malformed. 164 // Connection close data is malformed.
163 QUIC_INVALID_CONNECTION_CLOSE_DATA, 165 QUIC_INVALID_CONNECTION_CLOSE_DATA,
166 // GoAway data is malformed.
167 QUIC_INVALID_GOAWAY_DATA,
164 // Ack data is malformed. 168 // Ack data is malformed.
165 QUIC_INVALID_ACK_DATA, 169 QUIC_INVALID_ACK_DATA,
166 // There was an error decrypting. 170 // There was an error decrypting.
167 QUIC_DECRYPTION_FAILURE, 171 QUIC_DECRYPTION_FAILURE,
168 // There was an error encrypting. 172 // There was an error encrypting.
169 QUIC_ENCRYPTION_FAILURE, 173 QUIC_ENCRYPTION_FAILURE,
170 // The packet exceeded kMaxPacketSize. 174 // The packet exceeded kMaxPacketSize.
171 QUIC_PACKET_TOO_LARGE, 175 QUIC_PACKET_TOO_LARGE,
172 // Data was sent for a stream which did not exist. 176 // Data was sent for a stream which did not exist.
173 QUIC_PACKET_FOR_NONEXISTENT_STREAM, 177 QUIC_PACKET_FOR_NONEXISTENT_STREAM,
174 // The client is going away (browser close, etc.) 178 // The peer is going away. May be a client or server.
175 QUIC_CLIENT_GOING_AWAY, 179 QUIC_PEER_GOING_AWAY,
176 // The server is going away (restart etc.)
177 QUIC_SERVER_GOING_AWAY,
178 // A stream ID was invalid. 180 // A stream ID was invalid.
179 QUIC_INVALID_STREAM_ID, 181 QUIC_INVALID_STREAM_ID,
180 // Too many streams already open. 182 // Too many streams already open.
181 QUIC_TOO_MANY_OPEN_STREAMS, 183 QUIC_TOO_MANY_OPEN_STREAMS,
182 // Received public reset for this connection. 184 // Received public reset for this connection.
183 QUIC_PUBLIC_RESET, 185 QUIC_PUBLIC_RESET,
184 186
185 // We hit our prenegotiated (or default) timeout 187 // We hit our prenegotiated (or default) timeout
186 QUIC_CONNECTION_TIMED_OUT, 188 QUIC_CONNECTION_TIMED_OUT,
187 189
(...skipping 15 matching lines...) Expand all
203 QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND, 205 QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND,
204 // A crypto message was received with a parameter that has no overlap 206 // A crypto message was received with a parameter that has no overlap
205 // with the local parameter. 207 // with the local parameter.
206 QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP, 208 QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP,
207 }; 209 };
208 210
209 struct NET_EXPORT_PRIVATE QuicPacketPublicHeader { 211 struct NET_EXPORT_PRIVATE QuicPacketPublicHeader {
210 // Universal header. All QuicPacket headers will have a guid and public flags. 212 // Universal header. All QuicPacket headers will have a guid and public flags.
211 // TODO(satyamshekhar): Support versioning as per Protocol Negotiation Doc. 213 // TODO(satyamshekhar): Support versioning as per Protocol Negotiation Doc.
212 QuicGuid guid; 214 QuicGuid guid;
213 QuicPacketPublicFlags flags; 215 bool reset_flag;
216 bool version_flag;
214 }; 217 };
215 218
216 // Header for Data or FEC packets. 219 // Header for Data or FEC packets.
217 struct QuicPacketHeader { 220 struct QuicPacketHeader {
218 QuicPacketHeader() {} 221 QuicPacketHeader() {}
219 explicit QuicPacketHeader(const QuicPacketPublicHeader& header) 222 explicit QuicPacketHeader(const QuicPacketPublicHeader& header)
220 : public_header(header) {} 223 : public_header(header) {}
224
225 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
226 std::ostream& os, const QuicPacketHeader& s);
227
221 QuicPacketPublicHeader public_header; 228 QuicPacketPublicHeader public_header;
222 QuicPacketPrivateFlags private_flags; 229 bool fec_flag;
230 bool fec_entropy_flag;
231 bool entropy_flag;
232 QuicPacketEntropyHash entropy_hash;
223 QuicPacketSequenceNumber packet_sequence_number; 233 QuicPacketSequenceNumber packet_sequence_number;
224 QuicFecGroupNumber fec_group; 234 QuicFecGroupNumber fec_group;
225 }; 235 };
226 236
227 struct QuicPublicResetPacket { 237 struct QuicPublicResetPacket {
228 QuicPublicResetPacket() {} 238 QuicPublicResetPacket() {}
229 explicit QuicPublicResetPacket(const QuicPacketPublicHeader& header) 239 explicit QuicPublicResetPacket(const QuicPacketPublicHeader& header)
230 : public_header(header) {} 240 : public_header(header) {}
231 QuicPacketPublicHeader public_header; 241 QuicPacketPublicHeader public_header;
232 QuicPacketSequenceNumber rejected_sequence_number; 242 QuicPacketSequenceNumber rejected_sequence_number;
(...skipping 12 matching lines...) Expand all
245 base::StringPiece data); 255 base::StringPiece data);
246 256
247 QuicStreamId stream_id; 257 QuicStreamId stream_id;
248 bool fin; 258 bool fin;
249 QuicStreamOffset offset; // Location of this data in the stream. 259 QuicStreamOffset offset; // Location of this data in the stream.
250 base::StringPiece data; 260 base::StringPiece data;
251 }; 261 };
252 262
253 // TODO(ianswett): Re-evaluate the trade-offs of hash_set vs set when framing 263 // TODO(ianswett): Re-evaluate the trade-offs of hash_set vs set when framing
254 // is finalized. 264 // is finalized.
255 typedef std::set<QuicPacketSequenceNumber> SequenceSet; 265 typedef std::set<QuicPacketSequenceNumber> SequenceNumberSet;
256 // TODO(pwestin): Add a way to enforce the max size of this map. 266 // TODO(pwestin): Add a way to enforce the max size of this map.
257 typedef std::map<QuicPacketSequenceNumber, QuicTime> TimeMap; 267 typedef std::map<QuicPacketSequenceNumber, QuicTime> TimeMap;
258 268
259 struct NET_EXPORT_PRIVATE ReceivedPacketInfo { 269 struct NET_EXPORT_PRIVATE ReceivedPacketInfo {
260 ReceivedPacketInfo(); 270 ReceivedPacketInfo();
261 ~ReceivedPacketInfo(); 271 ~ReceivedPacketInfo();
262 NET_EXPORT_PRIVATE friend std::ostream& operator<<( 272 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
263 std::ostream& os, const ReceivedPacketInfo& s); 273 std::ostream& os, const ReceivedPacketInfo& s);
264 274
265 // Records a packet receipt. 275 // Entropy hash of all packets up to largest observed not including missing
266 void RecordReceived(QuicPacketSequenceNumber sequence_number); 276 // packets.
267 277 QuicPacketEntropyHash entropy_hash;
268 // True if the sequence number is greater than largest_observed or is listed
269 // as missing.
270 // Always returns false for sequence numbers less than least_unacked.
271 bool IsAwaitingPacket(QuicPacketSequenceNumber sequence_number) const;
272
273 // Clears all missing packets less than |least_unacked|.
274 void ClearMissingBefore(QuicPacketSequenceNumber least_unacked);
275 278
276 // The highest packet sequence number we've observed from the peer. 279 // The highest packet sequence number we've observed from the peer.
277 // 280 //
278 // In general, this should be the largest packet number we've received. In 281 // In general, this should be the largest packet number we've received. In
279 // the case of truncated acks, we may have to advertise a lower "upper bound" 282 // the case of truncated acks, we may have to advertise a lower "upper bound"
280 // than largest received, to avoid implicitly acking missing packets that 283 // than largest received, to avoid implicitly acking missing packets that
281 // don't fit in the missing packet list due to size limitations. In this 284 // don't fit in the missing packet list due to size limitations. In this
282 // case, largest_observed may be a packet which is also in the missing packets 285 // case, largest_observed may be a packet which is also in the missing packets
283 // list. 286 // list.
284 QuicPacketSequenceNumber largest_observed; 287 QuicPacketSequenceNumber largest_observed;
285 288
289 // TODO(satyamshekhar): Can be optimized using an interval set like data
290 // structure.
286 // The set of packets which we're expecting and have not received. 291 // The set of packets which we're expecting and have not received.
287 SequenceSet missing_packets; 292 SequenceNumberSet missing_packets;
288 }; 293 };
289 294
295 // True if the sequence number is greater than largest_observed or is listed
296 // as missing.
297 // Always returns false for sequence numbers less than least_unacked.
298 bool NET_EXPORT_PRIVATE IsAwaitingPacket(
299 const ReceivedPacketInfo& received_info,
300 QuicPacketSequenceNumber sequence_number);
301
302 // Inserts missing packets between [lower, higher).
303 void NET_EXPORT_PRIVATE InsertMissingPacketsBetween(
304 ReceivedPacketInfo* received_info,
305 QuicPacketSequenceNumber lower,
306 QuicPacketSequenceNumber higher);
307
290 struct NET_EXPORT_PRIVATE SentPacketInfo { 308 struct NET_EXPORT_PRIVATE SentPacketInfo {
291 SentPacketInfo(); 309 SentPacketInfo();
292 ~SentPacketInfo(); 310 ~SentPacketInfo();
293 NET_EXPORT_PRIVATE friend std::ostream& operator<<( 311 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
294 std::ostream& os, const SentPacketInfo& s); 312 std::ostream& os, const SentPacketInfo& s);
295 313
314 // Entropy hash of all packets up to, but not including, the least unacked
315 // packet.
316 QuicPacketEntropyHash entropy_hash;
296 // The lowest packet we've sent which is unacked, and we expect an ack for. 317 // The lowest packet we've sent which is unacked, and we expect an ack for.
297 QuicPacketSequenceNumber least_unacked; 318 QuicPacketSequenceNumber least_unacked;
298 }; 319 };
299 320
300 struct NET_EXPORT_PRIVATE QuicAckFrame { 321 struct NET_EXPORT_PRIVATE QuicAckFrame {
301 QuicAckFrame() {} 322 QuicAckFrame() {}
302 // Testing convenience method to construct a QuicAckFrame with all packets 323 // Testing convenience method to construct a QuicAckFrame with all packets
303 // from least_unacked to largest_observed acked. 324 // from least_unacked to largest_observed acked.
304 QuicAckFrame(QuicPacketSequenceNumber largest_observed, 325 QuicAckFrame(QuicPacketSequenceNumber largest_observed,
305 QuicPacketSequenceNumber least_unacked); 326 QuicPacketSequenceNumber least_unacked);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 CongestionFeedbackType type; 370 CongestionFeedbackType type;
350 // This should really be a union, but since the inter arrival struct 371 // This should really be a union, but since the inter arrival struct
351 // is non-trivial, C++ prohibits it. 372 // is non-trivial, C++ prohibits it.
352 CongestionFeedbackMessageTCP tcp; 373 CongestionFeedbackMessageTCP tcp;
353 CongestionFeedbackMessageInterArrival inter_arrival; 374 CongestionFeedbackMessageInterArrival inter_arrival;
354 CongestionFeedbackMessageFixRate fix_rate; 375 CongestionFeedbackMessageFixRate fix_rate;
355 }; 376 };
356 377
357 struct NET_EXPORT_PRIVATE QuicRstStreamFrame { 378 struct NET_EXPORT_PRIVATE QuicRstStreamFrame {
358 QuicRstStreamFrame() {} 379 QuicRstStreamFrame() {}
359 QuicRstStreamFrame(QuicStreamId stream_id, uint64 offset, 380 QuicRstStreamFrame(QuicStreamId stream_id, QuicErrorCode error_code)
360 QuicErrorCode error_code) 381 : stream_id(stream_id), error_code(error_code) {
361 : stream_id(stream_id), offset(offset), error_code(error_code) {
362 DCHECK_LE(error_code, std::numeric_limits<uint8>::max()); 382 DCHECK_LE(error_code, std::numeric_limits<uint8>::max());
363 } 383 }
364 384
365 QuicStreamId stream_id; 385 QuicStreamId stream_id;
366 uint64 offset;
367 QuicErrorCode error_code; 386 QuicErrorCode error_code;
368 std::string error_details; 387 std::string error_details;
369 }; 388 };
370 389
371 struct NET_EXPORT_PRIVATE QuicConnectionCloseFrame { 390 struct NET_EXPORT_PRIVATE QuicConnectionCloseFrame {
372 QuicErrorCode error_code; 391 QuicErrorCode error_code;
373 std::string error_details; 392 std::string error_details;
374 QuicAckFrame ack_frame; 393 QuicAckFrame ack_frame;
375 }; 394 };
376 395
396 struct NET_EXPORT_PRIVATE QuicGoAwayFrame {
397 QuicGoAwayFrame() {}
398 QuicGoAwayFrame(QuicErrorCode error_code,
399 QuicStreamId last_good_stream_id,
400 const std::string& reason);
401
402 QuicErrorCode error_code;
403 QuicStreamId last_good_stream_id;
404 std::string reason_phrase;
405 };
406
377 struct NET_EXPORT_PRIVATE QuicFrame { 407 struct NET_EXPORT_PRIVATE QuicFrame {
378 QuicFrame() {} 408 QuicFrame() {}
379 explicit QuicFrame(QuicPaddingFrame* padding_frame) 409 explicit QuicFrame(QuicPaddingFrame* padding_frame)
380 : type(PADDING_FRAME), 410 : type(PADDING_FRAME),
381 padding_frame(padding_frame) { 411 padding_frame(padding_frame) {
382 } 412 }
383 explicit QuicFrame(QuicStreamFrame* stream_frame) 413 explicit QuicFrame(QuicStreamFrame* stream_frame)
384 : type(STREAM_FRAME), 414 : type(STREAM_FRAME),
385 stream_frame(stream_frame) { 415 stream_frame(stream_frame) {
386 } 416 }
387 explicit QuicFrame(QuicAckFrame* frame) 417 explicit QuicFrame(QuicAckFrame* frame)
388 : type(ACK_FRAME), 418 : type(ACK_FRAME),
389 ack_frame(frame) { 419 ack_frame(frame) {
390 } 420 }
391 explicit QuicFrame(QuicCongestionFeedbackFrame* frame) 421 explicit QuicFrame(QuicCongestionFeedbackFrame* frame)
392 : type(CONGESTION_FEEDBACK_FRAME), 422 : type(CONGESTION_FEEDBACK_FRAME),
393 congestion_feedback_frame(frame) { 423 congestion_feedback_frame(frame) {
394 } 424 }
395 explicit QuicFrame(QuicRstStreamFrame* frame) 425 explicit QuicFrame(QuicRstStreamFrame* frame)
396 : type(RST_STREAM_FRAME), 426 : type(RST_STREAM_FRAME),
397 rst_stream_frame(frame) { 427 rst_stream_frame(frame) {
398 } 428 }
399 explicit QuicFrame(QuicConnectionCloseFrame* frame) 429 explicit QuicFrame(QuicConnectionCloseFrame* frame)
400 : type(CONNECTION_CLOSE_FRAME), 430 : type(CONNECTION_CLOSE_FRAME),
401 connection_close_frame(frame) { 431 connection_close_frame(frame) {
402 } 432 }
433 explicit QuicFrame(QuicGoAwayFrame* frame)
434 : type(GOAWAY_FRAME),
435 goaway_frame(frame) {
436 }
403 437
404 QuicFrameType type; 438 QuicFrameType type;
405 union { 439 union {
406 QuicPaddingFrame* padding_frame; 440 QuicPaddingFrame* padding_frame;
407 QuicStreamFrame* stream_frame; 441 QuicStreamFrame* stream_frame;
408 QuicAckFrame* ack_frame; 442 QuicAckFrame* ack_frame;
409 QuicCongestionFeedbackFrame* congestion_feedback_frame; 443 QuicCongestionFeedbackFrame* congestion_feedback_frame;
410 QuicRstStreamFrame* rst_stream_frame; 444 QuicRstStreamFrame* rst_stream_frame;
411 QuicConnectionCloseFrame* connection_close_frame; 445 QuicConnectionCloseFrame* connection_close_frame;
446 QuicGoAwayFrame* goaway_frame;
412 }; 447 };
413 }; 448 };
414 449
415 typedef std::vector<QuicFrame> QuicFrames; 450 typedef std::vector<QuicFrame> QuicFrames;
416 451
417 struct NET_EXPORT_PRIVATE QuicFecData { 452 struct NET_EXPORT_PRIVATE QuicFecData {
418 QuicFecData(); 453 QuicFecData();
419 454
420 bool operator==(const QuicFecData& other) const; 455 bool operator==(const QuicFecData& other) const;
421 456
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 const char* buffer_; 492 const char* buffer_;
458 size_t length_; 493 size_t length_;
459 bool owns_buffer_; 494 bool owns_buffer_;
460 495
461 DISALLOW_COPY_AND_ASSIGN(QuicData); 496 DISALLOW_COPY_AND_ASSIGN(QuicData);
462 }; 497 };
463 498
464 class NET_EXPORT_PRIVATE QuicPacket : public QuicData { 499 class NET_EXPORT_PRIVATE QuicPacket : public QuicData {
465 public: 500 public:
466 static QuicPacket* NewDataPacket(char* buffer, 501 static QuicPacket* NewDataPacket(char* buffer,
467 size_t length, 502 size_t length,
468 bool owns_buffer) { 503 bool owns_buffer) {
469 return new QuicPacket(buffer, length, owns_buffer, false); 504 return new QuicPacket(buffer, length, owns_buffer, false);
470 } 505 }
471 506
472 static QuicPacket* NewFecPacket(char* buffer, 507 static QuicPacket* NewFecPacket(char* buffer,
473 size_t length, 508 size_t length,
474 bool owns_buffer) { 509 bool owns_buffer) {
475 return new QuicPacket(buffer, length, owns_buffer, true); 510 return new QuicPacket(buffer, length, owns_buffer, true);
476 } 511 }
477 512
478 base::StringPiece FecProtectedData() const { 513 base::StringPiece FecProtectedData() const {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 558
524 base::StringPiece AssociatedData() const { 559 base::StringPiece AssociatedData() const {
525 return base::StringPiece(data() + kStartOfHashData, 560 return base::StringPiece(data() + kStartOfHashData,
526 kStartOfEncryptedData - kStartOfHashData); 561 kStartOfEncryptedData - kStartOfHashData);
527 } 562 }
528 563
529 private: 564 private:
530 DISALLOW_COPY_AND_ASSIGN(QuicEncryptedPacket); 565 DISALLOW_COPY_AND_ASSIGN(QuicEncryptedPacket);
531 }; 566 };
532 567
568 class NET_EXPORT_PRIVATE RetransmittableFrames {
569 public:
570 RetransmittableFrames();
571 ~RetransmittableFrames();
572
573 // Allocates a local copy of the referenced StringPiece has QuicStreamFrame
574 // use it.
575 // Takes ownership of |stream_frame|.
576 const QuicFrame& AddStreamFrame(QuicStreamFrame* stream_frame);
577 // Takes ownership of the frame inside |frame|.
578 const QuicFrame& AddNonStreamFrame(const QuicFrame& frame);
579 const QuicFrames& frames() const { return frames_; }
580
581 private:
582 QuicFrames frames_;
583 // Data referenced by the StringPiece of a QuicStreamFrame.
584 std::vector<std::string*> stream_data_;
585
586 DISALLOW_COPY_AND_ASSIGN(RetransmittableFrames);
587 };
588
589 struct NET_EXPORT_PRIVATE SerializedPacket {
590 SerializedPacket(QuicPacketSequenceNumber sequence_number,
591 QuicPacket* packet,
592 QuicPacketEntropyHash entropy_hash,
593 RetransmittableFrames* retransmittable_frames)
594 : sequence_number(sequence_number),
595 packet(packet),
596 entropy_hash(entropy_hash),
597 retransmittable_frames(retransmittable_frames) { }
598
599 QuicPacketSequenceNumber sequence_number;
600 QuicPacket* packet;
601 QuicPacketEntropyHash entropy_hash;
602 RetransmittableFrames* retransmittable_frames;
603 };
604
533 // A struct for functions which consume data payloads and fins. 605 // A struct for functions which consume data payloads and fins.
534 // The first member of the pair indicates bytes consumed. 606 // The first member of the pair indicates bytes consumed.
535 // The second member of the pair indicates if an incoming fin was consumed. 607 // The second member of the pair indicates if an incoming fin was consumed.
536 struct QuicConsumedData { 608 struct QuicConsumedData {
537 QuicConsumedData(size_t bytes_consumed, bool fin_consumed) 609 QuicConsumedData(size_t bytes_consumed, bool fin_consumed)
538 : bytes_consumed(bytes_consumed), 610 : bytes_consumed(bytes_consumed),
539 fin_consumed(fin_consumed) { 611 fin_consumed(fin_consumed) {
540 } 612 }
541 613
542 // By default, gtest prints the raw bytes of an object. The bool data 614 // By default, gtest prints the raw bytes of an object. The bool data
543 // member causes this object to have padding bytes, which causes the 615 // member causes this object to have padding bytes, which causes the
544 // default gtest object printer to read uninitialize memory. So we need 616 // default gtest object printer to read uninitialize memory. So we need
545 // to teach gtest how to print this object. 617 // to teach gtest how to print this object.
546 NET_EXPORT_PRIVATE friend std::ostream& operator<<( 618 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
547 std::ostream& os, const QuicConsumedData& s); 619 std::ostream& os, const QuicConsumedData& s);
548 620
549 size_t bytes_consumed; 621 size_t bytes_consumed;
550 bool fin_consumed; 622 bool fin_consumed;
551 }; 623 };
552 624
553 } // namespace net 625 } // namespace net
554 626
555 #endif // NET_QUIC_QUIC_PROTOCOL_H_ 627 #endif // NET_QUIC_QUIC_PROTOCOL_H_
OLDNEW
« no previous file with comments | « net/quic/quic_packet_generator_test.cc ('k') | net/quic/quic_protocol.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698