OLD | NEW |
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 "components/proximity_auth/cryptauth/sync_scheduler_impl.h" | 5 #include "components/cryptauth/sync_scheduler_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/numerics/safe_conversions.h" | 13 #include "base/numerics/safe_conversions.h" |
14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "components/proximity_auth/logging/logging.h" | 16 #include "components/proximity_auth/logging/logging.h" |
17 | 17 |
18 namespace proximity_auth { | 18 namespace cryptauth { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 // Returns a human readable string given a |time_delta|. | 22 // Returns a human readable string given a |time_delta|. |
23 std::string TimeDeltaToString(const base::TimeDelta& time_delta) { | 23 std::string TimeDeltaToString(const base::TimeDelta& time_delta) { |
24 if (time_delta.InDays() > 0) | 24 if (time_delta.InDays() > 0) |
25 return base::StringPrintf("%d days", time_delta.InDays()); | 25 return base::StringPrintf("%d days", time_delta.InDays()); |
26 | 26 |
27 if (time_delta.InHours() > 0) | 27 if (time_delta.InHours() > 0) |
28 return base::StringPrintf("%d hours", time_delta.InHours()); | 28 return base::StringPrintf("%d hours", time_delta.InHours()); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 double backoff_factor = pow(2, failure_count_ - 1); | 187 double backoff_factor = pow(2, failure_count_ - 1); |
188 base::TimeDelta backoff_period = base_recovery_period_ * backoff_factor; | 188 base::TimeDelta backoff_period = base_recovery_period_ * backoff_factor; |
189 return backoff_period < refresh_period_ ? backoff_period : refresh_period_; | 189 return backoff_period < refresh_period_ ? backoff_period : refresh_period_; |
190 } else { | 190 } else { |
191 PA_LOG(ERROR) << "Error getting period for strategy: " | 191 PA_LOG(ERROR) << "Error getting period for strategy: " |
192 << static_cast<int>(strategy_); | 192 << static_cast<int>(strategy_); |
193 return base::TimeDelta(); | 193 return base::TimeDelta(); |
194 } | 194 } |
195 } | 195 } |
196 | 196 |
197 } // namespace proximity_auth | 197 } // namespace cryptauth |
OLD | NEW |