Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: net/quic/quic_sent_entropy_manager.cc

Issue 1330973002: relnote: Refactor QuicAckFrame::missing_packets to support a change to a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Tidy_up_DLOG_messages_101773586
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 QuicPacketNumber packet_number) { 57 QuicPacketNumber packet_number) {
58 DCHECK_LE(last_cumulative_entropy_.packet_number, packet_number); 58 DCHECK_LE(last_cumulative_entropy_.packet_number, packet_number);
59 DCHECK_GE(GetLargestPacketWithEntropy(), packet_number); 59 DCHECK_GE(GetLargestPacketWithEntropy(), packet_number);
60 // First the entropy for largest_observed packet number should be updated. 60 // First the entropy for largest_observed packet number should be updated.
61 UpdateCumulativeEntropy(packet_number, &last_cumulative_entropy_); 61 UpdateCumulativeEntropy(packet_number, &last_cumulative_entropy_);
62 return last_cumulative_entropy_.entropy; 62 return last_cumulative_entropy_.entropy;
63 } 63 }
64 64
65 bool QuicSentEntropyManager::IsValidEntropy( 65 bool QuicSentEntropyManager::IsValidEntropy(
66 QuicPacketNumber largest_observed, 66 QuicPacketNumber largest_observed,
67 const PacketNumberSet& missing_packets, 67 const PacketNumberQueue& missing_packets,
68 QuicPacketEntropyHash entropy_hash) { 68 QuicPacketEntropyHash entropy_hash) {
69 DCHECK_GE(largest_observed, last_valid_entropy_.packet_number); 69 DCHECK_GE(largest_observed, last_valid_entropy_.packet_number);
70 // Ensure the largest and smallest packet numbers are in range. 70 // Ensure the largest and smallest packet numbers are in range.
71 if (largest_observed > GetLargestPacketWithEntropy()) { 71 if (largest_observed > GetLargestPacketWithEntropy()) {
72 return false; 72 return false;
73 } 73 }
74 if (!missing_packets.empty() && 74 if (!missing_packets.Empty() &&
75 *missing_packets.begin() < GetSmallestPacketWithEntropy()) { 75 missing_packets.Min() < GetSmallestPacketWithEntropy()) {
76 return false; 76 return false;
77 } 77 }
78 // First the entropy for largest_observed packet number should be updated. 78 // First the entropy for largest_observed packet number should be updated.
79 UpdateCumulativeEntropy(largest_observed, &last_valid_entropy_); 79 UpdateCumulativeEntropy(largest_observed, &last_valid_entropy_);
80 80
81 // Now XOR out all the missing entropies. 81 // Now XOR out all the missing entropies.
82 QuicPacketEntropyHash expected_entropy_hash = last_valid_entropy_.entropy; 82 QuicPacketEntropyHash expected_entropy_hash = last_valid_entropy_.entropy;
83 for (PacketNumberSet::const_iterator it = missing_packets.begin(); 83 for (QuicPacketNumber packet : missing_packets) {
84 it != missing_packets.end(); ++it) { 84 expected_entropy_hash ^= GetPacketEntropy(packet);
85 expected_entropy_hash ^= GetPacketEntropy(*it);
86 } 85 }
87 DLOG_IF(WARNING, entropy_hash != expected_entropy_hash) 86 DLOG_IF(WARNING, entropy_hash != expected_entropy_hash)
88 << "Invalid entropy hash: " << static_cast<int>(entropy_hash) 87 << "Invalid entropy hash: " << static_cast<int>(entropy_hash)
89 << " expected entropy hash: " << static_cast<int>(expected_entropy_hash); 88 << " expected entropy hash: " << static_cast<int>(expected_entropy_hash);
90 return entropy_hash == expected_entropy_hash; 89 return entropy_hash == expected_entropy_hash;
91 } 90 }
92 91
93 void QuicSentEntropyManager::ClearEntropyBefore( 92 void QuicSentEntropyManager::ClearEntropyBefore(
94 QuicPacketNumber packet_number) { 93 QuicPacketNumber packet_number) {
95 // Don't discard entropy before updating the cumulative entropy used to 94 // Don't discard entropy before updating the cumulative entropy used to
96 // calculate EntropyHash and IsValidEntropy. 95 // calculate EntropyHash and IsValidEntropy.
97 if (last_cumulative_entropy_.packet_number < packet_number) { 96 if (last_cumulative_entropy_.packet_number < packet_number) {
98 UpdateCumulativeEntropy(packet_number, &last_cumulative_entropy_); 97 UpdateCumulativeEntropy(packet_number, &last_cumulative_entropy_);
99 } 98 }
100 if (last_valid_entropy_.packet_number < packet_number) { 99 if (last_valid_entropy_.packet_number < packet_number) {
101 UpdateCumulativeEntropy(packet_number, &last_valid_entropy_); 100 UpdateCumulativeEntropy(packet_number, &last_valid_entropy_);
102 } 101 }
103 while (map_offset_ < packet_number) { 102 while (map_offset_ < packet_number) {
104 packets_entropy_.pop_front(); 103 packets_entropy_.pop_front();
105 ++map_offset_; 104 ++map_offset_;
106 } 105 }
107 DVLOG(2) << "Cleared entropy before: " << packet_number; 106 DVLOG(2) << "Cleared entropy before: " << packet_number;
108 } 107 }
109 108
110 } // namespace net 109 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698