| 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_fec_group.h" | 9 #include "net/quic/quic_fec_group.h" |
| 9 #include "net/quic/quic_flags.h" | 10 #include "net/quic/quic_flags.h" |
| 10 #include "net/quic/quic_utils.h" | 11 #include "net/quic/quic_utils.h" |
| 11 | 12 |
| 12 using base::StringPiece; | 13 using base::StringPiece; |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 | 16 |
| 16 class QuicAckNotifier; | 17 class QuicAckNotifier; |
| 17 | 18 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 packet_creator_.OnRttChange(rtt); | 78 packet_creator_.OnRttChange(rtt); |
| 78 } | 79 } |
| 79 | 80 |
| 80 void QuicPacketGenerator::SetShouldSendAck(bool also_send_stop_waiting) { | 81 void QuicPacketGenerator::SetShouldSendAck(bool also_send_stop_waiting) { |
| 81 if (packet_creator_.has_ack()) { | 82 if (packet_creator_.has_ack()) { |
| 82 // Ack already queued, nothing to do. | 83 // Ack already queued, nothing to do. |
| 83 return; | 84 return; |
| 84 } | 85 } |
| 85 | 86 |
| 86 if (also_send_stop_waiting && packet_creator_.has_stop_waiting()) { | 87 if (also_send_stop_waiting && packet_creator_.has_stop_waiting()) { |
| 87 LOG(DFATAL) << "Should only ever be one pending stop waiting frame."; | 88 QUIC_BUG << "Should only ever be one pending stop waiting frame."; |
| 88 return; | 89 return; |
| 89 } | 90 } |
| 90 | 91 |
| 91 should_send_ack_ = true; | 92 should_send_ack_ = true; |
| 92 should_send_stop_waiting_ = also_send_stop_waiting; | 93 should_send_stop_waiting_ = also_send_stop_waiting; |
| 93 SendQueuedFrames(/*flush=*/false, /*is_fec_timeout=*/false); | 94 SendQueuedFrames(/*flush=*/false, /*is_fec_timeout=*/false); |
| 94 } | 95 } |
| 95 | 96 |
| 96 void QuicPacketGenerator::AddControlFrame(const QuicFrame& frame) { | 97 void QuicPacketGenerator::AddControlFrame(const QuicFrame& frame) { |
| 97 queued_control_frames_.push_back(frame); | 98 queued_control_frames_.push_back(frame); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 113 SendQueuedFrames(flush, /*is_fec_timeout=*/false); | 114 SendQueuedFrames(flush, /*is_fec_timeout=*/false); |
| 114 | 115 |
| 115 size_t total_bytes_consumed = 0; | 116 size_t total_bytes_consumed = 0; |
| 116 bool fin_consumed = false; | 117 bool fin_consumed = false; |
| 117 | 118 |
| 118 if (!packet_creator_.HasRoomForStreamFrame(id, offset)) { | 119 if (!packet_creator_.HasRoomForStreamFrame(id, offset)) { |
| 119 packet_creator_.Flush(); | 120 packet_creator_.Flush(); |
| 120 } | 121 } |
| 121 | 122 |
| 122 if (!fin && (iov.total_length == 0)) { | 123 if (!fin && (iov.total_length == 0)) { |
| 123 LOG(DFATAL) << "Attempt to consume empty data without FIN."; | 124 QUIC_BUG << "Attempt to consume empty data without FIN."; |
| 124 return QuicConsumedData(0, false); | 125 return QuicConsumedData(0, false); |
| 125 } | 126 } |
| 126 | 127 |
| 127 while (delegate_->ShouldGeneratePacket( | 128 while (delegate_->ShouldGeneratePacket( |
| 128 HAS_RETRANSMITTABLE_DATA, has_handshake ? IS_HANDSHAKE : NOT_HANDSHAKE)) { | 129 HAS_RETRANSMITTABLE_DATA, has_handshake ? IS_HANDSHAKE : NOT_HANDSHAKE)) { |
| 129 QuicFrame frame; | 130 QuicFrame frame; |
| 130 if (!packet_creator_.ConsumeData(id, iov, total_bytes_consumed, | 131 if (!packet_creator_.ConsumeData(id, iov, total_bytes_consumed, |
| 131 offset + total_bytes_consumed, fin, | 132 offset + total_bytes_consumed, fin, |
| 132 has_handshake, &frame, fec_protection)) { | 133 has_handshake, &frame, fec_protection)) { |
| 133 // The creator is always flushed if there's not enough room for a new | 134 // The creator is always flushed if there's not enough room for a new |
| 134 // stream frame before ConsumeData, so ConsumeData should always succeed. | 135 // stream frame before ConsumeData, so ConsumeData should always succeed. |
| 135 LOG(DFATAL) << "Failed to ConsumeData, stream:" << id; | 136 QUIC_BUG << "Failed to ConsumeData, stream:" << id; |
| 136 return QuicConsumedData(0, false); | 137 return QuicConsumedData(0, false); |
| 137 } | 138 } |
| 138 | 139 |
| 139 // A stream frame is created and added. | 140 // A stream frame is created and added. |
| 140 size_t bytes_consumed = frame.stream_frame->frame_length; | 141 size_t bytes_consumed = frame.stream_frame->frame_length; |
| 141 if (listener != nullptr) { | 142 if (listener != nullptr) { |
| 142 packet_creator_.AddAckListener(listener, bytes_consumed); | 143 packet_creator_.AddAckListener(listener, bytes_consumed); |
| 143 } | 144 } |
| 144 total_bytes_consumed += bytes_consumed; | 145 total_bytes_consumed += bytes_consumed; |
| 145 fin_consumed = fin && total_bytes_consumed == iov.total_length; | 146 fin_consumed = fin && total_bytes_consumed == iov.total_length; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 225 } |
| 225 if (flush || !InBatchMode()) { | 226 if (flush || !InBatchMode()) { |
| 226 packet_creator_.Flush(); | 227 packet_creator_.Flush(); |
| 227 } | 228 } |
| 228 packet_creator_.MaybeSendFecPacketAndCloseGroup(flush, is_fec_timeout); | 229 packet_creator_.MaybeSendFecPacketAndCloseGroup(flush, is_fec_timeout); |
| 229 } | 230 } |
| 230 | 231 |
| 231 void QuicPacketGenerator::OnFecTimeout() { | 232 void QuicPacketGenerator::OnFecTimeout() { |
| 232 DCHECK(!InBatchMode()); | 233 DCHECK(!InBatchMode()); |
| 233 if (!packet_creator_.ShouldSendFec(true)) { | 234 if (!packet_creator_.ShouldSendFec(true)) { |
| 234 LOG(DFATAL) << "No FEC packet to send on FEC timeout."; | 235 QUIC_BUG << "No FEC packet to send on FEC timeout."; |
| 235 return; | 236 return; |
| 236 } | 237 } |
| 237 // Flush out any pending frames in the generator and the creator, and then | 238 // Flush out any pending frames in the generator and the creator, and then |
| 238 // send out FEC packet. | 239 // send out FEC packet. |
| 239 SendQueuedFrames(/*flush=*/true, /*is_fec_timeout=*/true); | 240 SendQueuedFrames(/*flush=*/true, /*is_fec_timeout=*/true); |
| 240 } | 241 } |
| 241 | 242 |
| 242 QuicTime::Delta QuicPacketGenerator::GetFecTimeout( | 243 QuicTime::Delta QuicPacketGenerator::GetFecTimeout( |
| 243 QuicPacketNumber packet_number) { | 244 QuicPacketNumber packet_number) { |
| 244 return packet_creator_.GetFecTimeout(packet_number); | 245 return packet_creator_.GetFecTimeout(packet_number); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 394 |
| 394 FecSendPolicy QuicPacketGenerator::fec_send_policy() { | 395 FecSendPolicy QuicPacketGenerator::fec_send_policy() { |
| 395 return packet_creator_.fec_send_policy(); | 396 return packet_creator_.fec_send_policy(); |
| 396 } | 397 } |
| 397 | 398 |
| 398 void QuicPacketGenerator::set_fec_send_policy(FecSendPolicy fec_send_policy) { | 399 void QuicPacketGenerator::set_fec_send_policy(FecSendPolicy fec_send_policy) { |
| 399 packet_creator_.set_fec_send_policy(fec_send_policy); | 400 packet_creator_.set_fec_send_policy(fec_send_policy); |
| 400 } | 401 } |
| 401 | 402 |
| 402 } // namespace net | 403 } // namespace net |
| OLD | NEW |