| 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" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "net/base/linked_hash_map.h" | 12 #include "net/base/linked_hash_map.h" |
| 13 #include "net/quic/crypto/crypto_protocol.h" | 13 #include "net/quic/crypto/crypto_protocol.h" |
| 14 #include "net/quic/quic_connection_stats.h" | 14 #include "net/quic/quic_connection_stats.h" |
| 15 | 15 |
| 16 using std::make_pair; | |
| 17 using std::max; | 16 using std::max; |
| 18 using std::min; | 17 using std::min; |
| 19 using std::numeric_limits; | 18 using std::numeric_limits; |
| 20 | 19 |
| 21 namespace net { | 20 namespace net { |
| 22 | 21 |
| 23 namespace { | 22 namespace { |
| 24 | 23 |
| 25 // The maximum number of packets to ack immediately after a missing packet for | 24 // The maximum number of packets to ack immediately after a missing packet for |
| 26 // fast retransmission to kick in at the sender. This limit is created to | 25 // fast retransmission to kick in at the sender. This limit is created to |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 73 |
| 75 // Optimize the typical case of no gaps. | 74 // Optimize the typical case of no gaps. |
| 76 if (sequence_number == largest_observed_ + 1 && packets_entropy_.empty()) { | 75 if (sequence_number == largest_observed_ + 1 && packets_entropy_.empty()) { |
| 77 ++first_gap_; | 76 ++first_gap_; |
| 78 largest_observed_ = sequence_number; | 77 largest_observed_ = sequence_number; |
| 79 return; | 78 return; |
| 80 } | 79 } |
| 81 if (sequence_number > largest_observed_) { | 80 if (sequence_number > largest_observed_) { |
| 82 for (QuicPacketSequenceNumber i = 0; | 81 for (QuicPacketSequenceNumber i = 0; |
| 83 i < (sequence_number - largest_observed_ - 1); ++i) { | 82 i < (sequence_number - largest_observed_ - 1); ++i) { |
| 84 packets_entropy_.push_back(make_pair(0, false)); | 83 packets_entropy_.push_back(std::make_pair(0, false)); |
| 85 } | 84 } |
| 86 packets_entropy_.push_back(make_pair(entropy_hash, true)); | 85 packets_entropy_.push_back(std::make_pair(entropy_hash, true)); |
| 87 largest_observed_ = sequence_number; | 86 largest_observed_ = sequence_number; |
| 88 } else { | 87 } else { |
| 89 packets_entropy_[sequence_number - first_gap_] = | 88 packets_entropy_[sequence_number - first_gap_] = |
| 90 make_pair(entropy_hash, true); | 89 std::make_pair(entropy_hash, true); |
| 91 AdvanceFirstGapAndGarbageCollectEntropyMap(); | 90 AdvanceFirstGapAndGarbageCollectEntropyMap(); |
| 92 } | 91 } |
| 93 | 92 |
| 94 DVLOG(2) << "setting cumulative received entropy hash to: " | 93 DVLOG(2) << "setting cumulative received entropy hash to: " |
| 95 << static_cast<int>(packets_entropy_hash_) | 94 << static_cast<int>(packets_entropy_hash_) |
| 96 << " updated with sequence number " << sequence_number | 95 << " updated with sequence number " << sequence_number |
| 97 << " entropy hash: " << static_cast<int>(entropy_hash); | 96 << " entropy hash: " << static_cast<int>(entropy_hash); |
| 98 } | 97 } |
| 99 | 98 |
| 100 void QuicReceivedPacketManager::EntropyTracker::SetCumulativeEntropyUpTo( | 99 void QuicReceivedPacketManager::EntropyTracker::SetCumulativeEntropyUpTo( |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 return !ack_frame_.missing_packets.empty() && | 277 return !ack_frame_.missing_packets.empty() && |
| 279 (ack_frame_.largest_observed - | 278 (ack_frame_.largest_observed - |
| 280 *ack_frame_.missing_packets.rbegin()) <= kMaxPacketsAfterNewMissing; | 279 *ack_frame_.missing_packets.rbegin()) <= kMaxPacketsAfterNewMissing; |
| 281 } | 280 } |
| 282 | 281 |
| 283 size_t QuicReceivedPacketManager::NumTrackedPackets() const { | 282 size_t QuicReceivedPacketManager::NumTrackedPackets() const { |
| 284 return entropy_tracker_.size(); | 283 return entropy_tracker_.size(); |
| 285 } | 284 } |
| 286 | 285 |
| 287 } // namespace net | 286 } // namespace net |
| OLD | NEW |