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

Side by Side Diff: net/quic/core/quic_packet_generator.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_packet_creator_test.cc ('k') | net/quic/core/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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // Consults delegate whether a packet should be generated. 66 // Consults delegate whether a packet should be generated.
67 virtual bool ShouldGeneratePacket(HasRetransmittableData retransmittable, 67 virtual bool ShouldGeneratePacket(HasRetransmittableData retransmittable,
68 IsHandshake handshake) = 0; 68 IsHandshake handshake) = 0;
69 virtual const QuicFrame GetUpdatedAckFrame() = 0; 69 virtual const QuicFrame GetUpdatedAckFrame() = 0;
70 virtual void PopulateStopWaitingFrame( 70 virtual void PopulateStopWaitingFrame(
71 QuicStopWaitingFrame* stop_waiting) = 0; 71 QuicStopWaitingFrame* stop_waiting) = 0;
72 }; 72 };
73 73
74 QuicPacketGenerator(QuicConnectionId connection_id, 74 QuicPacketGenerator(QuicConnectionId connection_id,
75 QuicFramer* framer, 75 QuicFramer* framer,
76 QuicRandom* random_generator,
76 QuicBufferAllocator* buffer_allocator, 77 QuicBufferAllocator* buffer_allocator,
77 DelegateInterface* delegate); 78 DelegateInterface* delegate);
78 79
79 ~QuicPacketGenerator(); 80 ~QuicPacketGenerator();
80 81
81 // Indicates that an ACK frame should be sent. 82 // Indicates that an ACK frame should be sent.
82 // If |also_send_stop_waiting| is true, then it also indicates that a 83 // If |also_send_stop_waiting| is true, then it also indicates that a
83 // STOP_WAITING frame should be sent as well. 84 // STOP_WAITING frame should be sent as well.
84 // The contents of the frame(s) will be generated via a call to the delegate 85 // The contents of the frame(s) will be generated via a call to the delegate
85 // CreateAckFrame() when the packet is serialized. 86 // CreateAckFrame() when the packet is serialized.
86 void SetShouldSendAck(bool also_send_stop_waiting); 87 void SetShouldSendAck(bool also_send_stop_waiting);
87 88
88 void AddControlFrame(const QuicFrame& frame); 89 void AddControlFrame(const QuicFrame& frame);
89 90
90 // Given some data, may consume part or all of it and pass it to the 91 // Given some data, may consume part or all of it and pass it to the
91 // packet creator to be serialized into packets. If not in batch 92 // packet creator to be serialized into packets. If not in batch
92 // mode, these packets will also be sent during this call. 93 // mode, these packets will also be sent during this call.
93 // |delegate| (if not nullptr) will be informed once all packets sent as a 94 // |delegate| (if not nullptr) will be informed once all packets sent as a
94 // result of this call are ACKed by the peer. 95 // result of this call are ACKed by the peer.
96 // When |state| is FIN_AND_PADDING, random padding of size [1, 256] will be
97 // added after stream frames. If current constructed packet cannot
98 // accommodate, the padding will overflow to the next packet(s).
95 QuicConsumedData ConsumeData( 99 QuicConsumedData ConsumeData(
96 QuicStreamId id, 100 QuicStreamId id,
97 QuicIOVector iov, 101 QuicIOVector iov,
98 QuicStreamOffset offset, 102 QuicStreamOffset offset,
99 bool fin, 103 StreamSendingState state,
100 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener); 104 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener);
101 105
102 // Sends as many data only packets as allowed by the send algorithm and the 106 // Sends as many data only packets as allowed by the send algorithm and the
103 // available iov. 107 // available iov.
104 // This path does not support FEC, padding, or bundling pending frames. 108 // This path does not support FEC, padding, or bundling pending frames.
105 QuicConsumedData ConsumeDataFastPath( 109 QuicConsumedData ConsumeDataFastPath(
106 QuicStreamId id, 110 QuicStreamId id,
107 const QuicIOVector& iov, 111 const QuicIOVector& iov,
108 QuicStreamOffset offset, 112 QuicStreamOffset offset,
109 bool fin, 113 bool fin,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 bool HasPendingFrames() const; 193 bool HasPendingFrames() const;
190 // Returns true if addition of a pending frame (which might be 194 // Returns true if addition of a pending frame (which might be
191 // retransmittable) would still allow the resulting packet to be sent now. 195 // retransmittable) would still allow the resulting packet to be sent now.
192 bool CanSendWithNextPendingFrameAddition() const; 196 bool CanSendWithNextPendingFrameAddition() const;
193 // Add exactly one pending frame, preferring ack frames over control frames. 197 // Add exactly one pending frame, preferring ack frames over control frames.
194 // Returns true if a pending frame is successfully added. 198 // Returns true if a pending frame is successfully added.
195 // Returns false and flushes current open packet if the pending frame cannot 199 // Returns false and flushes current open packet if the pending frame cannot
196 // fit into current open packet. 200 // fit into current open packet.
197 bool AddNextPendingFrame(); 201 bool AddNextPendingFrame();
198 202
203 // Adds a random amount of padding (between 1 to 256 bytes).
204 void AddRandomPadding();
205
206 // Sends remaining pending padding.
207 // Pending paddings should only be sent when there is nothing else to send.
208 void SendRemainingPendingPadding();
209
199 DelegateInterface* delegate_; 210 DelegateInterface* delegate_;
200 211
201 QuicPacketCreator packet_creator_; 212 QuicPacketCreator packet_creator_;
202 QuicFrames queued_control_frames_; 213 QuicFrames queued_control_frames_;
203 214
204 // True if batch mode is currently enabled. 215 // True if batch mode is currently enabled.
205 bool batch_mode_; 216 bool batch_mode_;
206 217
207 // Flags to indicate the need for just-in-time construction of a frame. 218 // Flags to indicate the need for just-in-time construction of a frame.
208 bool should_send_ack_; 219 bool should_send_ack_;
209 bool should_send_stop_waiting_; 220 bool should_send_stop_waiting_;
210 // If we put a non-retransmittable frame in this packet, then we have to hold 221 // If we put a non-retransmittable frame in this packet, then we have to hold
211 // a reference to it until we flush (and serialize it). Retransmittable frames 222 // a reference to it until we flush (and serialize it). Retransmittable frames
212 // are referenced elsewhere so that they can later be (optionally) 223 // are referenced elsewhere so that they can later be (optionally)
213 // retransmitted. 224 // retransmitted.
214 QuicStopWaitingFrame pending_stop_waiting_frame_; 225 QuicStopWaitingFrame pending_stop_waiting_frame_;
215 226
227 QuicRandom* random_generator_;
228
216 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator); 229 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator);
217 }; 230 };
218 231
219 } // namespace net 232 } // namespace net
220 233
221 #endif // NET_QUIC_CORE_QUIC_PACKET_GENERATOR_H_ 234 #endif // NET_QUIC_CORE_QUIC_PACKET_GENERATOR_H_
OLDNEW
« no previous file with comments | « net/quic/core/quic_packet_creator_test.cc ('k') | net/quic/core/quic_packet_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698