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

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

Issue 2390653002: Allow backoff entry serialization if clock is null. (Closed)
Patch Set: Created 4 years, 2 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
« net/base/backoff_entry.h ('K') | « net/base/backoff_entry.h ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_serializer.h" 5 #include "net/base/backoff_entry_serializer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/time/tick_clock.h" 10 #include "base/time/tick_clock.h"
(...skipping 11 matching lines...) Expand all
22 std::unique_ptr<base::Value> BackoffEntrySerializer::SerializeToValue( 22 std::unique_ptr<base::Value> BackoffEntrySerializer::SerializeToValue(
23 const BackoffEntry& entry, 23 const BackoffEntry& entry,
24 base::Time time_now) { 24 base::Time time_now) {
25 std::unique_ptr<base::ListValue> serialized(new base::ListValue()); 25 std::unique_ptr<base::ListValue> serialized(new base::ListValue());
26 serialized->AppendInteger(kSerializationFormatVersion); 26 serialized->AppendInteger(kSerializationFormatVersion);
27 27
28 serialized->AppendInteger(entry.failure_count()); 28 serialized->AppendInteger(entry.failure_count());
29 29
30 // Can't use entry.GetTimeUntilRelease as it doesn't allow negative deltas. 30 // Can't use entry.GetTimeUntilRelease as it doesn't allow negative deltas.
31 base::TimeDelta backoff_duration = 31 base::TimeDelta backoff_duration =
32 entry.GetReleaseTime() - entry.tick_clock()->NowTicks(); 32 entry.GetReleaseTime() - entry.GetTimeTicksNow();
johnme 2016/10/03 12:18:22 I believe this is the only caller of tick_clock().
Olivier 2016/10/03 12:29:24 Done.
33 // Redundantly stores both the remaining time delta and the absolute time. 33 // Redundantly stores both the remaining time delta and the absolute time.
34 // The delta is used to work around some cases where wall clock time changes. 34 // The delta is used to work around some cases where wall clock time changes.
35 serialized->AppendDouble(backoff_duration.InSecondsF()); 35 serialized->AppendDouble(backoff_duration.InSecondsF());
36 base::Time absolute_release_time = backoff_duration + time_now; 36 base::Time absolute_release_time = backoff_duration + time_now;
37 serialized->AppendString( 37 serialized->AppendString(
38 base::Int64ToString(absolute_release_time.ToInternalValue())); 38 base::Int64ToString(absolute_release_time.ToInternalValue()));
39 39
40 return std::move(serialized); 40 return std::move(serialized);
41 } 41 }
42 42
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // against the clock being wound forward). 88 // against the clock being wound forward).
89 if (backoff_duration > original_backoff_duration) 89 if (backoff_duration > original_backoff_duration)
90 backoff_duration = original_backoff_duration; 90 backoff_duration = original_backoff_duration;
91 entry->SetCustomReleaseTime( 91 entry->SetCustomReleaseTime(
92 entry->BackoffDurationToReleaseTime(backoff_duration)); 92 entry->BackoffDurationToReleaseTime(backoff_duration));
93 93
94 return entry; 94 return entry;
95 } 95 }
96 96
97 } // namespace net 97 } // namespace net
OLDNEW
« net/base/backoff_entry.h ('K') | « net/base/backoff_entry.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698