OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 5 #ifndef SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
6 #define SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 6 #define SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // Restart the poll interval. | 106 // Restart the poll interval. |
107 FORCE_RESET, | 107 FORCE_RESET, |
108 // Restart the poll interval only if its length has changed. | 108 // Restart the poll interval only if its length has changed. |
109 UPDATE_INTERVAL, | 109 UPDATE_INTERVAL, |
110 }; | 110 }; |
111 | 111 |
112 friend class SyncSchedulerTest; | 112 friend class SyncSchedulerTest; |
113 friend class SyncSchedulerWhiteboxTest; | 113 friend class SyncSchedulerWhiteboxTest; |
114 friend class SyncerTest; | 114 friend class SyncerTest; |
115 | 115 |
116 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, NoNudgesInConfigureMode); | |
117 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | |
118 DropNudgeWhileExponentialBackOff); | |
119 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, SaveNudge); | |
120 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | |
121 SaveNudgeWhileTypeThrottled); | |
122 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinueNudge); | |
123 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinueConfiguration); | |
124 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | |
125 SaveConfigurationWhileThrottled); | |
126 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | |
127 SaveNudgeWhileThrottled); | |
128 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | |
129 ContinueCanaryJobConfig); | |
130 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, TransientPollFailure); | 116 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, TransientPollFailure); |
131 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, | 117 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, |
132 ServerConnectionChangeDuringBackoff); | 118 ServerConnectionChangeDuringBackoff); |
133 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, | 119 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, |
134 ConnectionChangeCanaryPreemptedByNudge); | 120 ConnectionChangeCanaryPreemptedByNudge); |
135 FRIEND_TEST_ALL_PREFIXES(BackoffTriggersSyncSchedulerTest, | 121 FRIEND_TEST_ALL_PREFIXES(BackoffTriggersSyncSchedulerTest, |
136 FailGetEncryptionKey); | 122 FailGetEncryptionKey); |
| 123 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, SuccessfulRetry); |
| 124 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, FailedRetry); |
| 125 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, ReceiveNewRetryDelay); |
137 | 126 |
138 struct SYNC_EXPORT_PRIVATE WaitInterval { | 127 struct SYNC_EXPORT_PRIVATE WaitInterval { |
139 enum Mode { | 128 enum Mode { |
140 // Uninitialized state, should not be set in practice. | 129 // Uninitialized state, should not be set in practice. |
141 UNKNOWN = -1, | 130 UNKNOWN = -1, |
142 // We enter a series of increasingly longer WaitIntervals if we experience | 131 // We enter a series of increasingly longer WaitIntervals if we experience |
143 // repeated transient failures. We retry at the end of each interval. | 132 // repeated transient failures. We retry at the end of each interval. |
144 EXPONENTIAL_BACKOFF, | 133 EXPONENTIAL_BACKOFF, |
145 // A server-initiated throttled interval. We do not allow any syncing | 134 // A server-initiated throttled interval. We do not allow any syncing |
146 // during such an interval. | 135 // during such an interval. |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 base::TimeTicks last_poll_reset_; | 319 base::TimeTicks last_poll_reset_; |
331 | 320 |
332 // next_sync_session_job_priority_ defines which priority will be used next | 321 // next_sync_session_job_priority_ defines which priority will be used next |
333 // time TrySyncSessionJobImpl is called. CANARY_PRIORITY allows syncer to run | 322 // time TrySyncSessionJobImpl is called. CANARY_PRIORITY allows syncer to run |
334 // even if scheduler is in exponential backoff. This is needed for events that | 323 // even if scheduler is in exponential backoff. This is needed for events that |
335 // have chance of resolving previous error (e.g. network connection change | 324 // have chance of resolving previous error (e.g. network connection change |
336 // after NETWORK_UNAVAILABLE error). | 325 // after NETWORK_UNAVAILABLE error). |
337 // It is reset back to NORMAL_PRIORITY on every call to TrySyncSessionJobImpl. | 326 // It is reset back to NORMAL_PRIORITY on every call to TrySyncSessionJobImpl. |
338 JobPriority next_sync_session_job_priority_; | 327 JobPriority next_sync_session_job_priority_; |
339 | 328 |
| 329 // One-shot timer for scheduling GU retry according to delay set by server. |
| 330 base::OneShotTimer<SyncSchedulerImpl> retry_timer_; |
| 331 |
340 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_; | 332 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_; |
341 | 333 |
342 // A second factory specially for weak_handle_this_, to allow the handle | 334 // A second factory specially for weak_handle_this_, to allow the handle |
343 // to be const and alleviate threading concerns. | 335 // to be const and alleviate threading concerns. |
344 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; | 336 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; |
345 | 337 |
346 // One-shot timer for scheduling GU retry according to delay set by server. | |
347 base::OneShotTimer<SyncSchedulerImpl> retry_timer_; | |
348 | |
349 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); | 338 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
350 }; | 339 }; |
351 | 340 |
352 } // namespace syncer | 341 } // namespace syncer |
353 | 342 |
354 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 343 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
OLD | NEW |