OLD | NEW |
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 // Serializes all frames into a single packet. All frames must fit into a | 104 // Serializes all frames into a single packet. All frames must fit into a |
105 // single packet. Also, sets the entropy hash of the serialized packet to a | 105 // single packet. Also, sets the entropy hash of the serialized packet to a |
106 // random bool and returns that value as a member of SerializedPacket. | 106 // random bool and returns that value as a member of SerializedPacket. |
107 // Never returns a RetransmittableFrames in SerializedPacket. | 107 // Never returns a RetransmittableFrames in SerializedPacket. |
108 SerializedPacket SerializeAllFrames(const QuicFrames& frames); | 108 SerializedPacket SerializeAllFrames(const QuicFrames& frames); |
109 | 109 |
110 // Re-serializes frames with the original packet's sequence number length. | 110 // Re-serializes frames with the original packet's sequence number length. |
111 // Used for retransmitting packets to ensure they aren't too long. | 111 // Used for retransmitting packets to ensure they aren't too long. |
112 SerializedPacket ReserializeAllFrames( | 112 SerializedPacket ReserializeAllFrames( |
113 const QuicFrames& frames, QuicSequenceNumberLength original_length); | 113 const QuicFrames& frames, |
| 114 QuicSequenceNumberLength original_length); |
114 | 115 |
115 // Returns true if there are frames pending to be serialized. | 116 // Returns true if there are frames pending to be serialized. |
116 bool HasPendingFrames(); | 117 bool HasPendingFrames(); |
117 | 118 |
118 // Returns IN_FEC_GROUP or NOT_IN_FEC_GROUP, depending on whether FEC is | 119 // Returns IN_FEC_GROUP or NOT_IN_FEC_GROUP, depending on whether FEC is |
119 // enabled or not. Note: This does not mean that an FEC group is currently | 120 // enabled or not. Note: This does not mean that an FEC group is currently |
120 // active; i.e., fec_group_.get() may still be NULL. | 121 // active; i.e., fec_group_.get() may still be NULL. |
121 // TODO(jri): Straighten out naming: Enabling FEC for the connection | 122 // TODO(jri): Straighten out naming: Enabling FEC for the connection |
122 // should use FEC_ENABLED/DISABLED, and IN_FEC_GROUP/NOT_IN_FEC_GROUP should | 123 // should use FEC_ENABLED/DISABLED, and IN_FEC_GROUP/NOT_IN_FEC_GROUP should |
123 // be used if a given packet is in an fec group. | 124 // be used if a given packet is in an fec group. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 172 |
172 // Creates a version negotiation packet which supports |supported_versions|. | 173 // Creates a version negotiation packet which supports |supported_versions|. |
173 // Caller owns the created packet. Also, sets the entropy hash of the | 174 // Caller owns the created packet. Also, sets the entropy hash of the |
174 // serialized packet to a random bool and returns that value as a member of | 175 // serialized packet to a random bool and returns that value as a member of |
175 // SerializedPacket. | 176 // SerializedPacket. |
176 QuicEncryptedPacket* SerializeVersionNegotiationPacket( | 177 QuicEncryptedPacket* SerializeVersionNegotiationPacket( |
177 const QuicVersionVector& supported_versions); | 178 const QuicVersionVector& supported_versions); |
178 | 179 |
179 // Sequence number of the last created packet, or 0 if no packets have been | 180 // Sequence number of the last created packet, or 0 if no packets have been |
180 // created. | 181 // created. |
181 QuicPacketSequenceNumber sequence_number() const { | 182 QuicPacketSequenceNumber sequence_number() const { return sequence_number_; } |
182 return sequence_number_; | |
183 } | |
184 | 183 |
185 void set_sequence_number(QuicPacketSequenceNumber s) { | 184 void set_sequence_number(QuicPacketSequenceNumber s) { sequence_number_ = s; } |
186 sequence_number_ = s; | |
187 } | |
188 | 185 |
189 Options* options() { | 186 Options* options() { return &options_; } |
190 return &options_; | |
191 } | |
192 | 187 |
193 private: | 188 private: |
194 friend class test::QuicPacketCreatorPeer; | 189 friend class test::QuicPacketCreatorPeer; |
195 | 190 |
196 static bool ShouldRetransmit(const QuicFrame& frame); | 191 static bool ShouldRetransmit(const QuicFrame& frame); |
197 | 192 |
198 // Starts a new FEC group with the next serialized packet, if FEC is enabled | 193 // Starts a new FEC group with the next serialized packet, if FEC is enabled |
199 // and there is not already an FEC group open. | 194 // and there is not already an FEC group open. |
200 InFecGroup MaybeStartFEC(); | 195 InFecGroup MaybeStartFEC(); |
201 | 196 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 mutable size_t packet_size_; | 228 mutable size_t packet_size_; |
234 QuicFrames queued_frames_; | 229 QuicFrames queued_frames_; |
235 scoped_ptr<RetransmittableFrames> queued_retransmittable_frames_; | 230 scoped_ptr<RetransmittableFrames> queued_retransmittable_frames_; |
236 | 231 |
237 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator); | 232 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator); |
238 }; | 233 }; |
239 | 234 |
240 } // namespace net | 235 } // namespace net |
241 | 236 |
242 #endif // NET_QUIC_QUIC_PACKET_CREATOR_H_ | 237 #endif // NET_QUIC_QUIC_PACKET_CREATOR_H_ |
OLD | NEW |