OLD | NEW |
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 #include "net/quic/quic_packet_generator.h" | 5 #include "net/quic/quic_packet_generator.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/quic/quic_bug_tracker.h" | 8 #include "net/quic/quic_bug_tracker.h" |
9 #include "net/quic/quic_flags.h" | 9 #include "net/quic/quic_flags.h" |
10 #include "net/quic/quic_utils.h" | 10 #include "net/quic/quic_utils.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 191 } |
192 | 192 |
193 void QuicPacketGenerator::FlushAllQueuedFrames() { | 193 void QuicPacketGenerator::FlushAllQueuedFrames() { |
194 SendQueuedFrames(/*flush=*/true); | 194 SendQueuedFrames(/*flush=*/true); |
195 } | 195 } |
196 | 196 |
197 bool QuicPacketGenerator::HasQueuedFrames() const { | 197 bool QuicPacketGenerator::HasQueuedFrames() const { |
198 return packet_creator_.HasPendingFrames() || HasPendingFrames(); | 198 return packet_creator_.HasPendingFrames() || HasPendingFrames(); |
199 } | 199 } |
200 | 200 |
| 201 bool QuicPacketGenerator::IsPendingPacketEmpty() const { |
| 202 return !packet_creator_.HasPendingFrames(); |
| 203 } |
| 204 |
201 bool QuicPacketGenerator::HasPendingFrames() const { | 205 bool QuicPacketGenerator::HasPendingFrames() const { |
202 return should_send_ack_ || should_send_stop_waiting_ || | 206 return should_send_ack_ || should_send_stop_waiting_ || |
203 !queued_control_frames_.empty(); | 207 !queued_control_frames_.empty(); |
204 } | 208 } |
205 | 209 |
206 bool QuicPacketGenerator::AddNextPendingFrame() { | 210 bool QuicPacketGenerator::AddNextPendingFrame() { |
207 if (should_send_ack_) { | 211 if (should_send_ack_) { |
208 delegate_->PopulateAckFrame(&pending_ack_frame_); | 212 if (FLAGS_quic_dont_copy_acks) { |
209 // If we can't this add the frame now, then we still need to do so later. | 213 should_send_ack_ = |
210 should_send_ack_ = | 214 !packet_creator_.AddSavedFrame(delegate_->GetUpdatedAckFrame()); |
211 !packet_creator_.AddSavedFrame(QuicFrame(&pending_ack_frame_)); | 215 } else { |
212 // Return success if we have cleared out this flag (i.e., added the frame). | 216 delegate_->PopulateAckFrame(&pending_ack_frame_); |
213 // If we still need to send, then the frame is full, and we have failed. | 217 // If we can't this add the frame now, then we still need to do so later. |
| 218 should_send_ack_ = |
| 219 !packet_creator_.AddSavedFrame(QuicFrame(&pending_ack_frame_)); |
| 220 // Return success if we have added the frame. |
| 221 } |
214 return !should_send_ack_; | 222 return !should_send_ack_; |
215 } | 223 } |
216 | 224 |
217 if (should_send_stop_waiting_) { | 225 if (should_send_stop_waiting_) { |
218 delegate_->PopulateStopWaitingFrame(&pending_stop_waiting_frame_); | 226 delegate_->PopulateStopWaitingFrame(&pending_stop_waiting_frame_); |
219 // If we can't this add the frame now, then we still need to do so later. | 227 // If we can't this add the frame now, then we still need to do so later. |
220 should_send_stop_waiting_ = | 228 should_send_stop_waiting_ = |
221 !packet_creator_.AddSavedFrame(QuicFrame(&pending_stop_waiting_frame_)); | 229 !packet_creator_.AddSavedFrame(QuicFrame(&pending_stop_waiting_frame_)); |
222 // Return success if we have cleared out this flag (i.e., added the frame). | 230 // Return success if we have cleared out this flag (i.e., added the frame). |
223 // If we still need to send, then the frame is full, and we have failed. | 231 // If we still need to send, then the frame is full, and we have failed. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 301 |
294 void QuicPacketGenerator::SetCurrentPath( | 302 void QuicPacketGenerator::SetCurrentPath( |
295 QuicPathId path_id, | 303 QuicPathId path_id, |
296 QuicPacketNumber least_packet_awaited_by_peer, | 304 QuicPacketNumber least_packet_awaited_by_peer, |
297 QuicPacketCount max_packets_in_flight) { | 305 QuicPacketCount max_packets_in_flight) { |
298 packet_creator_.SetCurrentPath(path_id, least_packet_awaited_by_peer, | 306 packet_creator_.SetCurrentPath(path_id, least_packet_awaited_by_peer, |
299 max_packets_in_flight); | 307 max_packets_in_flight); |
300 } | 308 } |
301 | 309 |
302 } // namespace net | 310 } // namespace net |
OLD | NEW |