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

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

Issue 2825083003: Landing Recent QUIC changes until Mon Apr 17 2017 (Closed)
Patch Set: Format Created 3 years, 8 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/core/quic_headers_stream_test.cc ('k') | net/quic/core/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. 6 // it's time to create a packet from them.
7 7
8 #ifndef NET_QUIC_CORE_QUIC_PACKET_CREATOR_H_ 8 #ifndef NET_QUIC_CORE_QUIC_PACKET_CREATOR_H_
9 #define NET_QUIC_CORE_QUIC_PACKET_CREATOR_H_ 9 #define NET_QUIC_CORE_QUIC_PACKET_CREATOR_H_
10 10
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // plaintext size. 195 // plaintext size.
196 void SetEncrypter(EncryptionLevel level, QuicEncrypter* encrypter); 196 void SetEncrypter(EncryptionLevel level, QuicEncrypter* encrypter);
197 197
198 // Indicates whether the packet creator is in a state where it can change 198 // Indicates whether the packet creator is in a state where it can change
199 // current maximum packet length. 199 // current maximum packet length.
200 bool CanSetMaxPacketLength() const; 200 bool CanSetMaxPacketLength() const;
201 201
202 // Sets the maximum packet length. 202 // Sets the maximum packet length.
203 void SetMaxPacketLength(QuicByteCount length); 203 void SetMaxPacketLength(QuicByteCount length);
204 204
205 // Increases pending_padding_bytes by |size|. Pending padding will be sent by
206 // MaybeAddPadding().
207 void AddPendingPadding(QuicByteCount size);
208
205 void set_debug_delegate(DebugDelegate* debug_delegate) { 209 void set_debug_delegate(DebugDelegate* debug_delegate) {
206 debug_delegate_ = debug_delegate; 210 debug_delegate_ = debug_delegate;
207 } 211 }
208 212
209 bool latched_flag_no_stop_waiting_frames() const { 213 bool latched_flag_no_stop_waiting_frames() const {
210 return latched_flag_no_stop_waiting_frames_; 214 return latched_flag_no_stop_waiting_frames_;
211 } 215 }
212 216
217 QuicByteCount pending_padding_bytes() const { return pending_padding_bytes_; }
218
213 private: 219 private:
214 friend class test::QuicPacketCreatorPeer; 220 friend class test::QuicPacketCreatorPeer;
215 221
216 static bool ShouldRetransmit(const QuicFrame& frame); 222 static bool ShouldRetransmit(const QuicFrame& frame);
217 223
218 // Converts a raw payload to a frame which fits into the current open 224 // Converts a raw payload to a frame which fits into the current open
219 // packet. The payload begins at |iov_offset| into the |iov|. 225 // packet. The payload begins at |iov_offset| into the |iov|.
220 // If data is empty and fin is true, the expected behavior is to consume the 226 // If data is empty and fin is true, the expected behavior is to consume the
221 // fin but return 0. If any data is consumed, it will be copied into a 227 // fin but return 0. If any data is consumed, it will be copied into a
222 // new buffer that |frame| will point to and own. 228 // new buffer that |frame| will point to and own.
(...skipping 12 matching lines...) Expand all
235 size_t length, 241 size_t length,
236 char* buffer); 242 char* buffer);
237 243
238 void FillPacketHeader(QuicPacketHeader* header); 244 void FillPacketHeader(QuicPacketHeader* header);
239 245
240 // Adds a |frame| if there is space and returns false and flushes all pending 246 // Adds a |frame| if there is space and returns false and flushes all pending
241 // frames if there isn't room. If |save_retransmittable_frames| is true, 247 // frames if there isn't room. If |save_retransmittable_frames| is true,
242 // saves the |frame| in the next SerializedPacket. 248 // saves the |frame| in the next SerializedPacket.
243 bool AddFrame(const QuicFrame& frame, bool save_retransmittable_frames); 249 bool AddFrame(const QuicFrame& frame, bool save_retransmittable_frames);
244 250
245 // Adds a padding frame to the current packet only if the current packet 251 // Adds a padding frame to the current packet (if there is space) when (1)
246 // contains a handshake message, and there is sufficient room to fit a 252 // current packet needs full padding or (2) there are pending paddings.
247 // padding frame.
248 void MaybeAddPadding(); 253 void MaybeAddPadding();
249 254
250 // Serializes all frames which have been added and adds any which should be 255 // Serializes all frames which have been added and adds any which should be
251 // retransmitted to packet_.retransmittable_frames. All frames must fit into 256 // retransmitted to packet_.retransmittable_frames. All frames must fit into
252 // a single packet. 257 // a single packet.
253 // Fails if |buffer_len| isn't long enough for the encrypted packet. 258 // Fails if |buffer_len| isn't long enough for the encrypted packet.
254 void SerializePacket(char* encrypted_buffer, size_t buffer_len); 259 void SerializePacket(char* encrypted_buffer, size_t buffer_len);
255 260
256 // Called after a new SerialiedPacket is created to call the delegate's 261 // Called after a new SerialiedPacket is created to call the delegate's
257 // OnSerializedPacket and reset state. 262 // OnSerializedPacket and reset state.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // QuicEncryptedPacket has been flattened into SerializedPacket. 301 // QuicEncryptedPacket has been flattened into SerializedPacket.
297 size_t packet_size_; 302 size_t packet_size_;
298 QuicConnectionId connection_id_; 303 QuicConnectionId connection_id_;
299 304
300 // Packet used to invoke OnSerializedPacket. 305 // Packet used to invoke OnSerializedPacket.
301 SerializedPacket packet_; 306 SerializedPacket packet_;
302 307
303 // The latched value of FLAGS_quic_reloadable_flag_quic_no_stop_waiting_frames 308 // The latched value of FLAGS_quic_reloadable_flag_quic_no_stop_waiting_frames
304 bool latched_flag_no_stop_waiting_frames_; 309 bool latched_flag_no_stop_waiting_frames_;
305 310
311 // Pending padding bytes to send. Pending padding bytes will be sent in next
312 // packet(s) (after all other frames) if current constructed packet does not
313 // have room to send all of them.
314 QuicByteCount pending_padding_bytes_;
315
316 // Indicates whether current constructed packet needs full padding to max
317 // packet size. Please note, full padding does not consume pending padding
318 // bytes.
319 bool needs_full_padding_;
320
306 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator); 321 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator);
307 }; 322 };
308 323
309 } // namespace net 324 } // namespace net
310 325
311 #endif // NET_QUIC_CORE_QUIC_PACKET_CREATOR_H_ 326 #endif // NET_QUIC_CORE_QUIC_PACKET_CREATOR_H_
OLDNEW
« no previous file with comments | « net/quic/core/quic_headers_stream_test.cc ('k') | net/quic/core/quic_packet_creator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698