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/proximity_auth/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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 sync_state_ = SyncState::SYNC_IN_PROGRESS; | 106 sync_state_ = SyncState::SYNC_IN_PROGRESS; |
107 } else if (strategy_ == Strategy::AGGRESSIVE_RECOVERY) { | 107 } else if (strategy_ == Strategy::AGGRESSIVE_RECOVERY) { |
108 PA_LOG(INFO) << "Timer fired for aggressive recovery, making request..."; | 108 PA_LOG(INFO) << "Timer fired for aggressive recovery, making request..."; |
109 sync_state_ = SyncState::SYNC_IN_PROGRESS; | 109 sync_state_ = SyncState::SYNC_IN_PROGRESS; |
110 } else { | 110 } else { |
111 NOTREACHED(); | 111 NOTREACHED(); |
112 return; | 112 return; |
113 } | 113 } |
114 | 114 |
115 delegate_->OnSyncRequested( | 115 delegate_->OnSyncRequested( |
116 base::WrapUnique(new 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 bool retain_user_task = false; |
121 bool is_repeating = false; | 121 bool is_repeating = false; |
122 return base::WrapUnique(new base::Timer(retain_user_task, is_repeating)); | 122 return base::MakeUnique<base::Timer>(retain_user_task, is_repeating); |
123 } | 123 } |
124 | 124 |
125 void SyncSchedulerImpl::ScheduleNextSync(const base::TimeDelta& sync_delta) { | 125 void SyncSchedulerImpl::ScheduleNextSync(const base::TimeDelta& sync_delta) { |
126 if (sync_state_ != SyncState::WAITING_FOR_REFRESH) { | 126 if (sync_state_ != SyncState::WAITING_FOR_REFRESH) { |
127 PA_LOG(ERROR) << "Unexpected state when scheduling next sync: sync_state=" | 127 PA_LOG(ERROR) << "Unexpected state when scheduling next sync: sync_state=" |
128 << static_cast<int>(sync_state_); | 128 << static_cast<int>(sync_state_); |
129 return; | 129 return; |
130 } | 130 } |
131 | 131 |
132 bool is_aggressive_recovery = (strategy_ == Strategy::AGGRESSIVE_RECOVERY); | 132 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; | 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 proximity_auth |
OLD | NEW |