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

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

Issue 839143002: Roll Chrome into Mojo. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Rebase 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_test.cc ('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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // mode, we should probably set a timer so that several independent 46 // mode, we should probably set a timer so that several independent
47 // operations can be grouped into the same FEC group. 47 // operations can be grouped into the same FEC group.
48 // 48 //
49 // When an FEC packet is generated, it will be send to the Delegate, 49 // When an FEC packet is generated, it will be send to the Delegate,
50 // even if the Delegate has become unwritable after handling the 50 // even if the Delegate has become unwritable after handling the
51 // data packet immediately proceeding the FEC packet. 51 // data packet immediately proceeding the FEC packet.
52 52
53 #ifndef NET_QUIC_QUIC_PACKET_GENERATOR_H_ 53 #ifndef NET_QUIC_QUIC_PACKET_GENERATOR_H_
54 #define NET_QUIC_QUIC_PACKET_GENERATOR_H_ 54 #define NET_QUIC_QUIC_PACKET_GENERATOR_H_
55 55
56 #include "net/quic/quic_ack_notifier.h"
56 #include "net/quic/quic_packet_creator.h" 57 #include "net/quic/quic_packet_creator.h"
57 #include "net/quic/quic_sent_packet_manager.h" 58 #include "net/quic/quic_sent_packet_manager.h"
58 #include "net/quic/quic_types.h" 59 #include "net/quic/quic_types.h"
59 60
60 namespace net { 61 namespace net {
61 62
62 namespace test { 63 namespace test {
63 class QuicPacketGeneratorPeer; 64 class QuicPacketGeneratorPeer;
64 } // namespace test 65 } // namespace test
65 66
66 class QuicAckNotifier;
67
68 class NET_EXPORT_PRIVATE QuicPacketGenerator { 67 class NET_EXPORT_PRIVATE QuicPacketGenerator {
69 public: 68 public:
70 class NET_EXPORT_PRIVATE DelegateInterface { 69 class NET_EXPORT_PRIVATE DelegateInterface {
71 public: 70 public:
72 virtual ~DelegateInterface() {} 71 virtual ~DelegateInterface() {}
73 virtual bool ShouldGeneratePacket(TransmissionType transmission_type, 72 virtual bool ShouldGeneratePacket(TransmissionType transmission_type,
74 HasRetransmittableData retransmittable, 73 HasRetransmittableData retransmittable,
75 IsHandshake handshake) = 0; 74 IsHandshake handshake) = 0;
76 virtual QuicAckFrame* CreateAckFrame() = 0; 75 virtual QuicAckFrame* CreateAckFrame() = 0;
77 virtual QuicCongestionFeedbackFrame* CreateFeedbackFrame() = 0; 76 virtual QuicCongestionFeedbackFrame* CreateFeedbackFrame() = 0;
(...skipping 17 matching lines...) Expand all
95 QuicPacketGenerator(QuicConnectionId connection_id, 94 QuicPacketGenerator(QuicConnectionId connection_id,
96 QuicFramer* framer, 95 QuicFramer* framer,
97 QuicRandom* random_generator, 96 QuicRandom* random_generator,
98 DelegateInterface* delegate); 97 DelegateInterface* delegate);
99 98
100 virtual ~QuicPacketGenerator(); 99 virtual ~QuicPacketGenerator();
101 100
102 // Called by the connection in the event of the congestion window changing. 101 // Called by the connection in the event of the congestion window changing.
103 void OnCongestionWindowChange(QuicPacketCount max_packets_in_flight); 102 void OnCongestionWindowChange(QuicPacketCount max_packets_in_flight);
104 103
104 // Called by the connection when the RTT may have changed.
105 void OnRttChange(QuicTime::Delta rtt);
106
105 // Indicates that an ACK frame should be sent. If |also_send_feedback| is 107 // Indicates that an ACK frame should be sent. If |also_send_feedback| is
106 // true, then it also indicates a CONGESTION_FEEDBACK frame should be sent. 108 // true, then it also indicates a CONGESTION_FEEDBACK frame should be sent.
107 // If |also_send_stop_waiting| is true, then it also indicates that a 109 // If |also_send_stop_waiting| is true, then it also indicates that a
108 // STOP_WAITING frame should be sent as well. 110 // STOP_WAITING frame should be sent as well.
109 // The contents of the frame(s) will be generated via a call to the delegates 111 // The contents of the frame(s) will be generated via a call to the delegates
110 // CreateAckFrame() and CreateFeedbackFrame() when the packet is serialized. 112 // CreateAckFrame() and CreateFeedbackFrame() when the packet is serialized.
111 void SetShouldSendAck(bool also_send_feedback, 113 void SetShouldSendAck(bool also_send_feedback,
112 bool also_send_stop_waiting); 114 bool also_send_stop_waiting);
113 115
114 // Indicates that a STOP_WAITING frame should be sent. 116 // Indicates that a STOP_WAITING frame should be sent.
115 void SetShouldSendStopWaiting(); 117 void SetShouldSendStopWaiting();
116 118
117 void AddControlFrame(const QuicFrame& frame); 119 void AddControlFrame(const QuicFrame& frame);
118 120
119 // Given some data, may consume part or all of it and pass it to the 121 // Given some data, may consume part or all of it and pass it to the
120 // packet creator to be serialized into packets. If not in batch 122 // packet creator to be serialized into packets. If not in batch
121 // mode, these packets will also be sent during this call. Also 123 // mode, these packets will also be sent during this call.
122 // attaches a QuicAckNotifier to any created stream frames, which 124 // |delegate| (if not nullptr) will be informed once all packets sent as a
123 // will be called once the frame is ACKed by the peer. The 125 // result of this call are ACKed by the peer.
124 // QuicAckNotifier is owned by the QuicConnection. |notifier| may
125 // be nullptr.
126 QuicConsumedData ConsumeData(QuicStreamId id, 126 QuicConsumedData ConsumeData(QuicStreamId id,
127 const IOVector& data, 127 const IOVector& data,
128 QuicStreamOffset offset, 128 QuicStreamOffset offset,
129 bool fin, 129 bool fin,
130 FecProtection fec_protection, 130 FecProtection fec_protection,
131 QuicAckNotifier* notifier); 131 QuicAckNotifier::DelegateInterface* delegate);
132 132
133 // Indicates whether batch mode is currently enabled. 133 // Indicates whether batch mode is currently enabled.
134 bool InBatchMode(); 134 bool InBatchMode();
135 // Disables flushing. 135 // Disables flushing.
136 void StartBatchOperations(); 136 void StartBatchOperations();
137 // Enables flushing and flushes queued data which can be sent. 137 // Enables flushing and flushes queued data which can be sent.
138 void FinishBatchOperations(); 138 void FinishBatchOperations();
139 139
140 // Flushes all queued frames, even frames which are not sendable. 140 // Flushes all queued frames, even frames which are not sendable.
141 void FlushAllQueuedFrames(); 141 void FlushAllQueuedFrames();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 QuicPacketSequenceNumber sequence_number() const; 178 QuicPacketSequenceNumber sequence_number() const;
179 179
180 QuicByteCount max_packet_length() const; 180 QuicByteCount max_packet_length() const;
181 181
182 void set_max_packet_length(QuicByteCount length); 182 void set_max_packet_length(QuicByteCount length);
183 183
184 void set_debug_delegate(DebugDelegate* debug_delegate) { 184 void set_debug_delegate(DebugDelegate* debug_delegate) {
185 debug_delegate_ = debug_delegate; 185 debug_delegate_ = debug_delegate;
186 } 186 }
187 187
188 QuicTime::Delta fec_timeout() { return fec_timeout_; }
189
188 private: 190 private:
189 friend class test::QuicPacketGeneratorPeer; 191 friend class test::QuicPacketGeneratorPeer;
190 192
191 // Turn on FEC protection for subsequent packets in the generator. 193 // Turn on FEC protection for subsequent packets in the generator.
192 // If no FEC group is currently open in the creator, this method flushes any 194 // If no FEC group is currently open in the creator, this method flushes any
193 // queued frames in the generator and in the creator, and it then turns FEC on 195 // queued frames in the generator and in the creator, and it then turns FEC on
194 // in the creator. This method may be called with an open FEC group in the 196 // in the creator. This method may be called with an open FEC group in the
195 // creator, in which case, only the generator's state is altered. 197 // creator, in which case, only the generator's state is altered.
196 void MaybeStartFecProtection(); 198 void MaybeStartFecProtection();
197 199
(...skipping 21 matching lines...) Expand all
219 221
220 DelegateInterface* delegate_; 222 DelegateInterface* delegate_;
221 DebugDelegate* debug_delegate_; 223 DebugDelegate* debug_delegate_;
222 224
223 QuicPacketCreator packet_creator_; 225 QuicPacketCreator packet_creator_;
224 QuicFrames queued_control_frames_; 226 QuicFrames queued_control_frames_;
225 227
226 // True if batch mode is currently enabled. 228 // True if batch mode is currently enabled.
227 bool batch_mode_; 229 bool batch_mode_;
228 230
231 // Timeout used for FEC alarm. Can be set to zero.
232 QuicTime::Delta fec_timeout_;
233
229 // True if FEC protection is on. The creator may have an open FEC group even 234 // True if FEC protection is on. The creator may have an open FEC group even
230 // if this variable is false. 235 // if this variable is false.
231 bool should_fec_protect_; 236 bool should_fec_protect_;
232 237
233 // Flags to indicate the need for just-in-time construction of a frame. 238 // Flags to indicate the need for just-in-time construction of a frame.
234 bool should_send_ack_; 239 bool should_send_ack_;
235 bool should_send_feedback_; 240 bool should_send_feedback_;
236 bool should_send_stop_waiting_; 241 bool should_send_stop_waiting_;
237 // If we put a non-retransmittable frame (namley ack or feedback frame) in 242 // If we put a non-retransmittable frame (namley ack or feedback frame) in
238 // this packet, then we have to hold a reference to it until we flush (and 243 // this packet, then we have to hold a reference to it until we flush (and
239 // serialize it). Retransmittable frames are referenced elsewhere so that they 244 // serialize it). Retransmittable frames are referenced elsewhere so that they
240 // can later be (optionally) retransmitted. 245 // can later be (optionally) retransmitted.
241 scoped_ptr<QuicAckFrame> pending_ack_frame_; 246 scoped_ptr<QuicAckFrame> pending_ack_frame_;
242 scoped_ptr<QuicCongestionFeedbackFrame> pending_feedback_frame_; 247 scoped_ptr<QuicCongestionFeedbackFrame> pending_feedback_frame_;
243 scoped_ptr<QuicStopWaitingFrame> pending_stop_waiting_frame_; 248 scoped_ptr<QuicStopWaitingFrame> pending_stop_waiting_frame_;
244 249
245 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator); 250 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator);
246 }; 251 };
247 252
248 } // namespace net 253 } // namespace net
249 254
250 #endif // NET_QUIC_QUIC_PACKET_GENERATOR_H_ 255 #endif // NET_QUIC_QUIC_PACKET_GENERATOR_H_
OLDNEW
« no previous file with comments | « net/quic/quic_packet_creator_test.cc ('k') | net/quic/quic_packet_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698