| 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/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "net/quic/quic_ack_notifier.h" | 9 #include "net/quic/quic_ack_notifier.h" |
| 10 #include "net/quic/quic_fec_group.h" | 10 #include "net/quic/quic_fec_group.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 int frames_created = 0; | 165 int frames_created = 0; |
| 166 while (delegate_->ShouldGeneratePacket( | 166 while (delegate_->ShouldGeneratePacket( |
| 167 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, | 167 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, |
| 168 has_handshake ? IS_HANDSHAKE : NOT_HANDSHAKE)) { | 168 has_handshake ? IS_HANDSHAKE : NOT_HANDSHAKE)) { |
| 169 QuicFrame frame; | 169 QuicFrame frame; |
| 170 size_t bytes_consumed = packet_creator_.CreateStreamFrame( | 170 size_t bytes_consumed = packet_creator_.CreateStreamFrame( |
| 171 id, data, offset + total_bytes_consumed, fin, &frame); | 171 id, data, offset + total_bytes_consumed, fin, &frame); |
| 172 ++frames_created; | 172 ++frames_created; |
| 173 | 173 |
| 174 // We want to track which packet this stream frame ends up in. | 174 // We want to track which packet this stream frame ends up in. |
| 175 if (FLAGS_quic_attach_ack_notifiers_to_packets) { | 175 if (notifier != nullptr) { |
| 176 if (notifier != nullptr) { | 176 ack_notifiers_.push_back(notifier); |
| 177 ack_notifiers_.push_back(notifier); | |
| 178 } | |
| 179 } else { | |
| 180 frame.stream_frame->notifier = notifier; | |
| 181 } | 177 } |
| 182 | 178 |
| 183 if (!AddFrame(frame)) { | 179 if (!AddFrame(frame)) { |
| 184 LOG(DFATAL) << "Failed to add stream frame."; | 180 LOG(DFATAL) << "Failed to add stream frame."; |
| 185 // Inability to add a STREAM frame creates an unrecoverable hole in a | 181 // Inability to add a STREAM frame creates an unrecoverable hole in a |
| 186 // the stream, so it's best to close the connection. | 182 // the stream, so it's best to close the connection. |
| 187 delegate_->CloseConnection(QUIC_INTERNAL_ERROR, false); | 183 delegate_->CloseConnection(QUIC_INTERNAL_ERROR, false); |
| 188 delete notifier; | 184 delete notifier; |
| 189 return QuicConsumedData(0, false); | 185 return QuicConsumedData(0, false); |
| 190 } | 186 } |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 debug_delegate_->OnFrameAddedToPacket(frame); | 389 debug_delegate_->OnFrameAddedToPacket(frame); |
| 394 } | 390 } |
| 395 return success; | 391 return success; |
| 396 } | 392 } |
| 397 | 393 |
| 398 void QuicPacketGenerator::SerializeAndSendPacket() { | 394 void QuicPacketGenerator::SerializeAndSendPacket() { |
| 399 SerializedPacket serialized_packet = packet_creator_.SerializePacket(); | 395 SerializedPacket serialized_packet = packet_creator_.SerializePacket(); |
| 400 DCHECK(serialized_packet.packet); | 396 DCHECK(serialized_packet.packet); |
| 401 | 397 |
| 402 // There may be AckNotifiers interested in this packet. | 398 // There may be AckNotifiers interested in this packet. |
| 403 if (FLAGS_quic_attach_ack_notifiers_to_packets) { | 399 serialized_packet.notifiers.swap(ack_notifiers_); |
| 404 serialized_packet.notifiers.swap(ack_notifiers_); | 400 ack_notifiers_.clear(); |
| 405 ack_notifiers_.clear(); | |
| 406 } | |
| 407 | 401 |
| 408 delegate_->OnSerializedPacket(serialized_packet); | 402 delegate_->OnSerializedPacket(serialized_packet); |
| 409 MaybeSendFecPacketAndCloseGroup(/*force=*/false); | 403 MaybeSendFecPacketAndCloseGroup(/*force=*/false); |
| 410 | 404 |
| 411 // The packet has now been serialized, so the frames are no longer queued. | 405 // The packet has now been serialized, so the frames are no longer queued. |
| 412 ack_queued_ = false; | 406 ack_queued_ = false; |
| 413 stop_waiting_queued_ = false; | 407 stop_waiting_queued_ = false; |
| 414 } | 408 } |
| 415 | 409 |
| 416 void QuicPacketGenerator::StopSendingVersion() { | 410 void QuicPacketGenerator::StopSendingVersion() { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 packet_creator_.set_connection_id_length(PACKET_8BYTE_CONNECTION_ID); | 452 packet_creator_.set_connection_id_length(PACKET_8BYTE_CONNECTION_ID); |
| 459 } | 453 } |
| 460 } | 454 } |
| 461 | 455 |
| 462 | 456 |
| 463 void QuicPacketGenerator::set_encryption_level(EncryptionLevel level) { | 457 void QuicPacketGenerator::set_encryption_level(EncryptionLevel level) { |
| 464 packet_creator_.set_encryption_level(level); | 458 packet_creator_.set_encryption_level(level); |
| 465 } | 459 } |
| 466 | 460 |
| 467 } // namespace net | 461 } // namespace net |
| OLD | NEW |