| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_sent_packet_manager.h" | 5 #include "net/quic/quic_sent_packet_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 if (it->in_flight) { | 315 if (it->in_flight) { |
| 316 packets_acked_.push_back(std::make_pair(packet_number, it->bytes_sent)); | 316 packets_acked_.push_back(std::make_pair(packet_number, it->bytes_sent)); |
| 317 } else if (FLAGS_quic_loss_recovery_use_largest_acked && | 317 } else if (FLAGS_quic_loss_recovery_use_largest_acked && |
| 318 !it->is_unackable) { | 318 !it->is_unackable) { |
| 319 largest_newly_acked_ = packet_number; | 319 largest_newly_acked_ = packet_number; |
| 320 } | 320 } |
| 321 MarkPacketHandled(packet_number, &(*it), ack_delay_time); | 321 MarkPacketHandled(packet_number, &(*it), ack_delay_time); |
| 322 } | 322 } |
| 323 } | 323 } |
| 324 | 324 |
| 325 bool QuicSentPacketManager::HasRetransmittableFrames( | |
| 326 QuicPathId, | |
| 327 QuicPacketNumber packet_number) const { | |
| 328 return unacked_packets_.HasRetransmittableFrames(packet_number); | |
| 329 } | |
| 330 | |
| 331 void QuicSentPacketManager::RetransmitUnackedPackets( | 325 void QuicSentPacketManager::RetransmitUnackedPackets( |
| 332 TransmissionType retransmission_type) { | 326 TransmissionType retransmission_type) { |
| 333 DCHECK(retransmission_type == ALL_UNACKED_RETRANSMISSION || | 327 DCHECK(retransmission_type == ALL_UNACKED_RETRANSMISSION || |
| 334 retransmission_type == ALL_INITIAL_RETRANSMISSION); | 328 retransmission_type == ALL_INITIAL_RETRANSMISSION); |
| 335 QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); | 329 QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); |
| 336 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 330 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
| 337 it != unacked_packets_.end(); ++it, ++packet_number) { | 331 it != unacked_packets_.end(); ++it, ++packet_number) { |
| 338 if (!it->retransmittable_frames.empty() && | 332 if (!it->retransmittable_frames.empty() && |
| 339 (retransmission_type == ALL_UNACKED_RETRANSMISSION || | 333 (retransmission_type == ALL_UNACKED_RETRANSMISSION || |
| 340 it->encryption_level == ENCRYPTION_INITIAL)) { | 334 it->encryption_level == ENCRYPTION_INITIAL)) { |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 largest_mtu_acked_ = info->bytes_sent; | 522 largest_mtu_acked_ = info->bytes_sent; |
| 529 network_change_visitor_->OnPathMtuIncreased(largest_mtu_acked_); | 523 network_change_visitor_->OnPathMtuIncreased(largest_mtu_acked_); |
| 530 } | 524 } |
| 531 unacked_packets_.RemoveFromInFlight(info); | 525 unacked_packets_.RemoveFromInFlight(info); |
| 532 unacked_packets_.RemoveRetransmittability(info); | 526 unacked_packets_.RemoveRetransmittability(info); |
| 533 if (FLAGS_quic_loss_recovery_use_largest_acked) { | 527 if (FLAGS_quic_loss_recovery_use_largest_acked) { |
| 534 info->is_unackable = true; | 528 info->is_unackable = true; |
| 535 } | 529 } |
| 536 } | 530 } |
| 537 | 531 |
| 538 bool QuicSentPacketManager::IsUnacked(QuicPathId, | |
| 539 QuicPacketNumber packet_number) const { | |
| 540 return unacked_packets_.IsUnacked(packet_number); | |
| 541 } | |
| 542 | |
| 543 bool QuicSentPacketManager::HasUnackedPackets() const { | 532 bool QuicSentPacketManager::HasUnackedPackets() const { |
| 544 return unacked_packets_.HasUnackedPackets(); | 533 return unacked_packets_.HasUnackedPackets(); |
| 545 } | 534 } |
| 546 | 535 |
| 547 QuicPacketNumber QuicSentPacketManager::GetLeastUnacked(QuicPathId) const { | 536 QuicPacketNumber QuicSentPacketManager::GetLeastUnacked(QuicPathId) const { |
| 548 return unacked_packets_.GetLeastUnacked(); | 537 return unacked_packets_.GetLeastUnacked(); |
| 549 } | 538 } |
| 550 | 539 |
| 551 bool QuicSentPacketManager::OnPacketSent( | 540 bool QuicSentPacketManager::OnPacketSent( |
| 552 SerializedPacket* serialized_packet, | 541 SerializedPacket* serialized_packet, |
| 553 QuicPathId /*original_path_id*/, | 542 QuicPathId /*original_path_id*/, |
| 554 QuicPacketNumber original_packet_number, | 543 QuicPacketNumber original_packet_number, |
| 555 QuicTime sent_time, | 544 QuicTime sent_time, |
| 556 TransmissionType transmission_type, | 545 TransmissionType transmission_type, |
| 557 HasRetransmittableData has_retransmittable_data) { | 546 HasRetransmittableData has_retransmittable_data) { |
| 558 QuicPacketNumber packet_number = serialized_packet->packet_number; | 547 QuicPacketNumber packet_number = serialized_packet->packet_number; |
| 559 DCHECK_LT(0u, packet_number); | 548 DCHECK_LT(0u, packet_number); |
| 560 DCHECK(!unacked_packets_.IsUnacked(packet_number)); | 549 DCHECK(!unacked_packets_.IsUnacked(packet_number)); |
| 561 QUIC_BUG_IF(serialized_packet->encrypted_length == 0) | 550 QUIC_BUG_IF(serialized_packet->encrypted_length == 0) |
| 562 << "Cannot send empty packets."; | 551 << "Cannot send empty packets."; |
| 563 | 552 |
| 564 if (delegate_ == nullptr && original_packet_number != 0) { | 553 if (delegate_ == nullptr && original_packet_number != 0) { |
| 565 if (!pending_retransmissions_.erase(original_packet_number) && | 554 pending_retransmissions_.erase(original_packet_number); |
| 566 !FLAGS_quic_always_write_queued_retransmissions) { | |
| 567 QUIC_BUG << "Expected packet number to be in " | |
| 568 << "pending_retransmissions_. packet_number: " | |
| 569 << original_packet_number; | |
| 570 } | |
| 571 } | 555 } |
| 572 | 556 |
| 573 if (pending_timer_transmission_count_ > 0) { | 557 if (pending_timer_transmission_count_ > 0) { |
| 574 --pending_timer_transmission_count_; | 558 --pending_timer_transmission_count_; |
| 575 } | 559 } |
| 576 | 560 |
| 577 // TODO(ianswett): Remove sent_time, because it's unused. | 561 // TODO(ianswett): Remove sent_time, because it's unused. |
| 578 const bool in_flight = send_algorithm_->OnPacketSent( | 562 const bool in_flight = send_algorithm_->OnPacketSent( |
| 579 sent_time, unacked_packets_.bytes_in_flight(), packet_number, | 563 sent_time, unacked_packets_.bytes_in_flight(), packet_number, |
| 580 serialized_packet->encrypted_length, has_retransmittable_data); | 564 serialized_packet->encrypted_length, has_retransmittable_data); |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 } | 904 } |
| 921 | 905 |
| 922 void QuicSentPacketManager::CancelRetransmissionsForStream( | 906 void QuicSentPacketManager::CancelRetransmissionsForStream( |
| 923 QuicStreamId stream_id) { | 907 QuicStreamId stream_id) { |
| 924 unacked_packets_.CancelRetransmissionsForStream(stream_id); | 908 unacked_packets_.CancelRetransmissionsForStream(stream_id); |
| 925 if (delegate_ != nullptr) { | 909 if (delegate_ != nullptr) { |
| 926 return; | 910 return; |
| 927 } | 911 } |
| 928 PendingRetransmissionMap::iterator it = pending_retransmissions_.begin(); | 912 PendingRetransmissionMap::iterator it = pending_retransmissions_.begin(); |
| 929 while (it != pending_retransmissions_.end()) { | 913 while (it != pending_retransmissions_.end()) { |
| 930 if (HasRetransmittableFrames(path_id_, it->first)) { | 914 if (unacked_packets_.HasRetransmittableFrames(it->first)) { |
| 931 ++it; | 915 ++it; |
| 932 continue; | 916 continue; |
| 933 } | 917 } |
| 934 it = pending_retransmissions_.erase(it); | 918 it = pending_retransmissions_.erase(it); |
| 935 } | 919 } |
| 936 } | 920 } |
| 937 | 921 |
| 938 void QuicSentPacketManager::EnablePacing() { | 922 void QuicSentPacketManager::EnablePacing() { |
| 939 // TODO(ianswett): Replace with a method which wraps the send algorithm in a | 923 // TODO(ianswett): Replace with a method which wraps the send algorithm in a |
| 940 // pacer every time a new algorithm is set. | 924 // pacer every time a new algorithm is set. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 TransmissionInfo* QuicSentPacketManager::GetMutableTransmissionInfo( | 990 TransmissionInfo* QuicSentPacketManager::GetMutableTransmissionInfo( |
| 1007 QuicPacketNumber packet_number) { | 991 QuicPacketNumber packet_number) { |
| 1008 return unacked_packets_.GetMutableTransmissionInfo(packet_number); | 992 return unacked_packets_.GetMutableTransmissionInfo(packet_number); |
| 1009 } | 993 } |
| 1010 | 994 |
| 1011 void QuicSentPacketManager::RemoveObsoletePackets() { | 995 void QuicSentPacketManager::RemoveObsoletePackets() { |
| 1012 unacked_packets_.RemoveObsoletePackets(); | 996 unacked_packets_.RemoveObsoletePackets(); |
| 1013 } | 997 } |
| 1014 | 998 |
| 1015 } // namespace net | 999 } // namespace net |
| OLD | NEW |