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

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

Issue 312553003: Land Recent QUIC Changes. (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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 virtual QuicCongestionFeedbackFrame* CreateFeedbackFrame() = 0; 71 virtual QuicCongestionFeedbackFrame* CreateFeedbackFrame() = 0;
72 virtual QuicStopWaitingFrame* CreateStopWaitingFrame() = 0; 72 virtual QuicStopWaitingFrame* CreateStopWaitingFrame() = 0;
73 // Takes ownership of |packet.packet| and |packet.retransmittable_frames|. 73 // Takes ownership of |packet.packet| and |packet.retransmittable_frames|.
74 virtual bool OnSerializedPacket(const SerializedPacket& packet) = 0; 74 virtual bool OnSerializedPacket(const SerializedPacket& packet) = 0;
75 virtual void CloseConnection(QuicErrorCode error, bool from_peer) = 0; 75 virtual void CloseConnection(QuicErrorCode error, bool from_peer) = 0;
76 }; 76 };
77 77
78 // Interface which gets callbacks from the QuicPacketGenerator at interesting 78 // Interface which gets callbacks from the QuicPacketGenerator at interesting
79 // points. Implementations must not mutate the state of the generator 79 // points. Implementations must not mutate the state of the generator
80 // as a result of these callbacks. 80 // as a result of these callbacks.
81 class NET_EXPORT_PRIVATE DebugDelegateInterface { 81 class NET_EXPORT_PRIVATE DebugDelegate {
82 public: 82 public:
83 virtual ~DebugDelegateInterface() {} 83 virtual ~DebugDelegate() {}
84 84
85 // Called when a frame has been added to the current packet. 85 // Called when a frame has been added to the current packet.
86 virtual void OnFrameAddedToPacket(const QuicFrame& frame) {} 86 virtual void OnFrameAddedToPacket(const QuicFrame& frame) {}
87 }; 87 };
88 88
89 QuicPacketGenerator(DelegateInterface* delegate, 89 QuicPacketGenerator(DelegateInterface* delegate,
90 DebugDelegateInterface* debug_delegate, 90 DebugDelegate* debug_delegate,
91 QuicPacketCreator* creator); 91 QuicPacketCreator* creator);
92 92
93 virtual ~QuicPacketGenerator(); 93 virtual ~QuicPacketGenerator();
94 94
95 // Indicates that an ACK frame should be sent. If |also_send_feedback| is 95 // Indicates that an ACK frame should be sent. If |also_send_feedback| is
96 // true, then it also indicates a CONGESTION_FEEDBACK frame should be sent. 96 // true, then it also indicates a CONGESTION_FEEDBACK frame should be sent.
97 // If |also_send_stop_waiting| is true, then it also indicates that a 97 // If |also_send_stop_waiting| is true, then it also indicates that a
98 // STOP_WAITING frame should be sent as well. 98 // STOP_WAITING frame should be sent as well.
99 // The contents of the frame(s) will be generated via a call to the delegates 99 // The contents of the frame(s) will be generated via a call to the delegates
100 // CreateAckFrame() and CreateFeedbackFrame() when the packet is serialized. 100 // CreateAckFrame() and CreateFeedbackFrame() when the packet is serialized.
(...skipping 23 matching lines...) Expand all
124 // Disables flushing. 124 // Disables flushing.
125 void StartBatchOperations(); 125 void StartBatchOperations();
126 // Enables flushing and flushes queued data which can be sent. 126 // Enables flushing and flushes queued data which can be sent.
127 void FinishBatchOperations(); 127 void FinishBatchOperations();
128 128
129 // Flushes all queued frames, even frames which are not sendable. 129 // Flushes all queued frames, even frames which are not sendable.
130 void FlushAllQueuedFrames(); 130 void FlushAllQueuedFrames();
131 131
132 bool HasQueuedFrames() const; 132 bool HasQueuedFrames() const;
133 133
134 void set_debug_delegate(DebugDelegateInterface* debug_delegate) { 134 void set_debug_delegate(DebugDelegate* debug_delegate) {
135 debug_delegate_ = debug_delegate; 135 debug_delegate_ = debug_delegate;
136 } 136 }
137 137
138 private: 138 private:
139 void SendQueuedFrames(bool flush); 139 void SendQueuedFrames(bool flush);
140 140
141 // Test to see if we have pending ack, feedback, or control frames. 141 // Test to see if we have pending ack, feedback, or control frames.
142 bool HasPendingFrames() const; 142 bool HasPendingFrames() const;
143 // Test to see if the addition of a pending frame (which might be 143 // Test to see if the addition of a pending frame (which might be
144 // retransmittable) would still allow the resulting packet to be sent now. 144 // retransmittable) would still allow the resulting packet to be sent now.
145 bool CanSendWithNextPendingFrameAddition() const; 145 bool CanSendWithNextPendingFrameAddition() const;
146 // Add exactly one pending frame, preferring ack over feedback over control 146 // Add exactly one pending frame, preferring ack over feedback over control
147 // frames. 147 // frames.
148 bool AddNextPendingFrame(); 148 bool AddNextPendingFrame();
149 149
150 bool AddFrame(const QuicFrame& frame); 150 bool AddFrame(const QuicFrame& frame);
151 151
152 void SerializeAndSendPacket(); 152 void SerializeAndSendPacket();
153 153
154 DelegateInterface* delegate_; 154 DelegateInterface* delegate_;
155 DebugDelegateInterface* debug_delegate_; 155 DebugDelegate* debug_delegate_;
156 156
157 QuicPacketCreator* packet_creator_; 157 QuicPacketCreator* packet_creator_;
158 QuicFrames queued_control_frames_; 158 QuicFrames queued_control_frames_;
159 159
160 // True if batch mode is currently enabled. 160 // True if batch mode is currently enabled.
161 bool batch_mode_; 161 bool batch_mode_;
162 162
163 // Flags to indicate the need for just-in-time construction of a frame. 163 // Flags to indicate the need for just-in-time construction of a frame.
164 bool should_send_ack_; 164 bool should_send_ack_;
165 bool should_send_feedback_; 165 bool should_send_feedback_;
166 bool should_send_stop_waiting_; 166 bool should_send_stop_waiting_;
167 // If we put a non-retransmittable frame (namley ack or feedback frame) in 167 // If we put a non-retransmittable frame (namley ack or feedback frame) in
168 // this packet, then we have to hold a reference to it until we flush (and 168 // this packet, then we have to hold a reference to it until we flush (and
169 // serialize it). Retransmittable frames are referenced elsewhere so that they 169 // serialize it). Retransmittable frames are referenced elsewhere so that they
170 // can later be (optionally) retransmitted. 170 // can later be (optionally) retransmitted.
171 scoped_ptr<QuicAckFrame> pending_ack_frame_; 171 scoped_ptr<QuicAckFrame> pending_ack_frame_;
172 scoped_ptr<QuicCongestionFeedbackFrame> pending_feedback_frame_; 172 scoped_ptr<QuicCongestionFeedbackFrame> pending_feedback_frame_;
173 scoped_ptr<QuicStopWaitingFrame> pending_stop_waiting_frame_; 173 scoped_ptr<QuicStopWaitingFrame> pending_stop_waiting_frame_;
174 174
175 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator); 175 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator);
176 }; 176 };
177 177
178 } // namespace net 178 } // namespace net
179 179
180 #endif // NET_QUIC_QUIC_PACKET_GENERATOR_H_ 180 #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