| Index: net/quic/quic_unacked_packet_map.cc
|
| diff --git a/net/quic/quic_unacked_packet_map.cc b/net/quic/quic_unacked_packet_map.cc
|
| index 053b445b0e9c2fce2abb4055600df5db3dfcb490..b230485a9288548893637ee9153fe8be1db89408 100644
|
| --- a/net/quic/quic_unacked_packet_map.cc
|
| +++ b/net/quic/quic_unacked_packet_map.cc
|
| @@ -15,6 +15,7 @@ namespace net {
|
|
|
| QuicUnackedPacketMap::QuicUnackedPacketMap()
|
| : largest_sent_packet_(0),
|
| + largest_observed_(0),
|
| bytes_in_flight_(0),
|
| pending_crypto_packet_count_(0) {
|
| }
|
| @@ -83,10 +84,10 @@ void QuicUnackedPacketMap::ClearPreviousRetransmissions(size_t num_to_clear) {
|
| UnackedPacketMap::iterator it = unacked_packets_.begin();
|
| while (it != unacked_packets_.end() && num_to_clear > 0) {
|
| QuicPacketSequenceNumber sequence_number = it->first;
|
| - // If this is a pending packet, or has retransmittable data, then there is
|
| + // If this packet is in flight, or has retransmittable data, then there is
|
| // no point in clearing out any further packets, because they would not
|
| // affect the high water mark.
|
| - if (it->second.pending || it->second.retransmittable_frames != NULL) {
|
| + if (it->second.in_flight || it->second.retransmittable_frames != NULL) {
|
| break;
|
| }
|
|
|
| @@ -123,16 +124,15 @@ void QuicUnackedPacketMap::NackPacket(QuicPacketSequenceNumber sequence_number,
|
| }
|
|
|
| void QuicUnackedPacketMap::RemoveRetransmittability(
|
| - QuicPacketSequenceNumber sequence_number,
|
| - QuicPacketSequenceNumber largest_observed) {
|
| + QuicPacketSequenceNumber sequence_number) {
|
| UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number);
|
| if (it == unacked_packets_.end()) {
|
| - LOG(DFATAL) << "packet is not unacked: " << sequence_number;
|
| + DVLOG(1) << "packet is not in unacked_packets: " << sequence_number;
|
| return;
|
| }
|
| SequenceNumberSet* all_transmissions = it->second.all_transmissions;
|
| // TODO(ianswett): Consider optimizing this for lone packets.
|
| - // TODO(ianswett): Consider adding a check to ensure there are retranmittable
|
| + // TODO(ianswett): Consider adding a check to ensure there are retransmittable
|
| // frames associated with this packet.
|
| for (SequenceNumberSet::reverse_iterator it = all_transmissions->rbegin();
|
| it != all_transmissions->rend(); ++it) {
|
| @@ -143,7 +143,7 @@ void QuicUnackedPacketMap::RemoveRetransmittability(
|
| continue;
|
| }
|
| MaybeRemoveRetransmittableFrames(transmission_info);
|
| - if (sequence_number <= largest_observed && !transmission_info->pending) {
|
| + if (*it <= largest_observed_ && !transmission_info->in_flight) {
|
| unacked_packets_.erase(*it);
|
| } else {
|
| transmission_info->all_transmissions = new SequenceNumberSet();
|
| @@ -166,27 +166,29 @@ void QuicUnackedPacketMap::MaybeRemoveRetransmittableFrames(
|
| }
|
| }
|
|
|
| -void QuicUnackedPacketMap::RemoveRttOnlyPacket(
|
| - QuicPacketSequenceNumber sequence_number) {
|
| - UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number);
|
| - if (it == unacked_packets_.end()) {
|
| - LOG(DFATAL) << "packet is not unacked: " << sequence_number;
|
| - return;
|
| +void QuicUnackedPacketMap::IncreaseLargestObserved(
|
| + QuicPacketSequenceNumber largest_observed) {
|
| + DCHECK_LT(largest_observed_, largest_observed);
|
| + largest_observed_ = largest_observed;
|
| + UnackedPacketMap::iterator it = unacked_packets_.begin();
|
| + while (it != unacked_packets_.end() && it->first <= largest_observed_) {
|
| + if (!IsPacketUseless(it)) {
|
| + ++it;
|
| + continue;
|
| + }
|
| + delete it->second.all_transmissions;
|
| + QuicPacketSequenceNumber sequence_number = it->first;
|
| + ++it;
|
| + unacked_packets_.erase(sequence_number);
|
| }
|
| - TransmissionInfo* transmission_info = &it->second;
|
| - DCHECK(!transmission_info->pending);
|
| - DCHECK(transmission_info->retransmittable_frames == NULL);
|
| - DCHECK_EQ(1u, transmission_info->all_transmissions->size());
|
| - delete transmission_info->all_transmissions;
|
| - unacked_packets_.erase(it);
|
| }
|
|
|
| -// static
|
| -bool QuicUnackedPacketMap::IsForRttOnly(
|
| - const TransmissionInfo& transmission_info) {
|
| - return !transmission_info.pending &&
|
| - transmission_info.retransmittable_frames == NULL &&
|
| - transmission_info.all_transmissions->size() == 1;
|
| +bool QuicUnackedPacketMap::IsPacketUseless(
|
| + UnackedPacketMap::const_iterator it) const {
|
| + return it->first <= largest_observed_ &&
|
| + !it->second.in_flight &&
|
| + it->second.retransmittable_frames == NULL &&
|
| + it->second.all_transmissions->size() == 1;
|
| }
|
|
|
| bool QuicUnackedPacketMap::IsUnacked(
|
| @@ -194,18 +196,22 @@ bool QuicUnackedPacketMap::IsUnacked(
|
| return ContainsKey(unacked_packets_, sequence_number);
|
| }
|
|
|
| -void QuicUnackedPacketMap::SetNotPending(
|
| +void QuicUnackedPacketMap::RemoveFromInFlight(
|
| QuicPacketSequenceNumber sequence_number) {
|
| UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number);
|
| if (it == unacked_packets_.end()) {
|
| - LOG(DFATAL) << "SetNotPending called for packet that is not unacked: "
|
| + LOG(DFATAL) << "RemoveFromFlight called for packet that is not unacked: "
|
| << sequence_number;
|
| return;
|
| }
|
| - if (it->second.pending) {
|
| + if (it->second.in_flight) {
|
| LOG_IF(DFATAL, bytes_in_flight_ < it->second.bytes_sent);
|
| bytes_in_flight_ -= it->second.bytes_sent;
|
| - it->second.pending = false;
|
| + it->second.in_flight = false;
|
| + }
|
| + if (IsPacketUseless(it)) {
|
| + delete it->second.all_transmissions;
|
| + unacked_packets_.erase(it);
|
| }
|
| }
|
|
|
| @@ -213,7 +219,7 @@ bool QuicUnackedPacketMap::HasUnackedPackets() const {
|
| return !unacked_packets_.empty();
|
| }
|
|
|
| -bool QuicUnackedPacketMap::HasPendingPackets() const {
|
| +bool QuicUnackedPacketMap::HasInFlightPackets() const {
|
| return bytes_in_flight_ > 0;
|
| }
|
|
|
| @@ -225,25 +231,24 @@ const TransmissionInfo& QuicUnackedPacketMap::GetTransmissionInfo(
|
| QuicTime QuicUnackedPacketMap::GetLastPacketSentTime() const {
|
| UnackedPacketMap::const_reverse_iterator it = unacked_packets_.rbegin();
|
| while (it != unacked_packets_.rend()) {
|
| - if (it->second.pending) {
|
| + if (it->second.in_flight) {
|
| LOG_IF(DFATAL, it->second.sent_time == QuicTime::Zero())
|
| - << "Sent time can never be zero for a pending packet.";
|
| + << "Sent time can never be zero for a packet in flight.";
|
| return it->second.sent_time;
|
| }
|
| ++it;
|
| }
|
| - LOG(DFATAL) << "Unable to find sent time. "
|
| - << "This method is only intended when there are pending packets.";
|
| + LOG(DFATAL) << "GetLastPacketSentTime requires in flight packets.";
|
| return QuicTime::Zero();
|
| }
|
|
|
| -QuicTime QuicUnackedPacketMap::GetFirstPendingPacketSentTime() const {
|
| +QuicTime QuicUnackedPacketMap::GetFirstInFlightPacketSentTime() const {
|
| UnackedPacketMap::const_iterator it = unacked_packets_.begin();
|
| - while (it != unacked_packets_.end() && !it->second.pending) {
|
| + while (it != unacked_packets_.end() && !it->second.in_flight) {
|
| ++it;
|
| }
|
| if (it == unacked_packets_.end()) {
|
| - LOG(DFATAL) << "No pending packets";
|
| + LOG(DFATAL) << "GetFirstInFlightPacketSentTime requires in flight packets.";
|
| return QuicTime::Zero();
|
| }
|
| return it->second.sent_time;
|
| @@ -253,14 +258,14 @@ size_t QuicUnackedPacketMap::GetNumUnackedPackets() const {
|
| return unacked_packets_.size();
|
| }
|
|
|
| -bool QuicUnackedPacketMap::HasMultiplePendingPackets() const {
|
| - size_t num_pending = 0;
|
| +bool QuicUnackedPacketMap::HasMultipleInFlightPackets() const {
|
| + size_t num_in_flight = 0;
|
| for (UnackedPacketMap::const_reverse_iterator it = unacked_packets_.rbegin();
|
| it != unacked_packets_.rend(); ++it) {
|
| - if (it->second.pending) {
|
| - ++num_pending;
|
| + if (it->second.in_flight) {
|
| + ++num_in_flight;
|
| }
|
| - if (num_pending > 1) {
|
| + if (num_in_flight > 1) {
|
| return true;
|
| }
|
| }
|
| @@ -274,7 +279,7 @@ bool QuicUnackedPacketMap::HasPendingCryptoPackets() const {
|
| bool QuicUnackedPacketMap::HasUnackedRetransmittableFrames() const {
|
| for (UnackedPacketMap::const_reverse_iterator it =
|
| unacked_packets_.rbegin(); it != unacked_packets_.rend(); ++it) {
|
| - if (it->second.pending && it->second.retransmittable_frames) {
|
| + if (it->second.in_flight && it->second.retransmittable_frames) {
|
| return true;
|
| }
|
| }
|
| @@ -294,7 +299,7 @@ QuicUnackedPacketMap::GetLeastUnackedSentPacket() const {
|
| void QuicUnackedPacketMap::SetSent(QuicPacketSequenceNumber sequence_number,
|
| QuicTime sent_time,
|
| QuicByteCount bytes_sent,
|
| - bool set_pending) {
|
| + bool set_in_flight) {
|
| DCHECK_LT(0u, sequence_number);
|
| UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number);
|
| if (it == unacked_packets_.end()) {
|
| @@ -302,14 +307,14 @@ void QuicUnackedPacketMap::SetSent(QuicPacketSequenceNumber sequence_number,
|
| << sequence_number;
|
| return;
|
| }
|
| - DCHECK(!it->second.pending);
|
| + DCHECK(!it->second.in_flight);
|
|
|
| largest_sent_packet_ = max(sequence_number, largest_sent_packet_);
|
| it->second.sent_time = sent_time;
|
| - if (set_pending) {
|
| + if (set_in_flight) {
|
| bytes_in_flight_ += bytes_sent;
|
| it->second.bytes_sent = bytes_sent;
|
| - it->second.pending = true;
|
| + it->second.in_flight = true;
|
| }
|
| }
|
|
|
|
|