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

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

Issue 329933003: Refactor the Connection and Generator so the Creator is completely (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // points. Implementations must not mutate the state of the generator 84 // points. Implementations must not mutate the state of the generator
85 // as a result of these callbacks. 85 // as a result of these callbacks.
86 class NET_EXPORT_PRIVATE DebugDelegate { 86 class NET_EXPORT_PRIVATE DebugDelegate {
87 public: 87 public:
88 virtual ~DebugDelegate() {} 88 virtual ~DebugDelegate() {}
89 89
90 // Called when a frame has been added to the current packet. 90 // Called when a frame has been added to the current packet.
91 virtual void OnFrameAddedToPacket(const QuicFrame& frame) {} 91 virtual void OnFrameAddedToPacket(const QuicFrame& frame) {}
92 }; 92 };
93 93
94 QuicPacketGenerator(DelegateInterface* delegate, 94 QuicPacketGenerator(QuicConnectionId connection_id,
95 DebugDelegate* debug_delegate, 95 QuicFramer* framer,
96 QuicPacketCreator* creator); 96 QuicRandom* random_generator,
97 DelegateInterface* delegate);
97 98
98 virtual ~QuicPacketGenerator(); 99 virtual ~QuicPacketGenerator();
99 100
100 // Indicates that an ACK frame should be sent. If |also_send_feedback| is 101 // Indicates that an ACK frame should be sent. If |also_send_feedback| is
101 // true, then it also indicates a CONGESTION_FEEDBACK frame should be sent. 102 // true, then it also indicates a CONGESTION_FEEDBACK frame should be sent.
102 // If |also_send_stop_waiting| is true, then it also indicates that a 103 // If |also_send_stop_waiting| is true, then it also indicates that a
103 // STOP_WAITING frame should be sent as well. 104 // STOP_WAITING frame should be sent as well.
104 // The contents of the frame(s) will be generated via a call to the delegates 105 // The contents of the frame(s) will be generated via a call to the delegates
105 // CreateAckFrame() and CreateFeedbackFrame() when the packet is serialized. 106 // CreateAckFrame() and CreateFeedbackFrame() when the packet is serialized.
106 void SetShouldSendAck(bool also_send_feedback, 107 void SetShouldSendAck(bool also_send_feedback,
(...skipping 23 matching lines...) Expand all
130 // Disables flushing. 131 // Disables flushing.
131 void StartBatchOperations(); 132 void StartBatchOperations();
132 // Enables flushing and flushes queued data which can be sent. 133 // Enables flushing and flushes queued data which can be sent.
133 void FinishBatchOperations(); 134 void FinishBatchOperations();
134 135
135 // Flushes all queued frames, even frames which are not sendable. 136 // Flushes all queued frames, even frames which are not sendable.
136 void FlushAllQueuedFrames(); 137 void FlushAllQueuedFrames();
137 138
138 bool HasQueuedFrames() const; 139 bool HasQueuedFrames() const;
139 140
141 // Makes the framer not serialize the protocol version in sent packets.
142 void StopSendingVersion();
143
144 // Creates a version negotiation packet which supports |supported_versions|.
145 // Caller owns the created packet. Also, sets the entropy hash of the
146 // serialized packet to a random bool and returns that value as a member of
147 // SerializedPacket.
148 QuicEncryptedPacket* SerializeVersionNegotiationPacket(
149 const QuicVersionVector& supported_versions);
150
151
152 // Re-serializes frames with the original packet's sequence number length.
153 // Used for retransmitting packets to ensure they aren't too long.
154 // Caller must ensure that any open FEC group is closed before calling this
155 // method.
156 SerializedPacket ReserializeAllFrames(
157 const QuicFrames& frames,
158 QuicSequenceNumberLength original_length);
159
160 // Update the sequence number length to use in future packets as soon as it
161 // can be safely changed.
162 void UpdateSequenceNumberLength(
163 QuicPacketSequenceNumber least_packet_awaited_by_peer,
164 QuicByteCount congestion_window);
165
166 // Sets the encryption level that will be applied to new packets.
167 void set_encryption_level(EncryptionLevel level);
168
169 // Sequence number of the last created packet, or 0 if no packets have been
170 // created.
171 QuicPacketSequenceNumber sequence_number() const;
172
173 size_t max_packet_length() const;
174
175 void set_max_packet_length(size_t length);
176
140 void set_debug_delegate(DebugDelegate* debug_delegate) { 177 void set_debug_delegate(DebugDelegate* debug_delegate) {
141 debug_delegate_ = debug_delegate; 178 debug_delegate_ = debug_delegate;
142 } 179 }
143 180
144 private: 181 private:
145 friend class test::QuicPacketGeneratorPeer; 182 friend class test::QuicPacketGeneratorPeer;
146 183
147 // Turn on FEC protection for subsequent packets in the generator. 184 // Turn on FEC protection for subsequent packets in the generator.
148 // If no FEC group is currently open in the creator, this method flushes any 185 // If no FEC group is currently open in the creator, this method flushes any
149 // queued frames in the generator and in the creator, and it then turns FEC on 186 // queued frames in the generator and in the creator, and it then turns FEC on
(...skipping 19 matching lines...) Expand all
169 // frames. 206 // frames.
170 bool AddNextPendingFrame(); 207 bool AddNextPendingFrame();
171 208
172 bool AddFrame(const QuicFrame& frame); 209 bool AddFrame(const QuicFrame& frame);
173 210
174 void SerializeAndSendPacket(); 211 void SerializeAndSendPacket();
175 212
176 DelegateInterface* delegate_; 213 DelegateInterface* delegate_;
177 DebugDelegate* debug_delegate_; 214 DebugDelegate* debug_delegate_;
178 215
179 QuicPacketCreator* packet_creator_; 216 QuicPacketCreator packet_creator_;
180 QuicFrames queued_control_frames_; 217 QuicFrames queued_control_frames_;
181 218
182 // True if batch mode is currently enabled. 219 // True if batch mode is currently enabled.
183 bool batch_mode_; 220 bool batch_mode_;
184 221
185 // True if FEC protection is on. The creator may have an open FEC group even 222 // True if FEC protection is on. The creator may have an open FEC group even
186 // if this variable is false. 223 // if this variable is false.
187 bool should_fec_protect_; 224 bool should_fec_protect_;
188 225
189 // Flags to indicate the need for just-in-time construction of a frame. 226 // Flags to indicate the need for just-in-time construction of a frame.
190 bool should_send_ack_; 227 bool should_send_ack_;
191 bool should_send_feedback_; 228 bool should_send_feedback_;
192 bool should_send_stop_waiting_; 229 bool should_send_stop_waiting_;
193 // If we put a non-retransmittable frame (namley ack or feedback frame) in 230 // If we put a non-retransmittable frame (namley ack or feedback frame) in
194 // this packet, then we have to hold a reference to it until we flush (and 231 // this packet, then we have to hold a reference to it until we flush (and
195 // serialize it). Retransmittable frames are referenced elsewhere so that they 232 // serialize it). Retransmittable frames are referenced elsewhere so that they
196 // can later be (optionally) retransmitted. 233 // can later be (optionally) retransmitted.
197 scoped_ptr<QuicAckFrame> pending_ack_frame_; 234 scoped_ptr<QuicAckFrame> pending_ack_frame_;
198 scoped_ptr<QuicCongestionFeedbackFrame> pending_feedback_frame_; 235 scoped_ptr<QuicCongestionFeedbackFrame> pending_feedback_frame_;
199 scoped_ptr<QuicStopWaitingFrame> pending_stop_waiting_frame_; 236 scoped_ptr<QuicStopWaitingFrame> pending_stop_waiting_frame_;
200 237
201 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator); 238 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator);
202 }; 239 };
203 240
204 } // namespace net 241 } // namespace net
205 242
206 #endif // NET_QUIC_QUIC_PACKET_GENERATOR_H_ 243 #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