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/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 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } else { | 110 } else { |
111 NOTREACHED(); | 111 NOTREACHED(); |
112 return; | 112 return; |
113 } | 113 } |
114 | 114 |
115 delegate_->OnSyncRequested( | 115 delegate_->OnSyncRequested( |
116 base::MakeUnique<SyncRequest>(weak_ptr_factory_.GetWeakPtr())); | 116 base::MakeUnique<SyncRequest>(weak_ptr_factory_.GetWeakPtr())); |
117 } | 117 } |
118 | 118 |
119 std::unique_ptr<base::Timer> SyncSchedulerImpl::CreateTimer() { | 119 std::unique_ptr<base::Timer> SyncSchedulerImpl::CreateTimer() { |
120 bool retain_user_task = false; | 120 return base::MakeUnique<base::OneShotTimer>(); |
121 bool is_repeating = false; | |
122 return base::MakeUnique<base::Timer>(retain_user_task, is_repeating); | |
123 } | 121 } |
124 | 122 |
125 void SyncSchedulerImpl::ScheduleNextSync(const base::TimeDelta& sync_delta) { | 123 void SyncSchedulerImpl::ScheduleNextSync(const base::TimeDelta& sync_delta) { |
126 if (sync_state_ != SyncState::WAITING_FOR_REFRESH) { | 124 if (sync_state_ != SyncState::WAITING_FOR_REFRESH) { |
127 PA_LOG(ERROR) << "Unexpected state when scheduling next sync: sync_state=" | 125 PA_LOG(ERROR) << "Unexpected state when scheduling next sync: sync_state=" |
128 << static_cast<int>(sync_state_); | 126 << static_cast<int>(sync_state_); |
129 return; | 127 return; |
130 } | 128 } |
131 | 129 |
132 bool is_aggressive_recovery = (strategy_ == Strategy::AGGRESSIVE_RECOVERY); | 130 bool is_aggressive_recovery = (strategy_ == Strategy::AGGRESSIVE_RECOVERY); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 base::TimeDelta backoff_period = base_recovery_period_ * backoff_factor; | 186 base::TimeDelta backoff_period = base_recovery_period_ * backoff_factor; |
189 return backoff_period < refresh_period_ ? backoff_period : refresh_period_; | 187 return backoff_period < refresh_period_ ? backoff_period : refresh_period_; |
190 } else { | 188 } else { |
191 PA_LOG(ERROR) << "Error getting period for strategy: " | 189 PA_LOG(ERROR) << "Error getting period for strategy: " |
192 << static_cast<int>(strategy_); | 190 << static_cast<int>(strategy_); |
193 return base::TimeDelta(); | 191 return base::TimeDelta(); |
194 } | 192 } |
195 } | 193 } |
196 | 194 |
197 } // namespace cryptauth | 195 } // namespace cryptauth |
OLD | NEW |