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_received_packet_manager.h" | 5 #include "net/quic/quic_received_packet_manager.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 } | 172 } |
173 if (packet_number > ack_frame_.largest_observed) { | 173 if (packet_number > ack_frame_.largest_observed) { |
174 ack_frame_.largest_observed = packet_number; | 174 ack_frame_.largest_observed = packet_number; |
175 time_largest_observed_ = receipt_time; | 175 time_largest_observed_ = receipt_time; |
176 } | 176 } |
177 entropy_tracker_.RecordPacketEntropyHash(packet_number, header.entropy_hash); | 177 entropy_tracker_.RecordPacketEntropyHash(packet_number, header.entropy_hash); |
178 | 178 |
179 ack_frame_.received_packet_times.push_back( | 179 ack_frame_.received_packet_times.push_back( |
180 std::make_pair(packet_number, receipt_time)); | 180 std::make_pair(packet_number, receipt_time)); |
181 | 181 |
182 ack_frame_.revived_packets.erase(packet_number); | 182 if (ack_frame_.latest_revived_packet == packet_number) { |
| 183 ack_frame_.latest_revived_packet = 0; |
| 184 } |
183 } | 185 } |
184 | 186 |
185 void QuicReceivedPacketManager::RecordPacketRevived( | 187 void QuicReceivedPacketManager::RecordPacketRevived( |
186 QuicPacketNumber packet_number) { | 188 QuicPacketNumber packet_number) { |
187 LOG_IF(DFATAL, !IsAwaitingPacket(packet_number)); | 189 LOG_IF(DFATAL, !IsAwaitingPacket(packet_number)); |
188 ack_frame_.revived_packets.insert(packet_number); | 190 ack_frame_.latest_revived_packet = packet_number; |
189 } | 191 } |
190 | 192 |
191 bool QuicReceivedPacketManager::IsMissing(QuicPacketNumber packet_number) { | 193 bool QuicReceivedPacketManager::IsMissing(QuicPacketNumber packet_number) { |
192 return ack_frame_.missing_packets.Contains(packet_number); | 194 return ack_frame_.missing_packets.Contains(packet_number); |
193 } | 195 } |
194 | 196 |
195 bool QuicReceivedPacketManager::IsAwaitingPacket( | 197 bool QuicReceivedPacketManager::IsAwaitingPacket( |
196 QuicPacketNumber packet_number) { | 198 QuicPacketNumber packet_number) { |
197 return ::net::IsAwaitingPacket(ack_frame_, packet_number); | 199 return ::net::IsAwaitingPacket(ack_frame_, packet_number); |
198 } | 200 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 ack_frame->received_packet_times.swap(ack_frame_.received_packet_times); | 248 ack_frame->received_packet_times.swap(ack_frame_.received_packet_times); |
247 } | 249 } |
248 | 250 |
249 QuicPacketEntropyHash QuicReceivedPacketManager::EntropyHash( | 251 QuicPacketEntropyHash QuicReceivedPacketManager::EntropyHash( |
250 QuicPacketNumber packet_number) const { | 252 QuicPacketNumber packet_number) const { |
251 return entropy_tracker_.EntropyHash(packet_number); | 253 return entropy_tracker_.EntropyHash(packet_number); |
252 } | 254 } |
253 | 255 |
254 bool QuicReceivedPacketManager::DontWaitForPacketsBefore( | 256 bool QuicReceivedPacketManager::DontWaitForPacketsBefore( |
255 QuicPacketNumber least_unacked) { | 257 QuicPacketNumber least_unacked) { |
256 ack_frame_.revived_packets.erase( | 258 if (ack_frame_.latest_revived_packet < least_unacked) { |
257 ack_frame_.revived_packets.begin(), | 259 ack_frame_.latest_revived_packet = 0; |
258 ack_frame_.revived_packets.lower_bound(least_unacked)); | 260 } |
259 return ack_frame_.missing_packets.RemoveUpTo(least_unacked); | 261 return ack_frame_.missing_packets.RemoveUpTo(least_unacked); |
260 } | 262 } |
261 | 263 |
262 void QuicReceivedPacketManager::UpdatePacketInformationSentByPeer( | 264 void QuicReceivedPacketManager::UpdatePacketInformationSentByPeer( |
263 const QuicStopWaitingFrame& stop_waiting) { | 265 const QuicStopWaitingFrame& stop_waiting) { |
264 // ValidateAck() should fail if peer_least_packet_awaiting_ack_ shrinks. | 266 // ValidateAck() should fail if peer_least_packet_awaiting_ack_ shrinks. |
265 DCHECK_LE(peer_least_packet_awaiting_ack_, stop_waiting.least_unacked); | 267 DCHECK_LE(peer_least_packet_awaiting_ack_, stop_waiting.least_unacked); |
266 if (stop_waiting.least_unacked > peer_least_packet_awaiting_ack_) { | 268 if (stop_waiting.least_unacked > peer_least_packet_awaiting_ack_) { |
267 bool missed_packets = DontWaitForPacketsBefore(stop_waiting.least_unacked); | 269 bool missed_packets = DontWaitForPacketsBefore(stop_waiting.least_unacked); |
268 if (missed_packets) { | 270 if (missed_packets) { |
(...skipping 13 matching lines...) Expand all Loading... |
282 return !ack_frame_.missing_packets.Empty() && | 284 return !ack_frame_.missing_packets.Empty() && |
283 (ack_frame_.largest_observed - ack_frame_.missing_packets.Max()) <= | 285 (ack_frame_.largest_observed - ack_frame_.missing_packets.Max()) <= |
284 kMaxPacketsAfterNewMissing; | 286 kMaxPacketsAfterNewMissing; |
285 } | 287 } |
286 | 288 |
287 size_t QuicReceivedPacketManager::NumTrackedPackets() const { | 289 size_t QuicReceivedPacketManager::NumTrackedPackets() const { |
288 return entropy_tracker_.size(); | 290 return entropy_tracker_.size(); |
289 } | 291 } |
290 | 292 |
291 } // namespace net | 293 } // namespace net |
OLD | NEW |