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_entropy_manager.h" | 5 #include "net/quic/quic_sent_entropy_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/base/linked_hash_map.h" | 8 #include "net/base/linked_hash_map.h" |
9 | 9 |
10 using std::make_pair; | 10 using std::make_pair; |
11 using std::max; | 11 using std::max; |
12 using std::min; | 12 using std::min; |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 | 15 |
16 QuicSentEntropyManager::QuicSentEntropyManager() | 16 QuicSentEntropyManager::QuicSentEntropyManager() |
17 : packets_entropy_hash_(0) {} | 17 : packets_entropy_hash_(0) {} |
18 | 18 |
19 QuicSentEntropyManager::~QuicSentEntropyManager() {} | 19 QuicSentEntropyManager::~QuicSentEntropyManager() {} |
20 | 20 |
21 void QuicSentEntropyManager::RecordPacketEntropyHash( | 21 void QuicSentEntropyManager::RecordPacketEntropyHash( |
22 QuicPacketSequenceNumber sequence_number, | 22 QuicPacketSequenceNumber sequence_number, |
23 QuicPacketEntropyHash entropy_hash) { | 23 QuicPacketEntropyHash entropy_hash) { |
24 // TODO(satyamshekhar): Check this logic again when/if we enable packet | 24 if (!packets_entropy_.empty()) { |
25 // reordering. | 25 // Ensure packets always are recorded in order. |
| 26 // Every packet's entropy is recorded, even if it's not sent, so there |
| 27 // are not sequence number gaps. |
| 28 DCHECK_LT(packets_entropy_.back().first, sequence_number); |
| 29 } |
26 packets_entropy_hash_ ^= entropy_hash; | 30 packets_entropy_hash_ ^= entropy_hash; |
27 packets_entropy_.insert( | 31 packets_entropy_.insert( |
28 make_pair(sequence_number, | 32 make_pair(sequence_number, |
29 make_pair(entropy_hash, packets_entropy_hash_))); | 33 make_pair(entropy_hash, packets_entropy_hash_))); |
30 DVLOG(2) << "setting cumulative sent entropy hash to: " | 34 DVLOG(2) << "setting cumulative sent entropy hash to: " |
31 << static_cast<int>(packets_entropy_hash_) | 35 << static_cast<int>(packets_entropy_hash_) |
32 << " updated with sequence number " << sequence_number | 36 << " updated with sequence number " << sequence_number |
33 << " entropy hash: " << static_cast<int>(entropy_hash); | 37 << " entropy hash: " << static_cast<int>(entropy_hash); |
34 } | 38 } |
35 | 39 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 while (it->first < sequence_number) { | 82 while (it->first < sequence_number) { |
79 packets_entropy_.erase(it); | 83 packets_entropy_.erase(it); |
80 it = packets_entropy_.begin(); | 84 it = packets_entropy_.begin(); |
81 DCHECK(it != packets_entropy_.end()); | 85 DCHECK(it != packets_entropy_.end()); |
82 } | 86 } |
83 DVLOG(2) << "Cleared entropy before: " | 87 DVLOG(2) << "Cleared entropy before: " |
84 << packets_entropy_.begin()->first; | 88 << packets_entropy_.begin()->first; |
85 } | 89 } |
86 | 90 |
87 } // namespace net | 91 } // namespace net |
OLD | NEW |