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

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

Issue 181483006: PACKET_NBYTE_GUID -> PACKET_NBYTE_CONNECTION_ID (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: small comment fix Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_http_stream_test.cc ('k') | net/quic/quic_packet_creator.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 // Accumulates frames for the next packet until more frames no longer fit or 5 // Accumulates frames for the next packet until more frames no longer fit or
6 // it's time to create a packet from them. Also provides packet creation of 6 // it's time to create a packet from them. Also provides packet creation of
7 // FEC packets based on previously created packets. 7 // FEC packets based on previously created packets.
8 8
9 #ifndef NET_QUIC_QUIC_PACKET_CREATOR_H_ 9 #ifndef NET_QUIC_QUIC_PACKET_CREATOR_H_
10 #define NET_QUIC_QUIC_PACKET_CREATOR_H_ 10 #define NET_QUIC_QUIC_PACKET_CREATOR_H_
(...skipping 16 matching lines...) Expand all
27 class QuicRandom; 27 class QuicRandom;
28 class QuicRandomBoolSource; 28 class QuicRandomBoolSource;
29 29
30 class NET_EXPORT_PRIVATE QuicPacketCreator : public QuicFecBuilderInterface { 30 class NET_EXPORT_PRIVATE QuicPacketCreator : public QuicFecBuilderInterface {
31 public: 31 public:
32 // Options for controlling how packets are created. 32 // Options for controlling how packets are created.
33 struct Options { 33 struct Options {
34 Options() 34 Options()
35 : max_packet_length(kDefaultMaxPacketSize), 35 : max_packet_length(kDefaultMaxPacketSize),
36 max_packets_per_fec_group(0), 36 max_packets_per_fec_group(0),
37 send_guid_length(PACKET_8BYTE_GUID), 37 send_connection_id_length(PACKET_8BYTE_CONNECTION_ID),
38 send_sequence_number_length(PACKET_1BYTE_SEQUENCE_NUMBER) {} 38 send_sequence_number_length(PACKET_1BYTE_SEQUENCE_NUMBER) {}
39 39
40 size_t max_packet_length; 40 size_t max_packet_length;
41 // 0 indicates fec is disabled. 41 // 0 indicates fec is disabled.
42 size_t max_packets_per_fec_group; 42 size_t max_packets_per_fec_group;
43 // Length of guid to send over the wire. 43 // Length of connection_id to send over the wire.
44 QuicGuidLength send_guid_length; 44 QuicConnectionIdLength send_connection_id_length;
45 QuicSequenceNumberLength send_sequence_number_length; 45 QuicSequenceNumberLength send_sequence_number_length;
46 }; 46 };
47 47
48 // QuicRandom* required for packet entropy. 48 // QuicRandom* required for packet entropy.
49 QuicPacketCreator(QuicGuid guid, 49 QuicPacketCreator(QuicConnectionId connection_id,
50 QuicFramer* framer, 50 QuicFramer* framer,
51 QuicRandom* random_generator, 51 QuicRandom* random_generator,
52 bool is_server); 52 bool is_server);
53 53
54 virtual ~QuicPacketCreator(); 54 virtual ~QuicPacketCreator();
55 55
56 // QuicFecBuilderInterface 56 // QuicFecBuilderInterface
57 virtual void OnBuiltFecProtectedPayload(const QuicPacketHeader& header, 57 virtual void OnBuiltFecProtectedPayload(const QuicPacketHeader& header,
58 base::StringPiece payload) OVERRIDE; 58 base::StringPiece payload) OVERRIDE;
59 59
60 // Checks if it's time to send an FEC packet. |force_close| forces this to 60 // Checks if it's time to send an FEC packet. |force_close| forces this to
61 // return true if an fec group is open. 61 // return true if an fec group is open.
62 bool ShouldSendFec(bool force_close) const; 62 bool ShouldSendFec(bool force_close) const;
63 63
64 // Makes the framer not serialize the protocol version in sent packets. 64 // Makes the framer not serialize the protocol version in sent packets.
65 void StopSendingVersion(); 65 void StopSendingVersion();
66 66
67 // Update the sequence number length to use in future packets as soon as it 67 // Update the sequence number length to use in future packets as soon as it
68 // can be safely changed. 68 // can be safely changed.
69 void UpdateSequenceNumberLength( 69 void UpdateSequenceNumberLength(
70 QuicPacketSequenceNumber least_packet_awaited_by_peer, 70 QuicPacketSequenceNumber least_packet_awaited_by_peer,
71 QuicByteCount bytes_per_second); 71 QuicByteCount bytes_per_second);
72 72
73 // The overhead the framing will add for a packet with one frame. 73 // The overhead the framing will add for a packet with one frame.
74 static size_t StreamFramePacketOverhead( 74 static size_t StreamFramePacketOverhead(
75 QuicVersion version, 75 QuicVersion version,
76 QuicGuidLength guid_length, 76 QuicConnectionIdLength connection_id_length,
77 bool include_version, 77 bool include_version,
78 QuicSequenceNumberLength sequence_number_length, 78 QuicSequenceNumberLength sequence_number_length,
79 InFecGroup is_in_fec_group); 79 InFecGroup is_in_fec_group);
80 80
81 bool HasRoomForStreamFrame(QuicStreamId id, QuicStreamOffset offset) const; 81 bool HasRoomForStreamFrame(QuicStreamId id, QuicStreamOffset offset) const;
82 82
83 // Converts a raw payload to a frame which fits into the currently open 83 // Converts a raw payload to a frame which fits into the currently open
84 // packet if there is one. Returns the number of bytes consumed from data. 84 // packet if there is one. Returns the number of bytes consumed from data.
85 // If data is empty and fin is true, the expected behavior is to consume the 85 // If data is empty and fin is true, the expected behavior is to consume the
86 // fin but return 0. 86 // fin but return 0.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // Allows a frame to be added without creating retransmittable frames. 191 // Allows a frame to be added without creating retransmittable frames.
192 // Particularly useful for retransmits using SerializeAllFrames(). 192 // Particularly useful for retransmits using SerializeAllFrames().
193 bool AddFrame(const QuicFrame& frame, bool save_retransmittable_frames); 193 bool AddFrame(const QuicFrame& frame, bool save_retransmittable_frames);
194 194
195 // Adds a padding frame to the current packet only if the current packet 195 // Adds a padding frame to the current packet only if the current packet
196 // contains a handshake message, and there is sufficient room to fit a 196 // contains a handshake message, and there is sufficient room to fit a
197 // padding frame. 197 // padding frame.
198 void MaybeAddPadding(); 198 void MaybeAddPadding();
199 199
200 Options options_; 200 Options options_;
201 QuicGuid guid_; 201 QuicConnectionId connection_id_;
202 QuicFramer* framer_; 202 QuicFramer* framer_;
203 scoped_ptr<QuicRandomBoolSource> random_bool_source_; 203 scoped_ptr<QuicRandomBoolSource> random_bool_source_;
204 QuicPacketSequenceNumber sequence_number_; 204 QuicPacketSequenceNumber sequence_number_;
205 QuicFecGroupNumber fec_group_number_; 205 QuicFecGroupNumber fec_group_number_;
206 scoped_ptr<QuicFecGroup> fec_group_; 206 scoped_ptr<QuicFecGroup> fec_group_;
207 // bool to keep track if this packet creator is being used the server. 207 // bool to keep track if this packet creator is being used the server.
208 bool is_server_; 208 bool is_server_;
209 // Controls whether protocol version should be included while serializing the 209 // Controls whether protocol version should be included while serializing the
210 // packet. 210 // packet.
211 bool send_version_in_packet_; 211 bool send_version_in_packet_;
212 // The sequence number length for the current packet and the current FEC group 212 // The sequence number length for the current packet and the current FEC group
213 // if FEC is enabled. 213 // if FEC is enabled.
214 // Mutable so PacketSize() can adjust it when the packet is empty. 214 // Mutable so PacketSize() can adjust it when the packet is empty.
215 mutable QuicSequenceNumberLength sequence_number_length_; 215 mutable QuicSequenceNumberLength sequence_number_length_;
216 // packet_size_ is mutable because it's just a cache of the current size. 216 // packet_size_ is mutable because it's just a cache of the current size.
217 // packet_size should never be read directly, use PacketSize() instead. 217 // packet_size should never be read directly, use PacketSize() instead.
218 mutable size_t packet_size_; 218 mutable size_t packet_size_;
219 QuicFrames queued_frames_; 219 QuicFrames queued_frames_;
220 scoped_ptr<RetransmittableFrames> queued_retransmittable_frames_; 220 scoped_ptr<RetransmittableFrames> queued_retransmittable_frames_;
221 221
222 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator); 222 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator);
223 }; 223 };
224 224
225 } // namespace net 225 } // namespace net
226 226
227 #endif // NET_QUIC_QUIC_PACKET_CREATOR_H_ 227 #endif // NET_QUIC_QUIC_PACKET_CREATOR_H_
OLDNEW
« no previous file with comments | « net/quic/quic_http_stream_test.cc ('k') | net/quic/quic_packet_creator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698