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

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

Issue 849123003: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed extra blank line Created 5 years, 11 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
« no previous file with comments | « net/quic/quic_packet_creator.h ('k') | net/quic/quic_packet_generator.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 // Responsible for generating packets on behalf of a QuicConnection. 5 // Responsible for generating packets on behalf of a QuicConnection.
6 // Packets are serialized just-in-time. Control frames are queued. 6 // Packets are serialized just-in-time. Control frames are queued.
7 // Ack and Feedback frames will be requested from the Connection 7 // Ack and Feedback frames will be requested from the Connection
8 // just-in-time. When a packet needs to be sent, the Generator 8 // just-in-time. When a packet needs to be sent, the Generator
9 // will serialize a packet and pass it to QuicConnection::SendOrQueuePacket() 9 // will serialize a packet and pass it to QuicConnection::SendOrQueuePacket()
10 // 10 //
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 // Update the sequence number length to use in future packets as soon as it 165 // Update the sequence number length to use in future packets as soon as it
166 // can be safely changed. 166 // can be safely changed.
167 void UpdateSequenceNumberLength( 167 void UpdateSequenceNumberLength(
168 QuicPacketSequenceNumber least_packet_awaited_by_peer, 168 QuicPacketSequenceNumber least_packet_awaited_by_peer,
169 QuicPacketCount max_packets_in_flight); 169 QuicPacketCount max_packets_in_flight);
170 170
171 // Set the minimum number of bytes for the connection id length; 171 // Set the minimum number of bytes for the connection id length;
172 void SetConnectionIdLength(uint32 length); 172 void SetConnectionIdLength(uint32 length);
173 173
174 // Called when the FEC alarm fires.
175 void OnFecTimeout();
176
177 // Called after sending |sequence_number| to determine whether an FEC alarm
178 // should be set for sending out an FEC packet. Returns a positive and finite
179 // timeout if an FEC alarm should be set, and infinite if no alarm should be
180 // set. OnFecTimeout should be called to send the FEC packet when the alarm
181 // fires.
182 QuicTime::Delta GetFecTimeout(QuicPacketSequenceNumber sequence_number);
183
174 // Sets the encryption level that will be applied to new packets. 184 // Sets the encryption level that will be applied to new packets.
175 void set_encryption_level(EncryptionLevel level); 185 void set_encryption_level(EncryptionLevel level);
176 186
177 // Sequence number of the last created packet, or 0 if no packets have been 187 // Sequence number of the last created packet, or 0 if no packets have been
178 // created. 188 // created.
179 QuicPacketSequenceNumber sequence_number() const; 189 QuicPacketSequenceNumber sequence_number() const;
180 190
181 QuicByteCount max_packet_length() const; 191 QuicByteCount max_packet_length() const;
182 192
183 void set_max_packet_length(QuicByteCount length); 193 void set_max_packet_length(QuicByteCount length);
184 194
185 void set_debug_delegate(DebugDelegate* debug_delegate) { 195 void set_debug_delegate(DebugDelegate* debug_delegate) {
186 debug_delegate_ = debug_delegate; 196 debug_delegate_ = debug_delegate;
187 } 197 }
188 198
189 QuicTime::Delta fec_timeout() { return fec_timeout_; }
190
191 private: 199 private:
192 friend class test::QuicPacketGeneratorPeer; 200 friend class test::QuicPacketGeneratorPeer;
193 201
194 // Turn on FEC protection for subsequent packets in the generator. 202 // Turn on FEC protection for subsequent packets in the generator.
195 // If no FEC group is currently open in the creator, this method flushes any 203 // If no FEC group is currently open in the creator, this method flushes any
196 // queued frames in the generator and in the creator, and it then turns FEC on 204 // queued frames in the generator and in the creator, and it then turns FEC on
197 // in the creator. This method may be called with an open FEC group in the 205 // in the creator. This method may be called with an open FEC group in the
198 // creator, in which case, only the generator's state is altered. 206 // creator, in which case, only the generator's state is altered.
199 void MaybeStartFecProtection(); 207 void MaybeStartFecProtection();
200 208
201 // Serializes and calls the delegate on an FEC packet if one was under 209 // Serializes and calls the delegate on an FEC packet if one was under
202 // construction in the creator. When |force| is false, it relies on the 210 // construction in the creator. When |force| is false, it relies on the
203 // creator being ready to send an FEC packet, otherwise FEC packet is sent 211 // creator being ready to send an FEC packet, otherwise FEC packet is sent
204 // as long as one is under construction in the creator. Also tries to turn 212 // as long as one is under construction in the creator. Also tries to turn
205 // off FEC protection in the creator if it's off in the generator. 213 // off FEC protection in the creator if it's off in the generator.
206 void MaybeSendFecPacketAndCloseGroup(bool force); 214 void MaybeSendFecPacketAndCloseGroup(bool force);
207 215
216 // Returns true if an FEC packet should be generated based on |force| and
217 // current state of the generator and the creator.
218 bool ShouldSendFecPacket(bool force);
219
208 void SendQueuedFrames(bool flush); 220 void SendQueuedFrames(bool flush);
209 221
210 // Test to see if we have pending ack, feedback, or control frames. 222 // Test to see if we have pending ack, feedback, or control frames.
211 bool HasPendingFrames() const; 223 bool HasPendingFrames() const;
212 // Test to see if the addition of a pending frame (which might be 224 // Test to see if the addition of a pending frame (which might be
213 // retransmittable) would still allow the resulting packet to be sent now. 225 // retransmittable) would still allow the resulting packet to be sent now.
214 bool CanSendWithNextPendingFrameAddition() const; 226 bool CanSendWithNextPendingFrameAddition() const;
215 // Add exactly one pending frame, preferring ack over feedback over control 227 // Add exactly one pending frame, preferring ack over feedback over control
216 // frames. 228 // frames.
217 bool AddNextPendingFrame(); 229 bool AddNextPendingFrame();
218 230
219 bool AddFrame(const QuicFrame& frame); 231 bool AddFrame(const QuicFrame& frame);
220 232
221 void SerializeAndSendPacket(); 233 void SerializeAndSendPacket();
222 234
223 DelegateInterface* delegate_; 235 DelegateInterface* delegate_;
224 DebugDelegate* debug_delegate_; 236 DebugDelegate* debug_delegate_;
225 237
226 QuicPacketCreator packet_creator_; 238 QuicPacketCreator packet_creator_;
227 QuicFrames queued_control_frames_; 239 QuicFrames queued_control_frames_;
228 240
229 // True if batch mode is currently enabled. 241 // True if batch mode is currently enabled.
230 bool batch_mode_; 242 bool batch_mode_;
231 243
232 // Timeout used for FEC alarm. Can be set to zero. 244 // Timeout used for FEC alarm. Can be set to zero initially or if the SRTT has
245 // not yet been set.
233 QuicTime::Delta fec_timeout_; 246 QuicTime::Delta fec_timeout_;
234 247
235 // True if FEC protection is on. The creator may have an open FEC group even 248 // True if FEC protection is on. The creator may have an open FEC group even
236 // if this variable is false. 249 // if this variable is false.
237 bool should_fec_protect_; 250 bool should_fec_protect_;
238 251
239 // Flags to indicate the need for just-in-time construction of a frame. 252 // Flags to indicate the need for just-in-time construction of a frame.
240 bool should_send_ack_; 253 bool should_send_ack_;
241 bool should_send_feedback_; 254 bool should_send_feedback_;
242 bool should_send_stop_waiting_; 255 bool should_send_stop_waiting_;
243 // If we put a non-retransmittable frame (namley ack or feedback frame) in 256 // If we put a non-retransmittable frame (namley ack or feedback frame) in
244 // this packet, then we have to hold a reference to it until we flush (and 257 // this packet, then we have to hold a reference to it until we flush (and
245 // serialize it). Retransmittable frames are referenced elsewhere so that they 258 // serialize it). Retransmittable frames are referenced elsewhere so that they
246 // can later be (optionally) retransmitted. 259 // can later be (optionally) retransmitted.
247 scoped_ptr<QuicAckFrame> pending_ack_frame_; 260 scoped_ptr<QuicAckFrame> pending_ack_frame_;
248 scoped_ptr<QuicCongestionFeedbackFrame> pending_feedback_frame_; 261 scoped_ptr<QuicCongestionFeedbackFrame> pending_feedback_frame_;
249 scoped_ptr<QuicStopWaitingFrame> pending_stop_waiting_frame_; 262 scoped_ptr<QuicStopWaitingFrame> pending_stop_waiting_frame_;
250 263
251 // Stores notifiers that should be attached to the next serialized packet. 264 // Stores notifiers that should be attached to the next serialized packet.
252 base::hash_set<QuicAckNotifier*> ack_notifiers_; 265 base::hash_set<QuicAckNotifier*> ack_notifiers_;
253 266
254 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator); 267 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator);
255 }; 268 };
256 269
257 } // namespace net 270 } // namespace net
258 271
259 #endif // NET_QUIC_QUIC_PACKET_GENERATOR_H_ 272 #endif // NET_QUIC_QUIC_PACKET_GENERATOR_H_
OLDNEW
« no previous file with comments | « net/quic/quic_packet_creator.h ('k') | net/quic/quic_packet_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698