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_ |
11 | 11 |
| 12 #include <string> |
12 #include <utility> | 13 #include <utility> |
13 #include <vector> | 14 #include <vector> |
14 | 15 |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
17 #include "net/quic/quic_fec_group.h" | 18 #include "net/quic/quic_fec_group.h" |
18 #include "net/quic/quic_framer.h" | 19 #include "net/quic/quic_framer.h" |
19 #include "net/quic/quic_protocol.h" | 20 #include "net/quic/quic_protocol.h" |
20 | 21 |
21 namespace net { | 22 namespace net { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 185 } |
185 | 186 |
186 void set_connection_id_length(QuicConnectionIdLength length) { | 187 void set_connection_id_length(QuicConnectionIdLength length) { |
187 connection_id_length_ = length; | 188 connection_id_length_ = length; |
188 } | 189 } |
189 | 190 |
190 QuicByteCount max_packet_length() const { | 191 QuicByteCount max_packet_length() const { |
191 return max_packet_length_; | 192 return max_packet_length_; |
192 } | 193 } |
193 | 194 |
194 void set_max_packet_length(QuicByteCount length) { | 195 // Sets the encrypter to use for the encryption level and updates the max |
195 // |max_packet_length_| should not be changed mid-packet or mid-FEC group. | 196 // plaintext size. |
196 DCHECK(fec_group_.get() == nullptr && queued_frames_.empty()); | 197 void SetEncrypter(EncryptionLevel level, QuicEncrypter* encrypter); |
197 max_packet_length_ = length; | 198 |
198 } | 199 // Sets the maximum packet length. |
| 200 void SetMaxPacketLength(QuicByteCount length); |
199 | 201 |
200 // Returns current max number of packets covered by an FEC group. | 202 // Returns current max number of packets covered by an FEC group. |
201 size_t max_packets_per_fec_group() const { | 203 size_t max_packets_per_fec_group() const { |
202 return max_packets_per_fec_group_; | 204 return max_packets_per_fec_group_; |
203 } | 205 } |
204 | 206 |
205 // Sets creator's max number of packets covered by an FEC group. | 207 // Sets creator's max number of packets covered by an FEC group. |
206 // Note: While there are no constraints on |max_packets_per_fec_group|, | 208 // Note: While there are no constraints on |max_packets_per_fec_group|, |
207 // this setter enforces a min value of kLowestMaxPacketsPerFecGroup. | 209 // this setter enforces a min value of kLowestMaxPacketsPerFecGroup. |
208 // To turn off FEC protection, use StopFecProtectingPackets(). | 210 // To turn off FEC protection, use StopFecProtectingPackets(). |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 // a packet or FEC group boundary, when the creator's sequence_number_length_ | 260 // a packet or FEC group boundary, when the creator's sequence_number_length_ |
259 // can be changed to this new value. | 261 // can be changed to this new value. |
260 QuicSequenceNumberLength next_sequence_number_length_; | 262 QuicSequenceNumberLength next_sequence_number_length_; |
261 // Sequence number length for the current packet and for the current FEC group | 263 // Sequence number length for the current packet and for the current FEC group |
262 // when FEC is enabled. Mutable so PacketSize() can adjust it when the packet | 264 // when FEC is enabled. Mutable so PacketSize() can adjust it when the packet |
263 // is empty. | 265 // is empty. |
264 mutable QuicSequenceNumberLength sequence_number_length_; | 266 mutable QuicSequenceNumberLength sequence_number_length_; |
265 // packet_size_ is mutable because it's just a cache of the current size. | 267 // packet_size_ is mutable because it's just a cache of the current size. |
266 // packet_size should never be read directly, use PacketSize() instead. | 268 // packet_size should never be read directly, use PacketSize() instead. |
267 mutable size_t packet_size_; | 269 mutable size_t packet_size_; |
| 270 mutable size_t max_plaintext_size_; |
268 QuicFrames queued_frames_; | 271 QuicFrames queued_frames_; |
269 scoped_ptr<RetransmittableFrames> queued_retransmittable_frames_; | 272 scoped_ptr<RetransmittableFrames> queued_retransmittable_frames_; |
270 | 273 |
271 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator); | 274 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator); |
272 }; | 275 }; |
273 | 276 |
274 } // namespace net | 277 } // namespace net |
275 | 278 |
276 #endif // NET_QUIC_QUIC_PACKET_CREATOR_H_ | 279 #endif // NET_QUIC_QUIC_PACKET_CREATOR_H_ |
OLD | NEW |