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

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

Issue 1158923005: Use the exact-width integer types defined in <stdint.h> rather than (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweak comments. Exclude mime_sniffer*. Rebase. Created 5 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
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 "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/time/tick_clock.h" 8 #include "base/time/tick_clock.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "net/base/backoff_entry.h" 10 #include "net/base/backoff_entry.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 int failure_count; 54 int failure_count;
55 if (!serialized_list->GetInteger(1, &failure_count) || failure_count < 0) 55 if (!serialized_list->GetInteger(1, &failure_count) || failure_count < 0)
56 return nullptr; 56 return nullptr;
57 double original_backoff_duration_double; 57 double original_backoff_duration_double;
58 if (!serialized_list->GetDouble(2, &original_backoff_duration_double)) 58 if (!serialized_list->GetDouble(2, &original_backoff_duration_double))
59 return nullptr; 59 return nullptr;
60 std::string absolute_release_time_string; 60 std::string absolute_release_time_string;
61 if (!serialized_list->GetString(3, &absolute_release_time_string)) 61 if (!serialized_list->GetString(3, &absolute_release_time_string))
62 return nullptr; 62 return nullptr;
63 int64 absolute_release_time_us; 63 int64_t absolute_release_time_us;
64 if (!base::StringToInt64(absolute_release_time_string, 64 if (!base::StringToInt64(absolute_release_time_string,
65 &absolute_release_time_us) || 65 &absolute_release_time_us) ||
66 absolute_release_time_us < 0) { 66 absolute_release_time_us < 0) {
67 return nullptr; 67 return nullptr;
68 } 68 }
69 69
70 scoped_ptr<BackoffEntry> entry(new BackoffEntry(policy, tick_clock)); 70 scoped_ptr<BackoffEntry> entry(new BackoffEntry(policy, tick_clock));
71 71
72 for (int n = 0; n < failure_count; n++) 72 for (int n = 0; n < failure_count; n++)
73 entry->InformOfRequest(false); 73 entry->InformOfRequest(false);
74 74
75 base::TimeDelta original_backoff_duration = 75 base::TimeDelta original_backoff_duration =
76 base::TimeDelta::FromSecondsD(original_backoff_duration_double); 76 base::TimeDelta::FromSecondsD(original_backoff_duration_double);
77 base::Time absolute_release_time = 77 base::Time absolute_release_time =
78 base::Time::FromInternalValue(absolute_release_time_us); 78 base::Time::FromInternalValue(absolute_release_time_us);
79 base::TimeDelta backoff_duration = absolute_release_time - time_now; 79 base::TimeDelta backoff_duration = absolute_release_time - time_now;
80 // In cases where the system wall clock is rewound, use the redundant 80 // In cases where the system wall clock is rewound, use the redundant
81 // original_backoff_duration to ensure the backoff duration isn't longer 81 // original_backoff_duration to ensure the backoff duration isn't longer
82 // than it was before serializing (note that it's not possible to protect 82 // than it was before serializing (note that it's not possible to protect
83 // against the clock being wound forward). 83 // against the clock being wound forward).
84 if (backoff_duration > original_backoff_duration) 84 if (backoff_duration > original_backoff_duration)
85 backoff_duration = original_backoff_duration; 85 backoff_duration = original_backoff_duration;
86 entry->SetCustomReleaseTime( 86 entry->SetCustomReleaseTime(
87 entry->BackoffDurationToReleaseTime(backoff_duration)); 87 entry->BackoffDurationToReleaseTime(backoff_duration));
88 88
89 return entry; 89 return entry;
90 } 90 }
91 91
92 } // namespace net 92 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698