OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_unacked_packet_map.h" | 5 #include "net/quic/quic_unacked_packet_map.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "net/quic/quic_connection_stats.h" | 9 #include "net/quic/quic_connection_stats.h" |
10 #include "net/quic/quic_utils_chromium.h" | 10 #include "net/quic/quic_utils_chromium.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 198 |
199 bool QuicUnackedPacketMap::IsPending( | 199 bool QuicUnackedPacketMap::IsPending( |
200 QuicPacketSequenceNumber sequence_number) const { | 200 QuicPacketSequenceNumber sequence_number) const { |
201 const TransmissionInfo* transmission_info = | 201 const TransmissionInfo* transmission_info = |
202 FindOrNull(unacked_packets_, sequence_number); | 202 FindOrNull(unacked_packets_, sequence_number); |
203 return transmission_info != NULL && transmission_info->pending; | 203 return transmission_info != NULL && transmission_info->pending; |
204 } | 204 } |
205 | 205 |
206 void QuicUnackedPacketMap::SetNotPending( | 206 void QuicUnackedPacketMap::SetNotPending( |
207 QuicPacketSequenceNumber sequence_number) { | 207 QuicPacketSequenceNumber sequence_number) { |
208 if (unacked_packets_[sequence_number].pending) { | 208 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number); |
209 LOG_IF(DFATAL, | 209 if (it == unacked_packets_.end()) { |
210 bytes_in_flight_ < unacked_packets_[sequence_number].bytes_sent); | 210 LOG(DFATAL) << "SetNotPending called for packet that is not unacked: " |
211 bytes_in_flight_ -= unacked_packets_[sequence_number].bytes_sent; | 211 << sequence_number; |
212 unacked_packets_[sequence_number].pending = false; | 212 return; |
| 213 } |
| 214 if (it->second.pending) { |
| 215 LOG_IF(DFATAL, bytes_in_flight_ < it->second.bytes_sent); |
| 216 bytes_in_flight_ -= it->second.bytes_sent; |
| 217 it->second.pending = false; |
213 } | 218 } |
214 } | 219 } |
215 | 220 |
216 bool QuicUnackedPacketMap::HasUnackedPackets() const { | 221 bool QuicUnackedPacketMap::HasUnackedPackets() const { |
217 return !unacked_packets_.empty(); | 222 return !unacked_packets_.empty(); |
218 } | 223 } |
219 | 224 |
220 bool QuicUnackedPacketMap::HasPendingPackets() const { | 225 bool QuicUnackedPacketMap::HasPendingPackets() const { |
221 for (UnackedPacketMap::const_reverse_iterator it = | 226 for (UnackedPacketMap::const_reverse_iterator it = |
222 unacked_packets_.rbegin(); it != unacked_packets_.rend(); ++it) { | 227 unacked_packets_.rbegin(); it != unacked_packets_.rend(); ++it) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 DCHECK(!it->second.pending); | 335 DCHECK(!it->second.pending); |
331 | 336 |
332 largest_sent_packet_ = max(sequence_number, largest_sent_packet_); | 337 largest_sent_packet_ = max(sequence_number, largest_sent_packet_); |
333 bytes_in_flight_ += bytes_sent; | 338 bytes_in_flight_ += bytes_sent; |
334 it->second.sent_time = sent_time; | 339 it->second.sent_time = sent_time; |
335 it->second.bytes_sent = bytes_sent; | 340 it->second.bytes_sent = bytes_sent; |
336 it->second.pending = true; | 341 it->second.pending = true; |
337 } | 342 } |
338 | 343 |
339 } // namespace net | 344 } // namespace net |
OLD | NEW |