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

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

Issue 327393002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_packet_creator.h" 56 #include "net/quic/quic_packet_creator.h"
57 #include "net/quic/quic_types.h" 57 #include "net/quic/quic_types.h"
58 58
59 namespace net { 59 namespace net {
60 60
61 namespace test {
62 class QuicPacketGeneratorPeer;
63 } // namespace test
64
61 class QuicAckNotifier; 65 class QuicAckNotifier;
62 66
63 class NET_EXPORT_PRIVATE QuicPacketGenerator { 67 class NET_EXPORT_PRIVATE QuicPacketGenerator {
64 public: 68 public:
65 class NET_EXPORT_PRIVATE DelegateInterface { 69 class NET_EXPORT_PRIVATE DelegateInterface {
66 public: 70 public:
67 virtual ~DelegateInterface() {} 71 virtual ~DelegateInterface() {}
68 virtual bool ShouldGeneratePacket(TransmissionType transmission_type, 72 virtual bool ShouldGeneratePacket(TransmissionType transmission_type,
69 HasRetransmittableData retransmittable, 73 HasRetransmittableData retransmittable,
70 IsHandshake handshake) = 0; 74 IsHandshake handshake) = 0;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // Flushes all queued frames, even frames which are not sendable. 134 // Flushes all queued frames, even frames which are not sendable.
131 void FlushAllQueuedFrames(); 135 void FlushAllQueuedFrames();
132 136
133 bool HasQueuedFrames() const; 137 bool HasQueuedFrames() const;
134 138
135 void set_debug_delegate(DebugDelegate* debug_delegate) { 139 void set_debug_delegate(DebugDelegate* debug_delegate) {
136 debug_delegate_ = debug_delegate; 140 debug_delegate_ = debug_delegate;
137 } 141 }
138 142
139 private: 143 private:
144 friend class test::QuicPacketGeneratorPeer;
145
146 // Turn on FEC protection for subsequent packets in the generator.
147 // If no FEC group is currently open in the creator, this method flushes any
148 // queued frames in the generator and in the creator, and it then turns FEC on
149 // in the creator. This method may be called with an open FEC group in the
150 // creator, in which case, only the generator's state is altered.
151 void MaybeStartFecProtection();
152
153 // Turn off FEC protection for subsequent packets. If |force| is true,
154 // force-closes any open FEC group, sends out an FEC packet if one was under
155 // construction, and turns off protection in the generator and creator. If
156 // |force| is false, does the same as above if the creator is ready to send
157 // and FEC packet. Note that when |force| is false, the creator may still have
158 // an open FEC group after this method runs.
159 void MaybeStopFecProtection(bool force);
160
161 // Serializes and calls the delegate on an FEC packet if one was under
162 // construction in the creator. When |force| is false, it relies on the
163 // creator being ready to send an FEC packet, otherwise FEC packet is sent
164 // as long as one is under construction in the creator. Also tries to turns
165 // off FEC protection in the creator if it's off in the generator.
166 void MaybeSendFecPacketAndCloseGroup(bool force);
167
140 void SendQueuedFrames(bool flush); 168 void SendQueuedFrames(bool flush);
141 169
142 // Test to see if we have pending ack, feedback, or control frames. 170 // Test to see if we have pending ack, feedback, or control frames.
143 bool HasPendingFrames() const; 171 bool HasPendingFrames() const;
144 // Test to see if the addition of a pending frame (which might be 172 // Test to see if the addition of a pending frame (which might be
145 // retransmittable) would still allow the resulting packet to be sent now. 173 // retransmittable) would still allow the resulting packet to be sent now.
146 bool CanSendWithNextPendingFrameAddition() const; 174 bool CanSendWithNextPendingFrameAddition() const;
147 // Add exactly one pending frame, preferring ack over feedback over control 175 // Add exactly one pending frame, preferring ack over feedback over control
148 // frames. 176 // frames.
149 bool AddNextPendingFrame(); 177 bool AddNextPendingFrame();
150 178
151 bool AddFrame(const QuicFrame& frame); 179 bool AddFrame(const QuicFrame& frame);
152 180
153 void SerializeAndSendPacket(); 181 void SerializeAndSendPacket();
154 182
155 DelegateInterface* delegate_; 183 DelegateInterface* delegate_;
156 DebugDelegate* debug_delegate_; 184 DebugDelegate* debug_delegate_;
157 185
158 QuicPacketCreator* packet_creator_; 186 QuicPacketCreator* packet_creator_;
159 QuicFrames queued_control_frames_; 187 QuicFrames queued_control_frames_;
160 188
161 // True if batch mode is currently enabled. 189 // True if batch mode is currently enabled.
162 bool batch_mode_; 190 bool batch_mode_;
163 191
192 // True if FEC protection is on.
193 bool should_fec_protect_;
194
164 // Flags to indicate the need for just-in-time construction of a frame. 195 // Flags to indicate the need for just-in-time construction of a frame.
165 bool should_send_ack_; 196 bool should_send_ack_;
166 bool should_send_feedback_; 197 bool should_send_feedback_;
167 bool should_send_stop_waiting_; 198 bool should_send_stop_waiting_;
168 // If we put a non-retransmittable frame (namley ack or feedback frame) in 199 // If we put a non-retransmittable frame (namley ack or feedback frame) in
169 // this packet, then we have to hold a reference to it until we flush (and 200 // this packet, then we have to hold a reference to it until we flush (and
170 // serialize it). Retransmittable frames are referenced elsewhere so that they 201 // serialize it). Retransmittable frames are referenced elsewhere so that they
171 // can later be (optionally) retransmitted. 202 // can later be (optionally) retransmitted.
172 scoped_ptr<QuicAckFrame> pending_ack_frame_; 203 scoped_ptr<QuicAckFrame> pending_ack_frame_;
173 scoped_ptr<QuicCongestionFeedbackFrame> pending_feedback_frame_; 204 scoped_ptr<QuicCongestionFeedbackFrame> pending_feedback_frame_;
174 scoped_ptr<QuicStopWaitingFrame> pending_stop_waiting_frame_; 205 scoped_ptr<QuicStopWaitingFrame> pending_stop_waiting_frame_;
175 206
176 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator); 207 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator);
177 }; 208 };
178 209
179 } // namespace net 210 } // namespace net
180 211
181 #endif // NET_QUIC_QUIC_PACKET_GENERATOR_H_ 212 #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