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

Side by Side Diff: net/base/backoff_entry_unittest.cc

Issue 337803004: Backoff: Respect maximum delay in face of float overflow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« net/base/backoff_entry.cc ('K') | « net/base/backoff_entry.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/base/backoff_entry.h" 5 #include "net/base/backoff_entry.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 namespace { 8 namespace {
9 9
10 using base::TimeDelta; 10 using base::TimeDelta;
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 // Regression test for a bug discovered during code review. 286 // Regression test for a bug discovered during code review.
287 BackoffEntry::Policy lenient_policy = base_policy; 287 BackoffEntry::Policy lenient_policy = base_policy;
288 lenient_policy.num_errors_to_ignore = 1; 288 lenient_policy.num_errors_to_ignore = 1;
289 TestBackoffEntry custom(&lenient_policy); 289 TestBackoffEntry custom(&lenient_policy);
290 TimeTicks custom_horizon = TimeTicks() + TimeDelta::FromDays(3); 290 TimeTicks custom_horizon = TimeTicks() + TimeDelta::FromDays(3);
291 custom.SetCustomReleaseTime(custom_horizon); 291 custom.SetCustomReleaseTime(custom_horizon);
292 custom.InformOfRequest(false); // This must not reset the horizon. 292 custom.InformOfRequest(false); // This must not reset the horizon.
293 EXPECT_EQ(custom_horizon, custom.GetReleaseTime()); 293 EXPECT_EQ(custom_horizon, custom.GetReleaseTime());
294 } 294 }
295 295
296 TEST(BackoffEntryTest, OverflowProtection) {
297 TestBackoffEntry custom(&base_policy);
298
299 // Trigger enough failures such that more than 11 bits of exponent are used
300 // to represent the exponential backoff intermediate values.
cbentzel 2014/06/14 15:16:07 Could you use a different policy for this test wit
Nicolas Zea 2014/06/16 20:27:25 Done.
301 for (size_t i = 0; i < (1 << 11); ++i) {
302 custom.set_now(custom.ImplGetTimeNow() + custom.GetTimeUntilRelease());
303 custom.InformOfRequest(false);
304 EXPECT_TRUE(custom.ShouldRejectRequest());
305 }
306
307 // Max delay should still be respected.
308 EXPECT_EQ(20000, custom.GetTimeUntilRelease().InMilliseconds());
309 }
310
296 } // namespace 311 } // namespace
OLDNEW
« net/base/backoff_entry.cc ('K') | « net/base/backoff_entry.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698