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

Side by Side Diff: net/quic/crypto/strike_register.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « net/quic/crypto/quic_server_info.h ('k') | net/quic/crypto/strike_register_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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/crypto/strike_register.h" 5 #include "net/quic/crypto/strike_register.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 using std::make_pair;
12 using std::max; 11 using std::max;
13 using std::min; 12 using std::min;
14 using std::pair; 13 using std::pair;
15 using std::set; 14 using std::set;
16 using std::vector; 15 using std::vector;
17 16
18 namespace net { 17 namespace net {
19 18
20 namespace { 19 namespace {
21 20
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 return static_cast<uint32>(d[0]) << 24 | 316 return static_cast<uint32>(d[0]) << 24 |
318 static_cast<uint32>(d[1]) << 16 | 317 static_cast<uint32>(d[1]) << 16 |
319 static_cast<uint32>(d[2]) << 8 | 318 static_cast<uint32>(d[2]) << 8 |
320 static_cast<uint32>(d[3]); 319 static_cast<uint32>(d[3]);
321 } 320 }
322 321
323 pair<uint32, uint32> StrikeRegister::GetValidRange( 322 pair<uint32, uint32> StrikeRegister::GetValidRange(
324 uint32 current_time_internal) const { 323 uint32 current_time_internal) const {
325 if (current_time_internal < horizon_) { 324 if (current_time_internal < horizon_) {
326 // Empty valid range. 325 // Empty valid range.
327 return make_pair(std::numeric_limits<uint32>::max(), 0); 326 return std::make_pair(std::numeric_limits<uint32>::max(), 0);
328 } 327 }
329 328
330 uint32 lower_bound; 329 uint32 lower_bound;
331 if (current_time_internal >= window_secs_) { 330 if (current_time_internal >= window_secs_) {
332 lower_bound = max(horizon_, current_time_internal - window_secs_); 331 lower_bound = max(horizon_, current_time_internal - window_secs_);
333 } else { 332 } else {
334 lower_bound = horizon_; 333 lower_bound = horizon_;
335 } 334 }
336 335
337 // Also limit the upper range based on horizon_. This makes the 336 // Also limit the upper range based on horizon_. This makes the
338 // strike register reject inserts that are far in the future and 337 // strike register reject inserts that are far in the future and
339 // would consume strike register resources for a long time. This 338 // would consume strike register resources for a long time. This
340 // allows the strike server to degrade optimally in cases where the 339 // allows the strike server to degrade optimally in cases where the
341 // insert rate exceeds |max_entries_ / (2 * window_secs_)| entries 340 // insert rate exceeds |max_entries_ / (2 * window_secs_)| entries
342 // per second. 341 // per second.
343 uint32 upper_bound = 342 uint32 upper_bound =
344 current_time_internal + min(current_time_internal - horizon_, 343 current_time_internal + min(current_time_internal - horizon_,
345 window_secs_); 344 window_secs_);
346 345
347 return make_pair(lower_bound, upper_bound); 346 return std::make_pair(lower_bound, upper_bound);
348 } 347 }
349 348
350 uint32 StrikeRegister::ExternalTimeToInternal(uint32 external_time) const { 349 uint32 StrikeRegister::ExternalTimeToInternal(uint32 external_time) const {
351 return external_time - internal_epoch_; 350 return external_time - internal_epoch_;
352 } 351 }
353 352
354 uint32 StrikeRegister::BestMatch(const uint8 v[24]) const { 353 uint32 StrikeRegister::BestMatch(const uint8 v[24]) const {
355 if (internal_node_head_ == kNil) { 354 if (internal_node_head_ == kNil) {
356 return kNil; 355 return kNil;
357 } 356 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 CHECK_EQ(free_internal_nodes.count(inter), 0u); 511 CHECK_EQ(free_internal_nodes.count(inter), 0u);
513 CHECK_EQ(used_internal_nodes->count(inter), 0u); 512 CHECK_EQ(used_internal_nodes->count(inter), 0u);
514 used_internal_nodes->insert(inter); 513 used_internal_nodes->insert(inter);
515 ValidateTree(inter, bit, bits, free_internal_nodes, free_external_nodes, 514 ValidateTree(inter, bit, bits, free_internal_nodes, free_external_nodes,
516 used_internal_nodes, used_external_nodes); 515 used_internal_nodes, used_external_nodes);
517 } 516 }
518 } 517 }
519 } 518 }
520 519
521 } // namespace net 520 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/quic_server_info.h ('k') | net/quic/crypto/strike_register_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698