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 14 matching lines...) Expand all Loading... |
25 | 25 |
26 class QuicAckNotifier; | 26 class QuicAckNotifier; |
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 // QuicRandom* required for packet entropy. | 32 // QuicRandom* required for packet entropy. |
33 QuicPacketCreator(QuicConnectionId connection_id, | 33 QuicPacketCreator(QuicConnectionId connection_id, |
34 QuicFramer* framer, | 34 QuicFramer* framer, |
35 QuicRandom* random_generator, | 35 QuicRandom* random_generator); |
36 bool is_server); | |
37 | 36 |
38 virtual ~QuicPacketCreator(); | 37 virtual ~QuicPacketCreator(); |
39 | 38 |
40 // QuicFecBuilderInterface | 39 // QuicFecBuilderInterface |
41 virtual void OnBuiltFecProtectedPayload(const QuicPacketHeader& header, | 40 virtual void OnBuiltFecProtectedPayload(const QuicPacketHeader& header, |
42 base::StringPiece payload) OVERRIDE; | 41 base::StringPiece payload) OVERRIDE; |
43 | 42 |
44 // Turn on FEC protection for subsequently created packets. FEC should be | 43 // Turn on FEC protection for subsequently created packets. FEC should be |
45 // enabled first (max_packets_per_fec_group should be non-zero) for FEC | 44 // enabled first (max_packets_per_fec_group should be non-zero) for FEC |
46 // protection to start. | 45 // protection to start. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // single packet. Also, sets the entropy hash of the serialized packet to a | 103 // single packet. Also, sets the entropy hash of the serialized packet to a |
105 // random bool and returns that value as a member of SerializedPacket. | 104 // random bool and returns that value as a member of SerializedPacket. |
106 // Never returns a RetransmittableFrames in SerializedPacket. | 105 // Never returns a RetransmittableFrames in SerializedPacket. |
107 SerializedPacket SerializeAllFrames(const QuicFrames& frames); | 106 SerializedPacket SerializeAllFrames(const QuicFrames& frames); |
108 | 107 |
109 // Re-serializes frames with the original packet's sequence number length. | 108 // Re-serializes frames with the original packet's sequence number length. |
110 // Used for retransmitting packets to ensure they aren't too long. | 109 // Used for retransmitting packets to ensure they aren't too long. |
111 // Caller must ensure that any open FEC group is closed before calling this | 110 // Caller must ensure that any open FEC group is closed before calling this |
112 // method. | 111 // method. |
113 SerializedPacket ReserializeAllFrames( | 112 SerializedPacket ReserializeAllFrames( |
114 const QuicFrames& frames, QuicSequenceNumberLength original_length); | 113 const QuicFrames& frames, |
| 114 QuicSequenceNumberLength original_length); |
115 | 115 |
116 // Returns true if there are frames pending to be serialized. | 116 // Returns true if there are frames pending to be serialized. |
117 bool HasPendingFrames() const; | 117 bool HasPendingFrames() const; |
118 | 118 |
119 // Returns whether FEC protection is currently enabled. Note: Enabled does not | 119 // Returns whether FEC protection is currently enabled. Note: Enabled does not |
120 // mean that an FEC group is currently active; i.e., IsFecProtected() may | 120 // mean that an FEC group is currently active; i.e., IsFecProtected() may |
121 // still return false. | 121 // still return false. |
122 bool IsFecEnabled() const; | 122 bool IsFecEnabled() const; |
123 | 123 |
124 // Returns true if subsequent packets will be FEC protected. Note: True does | 124 // Returns true if subsequent packets will be FEC protected. Note: True does |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 | 257 |
258 QuicConnectionId connection_id_; | 258 QuicConnectionId connection_id_; |
259 EncryptionLevel encryption_level_; | 259 EncryptionLevel encryption_level_; |
260 QuicFramer* framer_; | 260 QuicFramer* framer_; |
261 scoped_ptr<QuicRandomBoolSource> random_bool_source_; | 261 scoped_ptr<QuicRandomBoolSource> random_bool_source_; |
262 QuicPacketSequenceNumber sequence_number_; | 262 QuicPacketSequenceNumber sequence_number_; |
263 // If true, any created packets will be FEC protected. | 263 // If true, any created packets will be FEC protected. |
264 bool should_fec_protect_; | 264 bool should_fec_protect_; |
265 QuicFecGroupNumber fec_group_number_; | 265 QuicFecGroupNumber fec_group_number_; |
266 scoped_ptr<QuicFecGroup> fec_group_; | 266 scoped_ptr<QuicFecGroup> fec_group_; |
267 // bool to keep track if this packet creator is being used the server. | |
268 bool is_server_; | |
269 // Controls whether protocol version should be included while serializing the | 267 // Controls whether protocol version should be included while serializing the |
270 // packet. | 268 // packet. |
271 bool send_version_in_packet_; | 269 bool send_version_in_packet_; |
272 // Maximum length including headers and encryption (UDP payload length.) | 270 // Maximum length including headers and encryption (UDP payload length.) |
273 size_t max_packet_length_; | 271 size_t max_packet_length_; |
274 // 0 indicates FEC is disabled. | 272 // 0 indicates FEC is disabled. |
275 size_t max_packets_per_fec_group_; | 273 size_t max_packets_per_fec_group_; |
276 // Length of connection_id to send over the wire. | 274 // Length of connection_id to send over the wire. |
277 QuicConnectionIdLength connection_id_length_; | 275 QuicConnectionIdLength connection_id_length_; |
278 // Staging variable to hold next packet sequence number length. When sequence | 276 // Staging variable to hold next packet sequence number length. When sequence |
(...skipping 10 matching lines...) Expand all Loading... |
289 mutable size_t packet_size_; | 287 mutable size_t packet_size_; |
290 QuicFrames queued_frames_; | 288 QuicFrames queued_frames_; |
291 scoped_ptr<RetransmittableFrames> queued_retransmittable_frames_; | 289 scoped_ptr<RetransmittableFrames> queued_retransmittable_frames_; |
292 | 290 |
293 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator); | 291 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator); |
294 }; | 292 }; |
295 | 293 |
296 } // namespace net | 294 } // namespace net |
297 | 295 |
298 #endif // NET_QUIC_QUIC_PACKET_CREATOR_H_ | 296 #endif // NET_QUIC_QUIC_PACKET_CREATOR_H_ |
OLD | NEW |