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

Side by Side Diff: net/quic/core/quic_received_packet_manager.cc

Issue 2464683002: adds std:: to stl types (#049) (Closed)
Patch Set: remove dead using std::foo declarations. Created 4 years, 1 month 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
« no previous file with comments | « net/quic/core/quic_protocol.h ('k') | net/quic/core/quic_received_packet_manager_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/core/quic_received_packet_manager.h" 5 #include "net/quic/core/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 "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "net/base/linked_hash_map.h" 13 #include "net/base/linked_hash_map.h"
14 #include "net/quic/core/crypto/crypto_protocol.h" 14 #include "net/quic/core/crypto/crypto_protocol.h"
15 #include "net/quic/core/quic_bug_tracker.h" 15 #include "net/quic/core/quic_bug_tracker.h"
16 #include "net/quic/core/quic_connection_stats.h" 16 #include "net/quic/core/quic_connection_stats.h"
17 #include "net/quic/core/quic_flags.h" 17 #include "net/quic/core/quic_flags.h"
18 18
19 using std::max; 19 using std::max;
20 using std::min; 20 using std::min;
21 using std::numeric_limits;
22 21
23 namespace net { 22 namespace net {
24 23
25 namespace { 24 namespace {
26 25
27 // The maximum number of packets to ack immediately after a missing packet for 26 // The maximum number of packets to ack immediately after a missing packet for
28 // fast retransmission to kick in at the sender. This limit is created to 27 // fast retransmission to kick in at the sender. This limit is created to
29 // reduce the number of acks sent that have no benefit for fast retransmission. 28 // reduce the number of acks sent that have no benefit for fast retransmission.
30 // Set to the number of nacks needed for fast retransmit plus one for protection 29 // Set to the number of nacks needed for fast retransmit plus one for protection
31 // against an ack loss 30 // against an ack loss
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 205 }
207 206
208 namespace { 207 namespace {
209 struct isTooLarge { 208 struct isTooLarge {
210 explicit isTooLarge(QuicPacketNumber n) : largest_observed_(n) {} 209 explicit isTooLarge(QuicPacketNumber n) : largest_observed_(n) {}
211 QuicPacketNumber largest_observed_; 210 QuicPacketNumber largest_observed_;
212 211
213 // Return true if the packet in p is too different from largest_observed_ 212 // Return true if the packet in p is too different from largest_observed_
214 // to express. 213 // to express.
215 bool operator()(const std::pair<QuicPacketNumber, QuicTime>& p) const { 214 bool operator()(const std::pair<QuicPacketNumber, QuicTime>& p) const {
216 return largest_observed_ - p.first >= numeric_limits<uint8_t>::max(); 215 return largest_observed_ - p.first >= std::numeric_limits<uint8_t>::max();
217 } 216 }
218 }; 217 };
219 } // namespace 218 } // namespace
220 219
221 const QuicFrame QuicReceivedPacketManager::GetUpdatedAckFrame( 220 const QuicFrame QuicReceivedPacketManager::GetUpdatedAckFrame(
222 QuicTime approximate_now) { 221 QuicTime approximate_now) {
223 ack_frame_updated_ = false; 222 ack_frame_updated_ = false;
224 if (ack_frame_.missing) { 223 if (ack_frame_.missing) {
225 ack_frame_.entropy_hash = EntropyHash(ack_frame_.largest_observed); 224 ack_frame_.entropy_hash = EntropyHash(ack_frame_.largest_observed);
226 } 225 }
227 226
228 if (time_largest_observed_ == QuicTime::Zero()) { 227 if (time_largest_observed_ == QuicTime::Zero()) {
229 // We have received no packets. 228 // We have received no packets.
230 ack_frame_.ack_delay_time = QuicTime::Delta::Infinite(); 229 ack_frame_.ack_delay_time = QuicTime::Delta::Infinite();
231 } else { 230 } else {
232 // Ensure the delta is zero if approximate now is "in the past". 231 // Ensure the delta is zero if approximate now is "in the past".
233 ack_frame_.ack_delay_time = approximate_now < time_largest_observed_ 232 ack_frame_.ack_delay_time = approximate_now < time_largest_observed_
234 ? QuicTime::Delta::Zero() 233 ? QuicTime::Delta::Zero()
235 : approximate_now - time_largest_observed_; 234 : approximate_now - time_largest_observed_;
236 } 235 }
237 236
238 // Clear all packet times if any are too far from largest observed. 237 // Clear all packet times if any are too far from largest observed.
239 // It's expected this is extremely rare. 238 // It's expected this is extremely rare.
240 for (PacketTimeVector::iterator it = ack_frame_.received_packet_times.begin(); 239 for (PacketTimeVector::iterator it = ack_frame_.received_packet_times.begin();
241 it != ack_frame_.received_packet_times.end();) { 240 it != ack_frame_.received_packet_times.end();) {
242 if (ack_frame_.largest_observed - it->first >= 241 if (ack_frame_.largest_observed - it->first >=
243 numeric_limits<uint8_t>::max()) { 242 std::numeric_limits<uint8_t>::max()) {
244 it = ack_frame_.received_packet_times.erase(it); 243 it = ack_frame_.received_packet_times.erase(it);
245 } else { 244 } else {
246 ++it; 245 ++it;
247 } 246 }
248 } 247 }
249 248
250 return QuicFrame(&ack_frame_); 249 return QuicFrame(&ack_frame_);
251 } 250 }
252 251
253 QuicPacketEntropyHash QuicReceivedPacketManager::EntropyHash( 252 QuicPacketEntropyHash QuicReceivedPacketManager::EntropyHash(
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 315
317 bool QuicReceivedPacketManager::ack_frame_updated() const { 316 bool QuicReceivedPacketManager::ack_frame_updated() const {
318 return ack_frame_updated_; 317 return ack_frame_updated_;
319 } 318 }
320 319
321 QuicPacketNumber QuicReceivedPacketManager::GetLargestObserved() const { 320 QuicPacketNumber QuicReceivedPacketManager::GetLargestObserved() const {
322 return ack_frame_.largest_observed; 321 return ack_frame_.largest_observed;
323 } 322 }
324 323
325 } // namespace net 324 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_protocol.h ('k') | net/quic/core/quic_received_packet_manager_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698