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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 int frames_created = 0; | 177 int frames_created = 0; |
178 while (delegate_->ShouldGeneratePacket(NOT_RETRANSMISSION, | 178 while (delegate_->ShouldGeneratePacket(NOT_RETRANSMISSION, |
179 HAS_RETRANSMITTABLE_DATA, handshake)) { | 179 HAS_RETRANSMITTABLE_DATA, handshake)) { |
180 QuicFrame frame; | 180 QuicFrame frame; |
181 size_t bytes_consumed = packet_creator_.CreateStreamFrame( | 181 size_t bytes_consumed = packet_creator_.CreateStreamFrame( |
182 id, data, offset + total_bytes_consumed, fin, &frame); | 182 id, data, offset + total_bytes_consumed, fin, &frame); |
183 ++frames_created; | 183 ++frames_created; |
184 | 184 |
185 // We want to track which packet this stream frame ends up in. | 185 // We want to track which packet this stream frame ends up in. |
186 frame.stream_frame->notifier = notifier; | 186 if (FLAGS_quic_attach_ack_notifiers_to_packets) { |
| 187 if (notifier != nullptr) { |
| 188 ack_notifiers_.insert(notifier); |
| 189 } |
| 190 } else { |
| 191 frame.stream_frame->notifier = notifier; |
| 192 } |
187 | 193 |
188 if (!AddFrame(frame)) { | 194 if (!AddFrame(frame)) { |
189 LOG(DFATAL) << "Failed to add stream frame."; | 195 LOG(DFATAL) << "Failed to add stream frame."; |
190 // Inability to add a STREAM frame creates an unrecoverable hole in a | 196 // Inability to add a STREAM frame creates an unrecoverable hole in a |
191 // the stream, so it's best to close the connection. | 197 // the stream, so it's best to close the connection. |
192 delegate_->CloseConnection(QUIC_INTERNAL_ERROR, false); | 198 delegate_->CloseConnection(QUIC_INTERNAL_ERROR, false); |
193 delete notifier; | 199 delete notifier; |
194 return QuicConsumedData(0, false); | 200 return QuicConsumedData(0, false); |
195 } | 201 } |
196 | 202 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 bool success = packet_creator_.AddSavedFrame(frame); | 388 bool success = packet_creator_.AddSavedFrame(frame); |
383 if (success && debug_delegate_) { | 389 if (success && debug_delegate_) { |
384 debug_delegate_->OnFrameAddedToPacket(frame); | 390 debug_delegate_->OnFrameAddedToPacket(frame); |
385 } | 391 } |
386 return success; | 392 return success; |
387 } | 393 } |
388 | 394 |
389 void QuicPacketGenerator::SerializeAndSendPacket() { | 395 void QuicPacketGenerator::SerializeAndSendPacket() { |
390 SerializedPacket serialized_packet = packet_creator_.SerializePacket(); | 396 SerializedPacket serialized_packet = packet_creator_.SerializePacket(); |
391 DCHECK(serialized_packet.packet); | 397 DCHECK(serialized_packet.packet); |
| 398 |
| 399 // There may be AckNotifiers interested in this packet. |
| 400 if (FLAGS_quic_attach_ack_notifiers_to_packets) { |
| 401 serialized_packet.notifiers.swap(ack_notifiers_); |
| 402 ack_notifiers_.clear(); |
| 403 } |
| 404 |
392 delegate_->OnSerializedPacket(serialized_packet); | 405 delegate_->OnSerializedPacket(serialized_packet); |
393 MaybeSendFecPacketAndCloseGroup(false); | 406 MaybeSendFecPacketAndCloseGroup(false); |
394 | 407 |
395 // The packet has now been serialized, safe to delete pending frames. | 408 // The packet has now been serialized, safe to delete pending frames. |
396 if (FLAGS_quic_disallow_multiple_pending_ack_frames) { | 409 if (FLAGS_quic_disallow_multiple_pending_ack_frames) { |
397 pending_ack_frame_.reset(); | 410 pending_ack_frame_.reset(); |
398 pending_feedback_frame_.reset(); | 411 pending_feedback_frame_.reset(); |
399 pending_stop_waiting_frame_.reset(); | 412 pending_stop_waiting_frame_.reset(); |
400 } | 413 } |
401 } | 414 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 packet_creator_.set_connection_id_length(PACKET_8BYTE_CONNECTION_ID); | 458 packet_creator_.set_connection_id_length(PACKET_8BYTE_CONNECTION_ID); |
446 } | 459 } |
447 } | 460 } |
448 | 461 |
449 | 462 |
450 void QuicPacketGenerator::set_encryption_level(EncryptionLevel level) { | 463 void QuicPacketGenerator::set_encryption_level(EncryptionLevel level) { |
451 packet_creator_.set_encryption_level(level); | 464 packet_creator_.set_encryption_level(level); |
452 } | 465 } |
453 | 466 |
454 } // namespace net | 467 } // namespace net |
OLD | NEW |