| 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/core/quic_packet_generator.h" | 5 #include "net/quic/core/quic_packet_generator.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "net/quic/core/quic_bug_tracker.h" | 8 #include "net/quic/core/quic_bug_tracker.h" |
| 9 #include "net/quic/core/quic_flags.h" | 9 #include "net/quic/core/quic_flags.h" |
| 10 #include "net/quic/core/quic_utils.h" | 10 #include "net/quic/core/quic_utils.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 if (retransmittable == HAS_RETRANSMITTABLE_DATA) { | 188 if (retransmittable == HAS_RETRANSMITTABLE_DATA) { |
| 189 DCHECK(!queued_control_frames_.empty()); // These are retransmittable. | 189 DCHECK(!queued_control_frames_.empty()); // These are retransmittable. |
| 190 } | 190 } |
| 191 return delegate_->ShouldGeneratePacket(retransmittable, NOT_HANDSHAKE); | 191 return delegate_->ShouldGeneratePacket(retransmittable, NOT_HANDSHAKE); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void QuicPacketGenerator::SendQueuedFrames(bool flush) { | 194 void QuicPacketGenerator::SendQueuedFrames(bool flush) { |
| 195 // Only add pending frames if we are SURE we can then send the whole packet. | 195 // Only add pending frames if we are SURE we can then send the whole packet. |
| 196 while (HasPendingFrames() && | 196 while (HasPendingFrames() && |
| 197 (flush || CanSendWithNextPendingFrameAddition())) { | 197 (flush || CanSendWithNextPendingFrameAddition())) { |
| 198 AddNextPendingFrame(); | 198 if (FLAGS_quic_close_connection_on_huge_frames) { |
| 199 bool first_frame = packet_creator_.CanSetMaxPacketLength(); |
| 200 if (!AddNextPendingFrame() && first_frame) { |
| 201 // A single frame cannot fit into the packet, tear down the connection. |
| 202 QUIC_BUG << "A single frame cannot fit into packet." |
| 203 << " should_send_ack: " << should_send_ack_ |
| 204 << " should_send_stop_waiting: " << should_send_stop_waiting_ |
| 205 << " number of queued_control_frames: " |
| 206 << queued_control_frames_.size(); |
| 207 if (!queued_control_frames_.empty()) { |
| 208 DVLOG(1) << queued_control_frames_[0]; |
| 209 } |
| 210 delegate_->OnUnrecoverableError(QUIC_FAILED_TO_SERIALIZE_PACKET, |
| 211 "Single frame cannot fit into a packet", |
| 212 ConnectionCloseSource::FROM_SELF); |
| 213 return; |
| 214 } |
| 215 } else { |
| 216 AddNextPendingFrame(); |
| 217 } |
| 199 } | 218 } |
| 200 if (flush || !InBatchMode()) { | 219 if (flush || !InBatchMode()) { |
| 201 packet_creator_.Flush(); | 220 packet_creator_.Flush(); |
| 202 } | 221 } |
| 203 } | 222 } |
| 204 | 223 |
| 205 bool QuicPacketGenerator::InBatchMode() { | 224 bool QuicPacketGenerator::InBatchMode() { |
| 206 return batch_mode_; | 225 return batch_mode_; |
| 207 } | 226 } |
| 208 | 227 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 338 |
| 320 void QuicPacketGenerator::SetCurrentPath( | 339 void QuicPacketGenerator::SetCurrentPath( |
| 321 QuicPathId path_id, | 340 QuicPathId path_id, |
| 322 QuicPacketNumber least_packet_awaited_by_peer, | 341 QuicPacketNumber least_packet_awaited_by_peer, |
| 323 QuicPacketCount max_packets_in_flight) { | 342 QuicPacketCount max_packets_in_flight) { |
| 324 packet_creator_.SetCurrentPath(path_id, least_packet_awaited_by_peer, | 343 packet_creator_.SetCurrentPath(path_id, least_packet_awaited_by_peer, |
| 325 max_packets_in_flight); | 344 max_packets_in_flight); |
| 326 } | 345 } |
| 327 | 346 |
| 328 } // namespace net | 347 } // namespace net |
| OLD | NEW |