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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 void SendInitialSnapshot(); | 235 void SendInitialSnapshot(); |
247 | 236 |
248 // This is used for histogramming and analysis of ScheduleNudge* APIs. | 237 // This is used for histogramming and analysis of ScheduleNudge* APIs. |
249 // SyncScheduler is the ultimate choke-point for all such invocations (with | 238 // SyncScheduler is the ultimate choke-point for all such invocations (with |
250 // and without InvalidationState variants, all NudgeSources, etc) and as such | 239 // and without InvalidationState variants, all NudgeSources, etc) and as such |
251 // is the most flexible place to do this bookkeeping. | 240 // is the most flexible place to do this bookkeeping. |
252 void UpdateNudgeTimeRecords(ModelTypeSet types); | 241 void UpdateNudgeTimeRecords(ModelTypeSet types); |
253 | 242 |
254 virtual void OnActionableError(const sessions::SyncSessionSnapshot& snapshot); | 243 virtual void OnActionableError(const sessions::SyncSessionSnapshot& snapshot); |
255 | 244 |
245 // Helper to process the GU retry delay we received in the previous cycle. | |
246 void ProcessReceivedGuRetryDelay(); | |
247 | |
248 // Helper to clear state associated with the receipt of GU retry requests. | |
249 void ClearReceivedGuRetryDelayFlag(); | |
250 | |
256 // For certain methods that need to worry about X-thread posting. | 251 // For certain methods that need to worry about X-thread posting. |
257 WeakHandle<SyncSchedulerImpl> weak_handle_this_; | 252 WeakHandle<SyncSchedulerImpl> weak_handle_this_; |
258 | 253 |
259 // Used for logging. | 254 // Used for logging. |
260 const std::string name_; | 255 const std::string name_; |
261 | 256 |
262 // Set in Start(), unset in Stop(). | 257 // Set in Start(), unset in Stop(). |
263 bool started_; | 258 bool started_; |
264 | 259 |
265 // Modifiable versions of kDefaultLongPollIntervalSeconds which can be | 260 // Modifiable versions of kDefaultLongPollIntervalSeconds which can be |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 base::TimeTicks last_poll_reset_; | 325 base::TimeTicks last_poll_reset_; |
331 | 326 |
332 // next_sync_session_job_priority_ defines which priority will be used next | 327 // next_sync_session_job_priority_ defines which priority will be used next |
333 // time TrySyncSessionJobImpl is called. CANARY_PRIORITY allows syncer to run | 328 // time TrySyncSessionJobImpl is called. CANARY_PRIORITY allows syncer to run |
334 // even if scheduler is in exponential backoff. This is needed for events that | 329 // 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 | 330 // have chance of resolving previous error (e.g. network connection change |
336 // after NETWORK_UNAVAILABLE error). | 331 // after NETWORK_UNAVAILABLE error). |
337 // It is reset back to NORMAL_PRIORITY on every call to TrySyncSessionJobImpl. | 332 // It is reset back to NORMAL_PRIORITY on every call to TrySyncSessionJobImpl. |
338 JobPriority next_sync_session_job_priority_; | 333 JobPriority next_sync_session_job_priority_; |
339 | 334 |
335 // Set by the OnReceivedGuRetryDelay callback. | |
336 base::TimeDelta pending_retry_delay_; | |
337 | |
338 // Set byt he OnReceivedGuRetryDelay callback. | |
pavely
2014/01/27 11:54:05
typo: "byt he" => "by the"
| |
339 bool received_pending_retry_; | |
340 | |
341 // One-shot timer for scheduling GU retry according to delay set by server. | |
342 base::OneShotTimer<SyncSchedulerImpl> retry_timer_; | |
343 | |
340 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_; | 344 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_; |
341 | 345 |
342 // A second factory specially for weak_handle_this_, to allow the handle | 346 // A second factory specially for weak_handle_this_, to allow the handle |
343 // to be const and alleviate threading concerns. | 347 // to be const and alleviate threading concerns. |
344 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; | 348 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; |
345 | 349 |
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); | 350 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
350 }; | 351 }; |
351 | 352 |
352 } // namespace syncer | 353 } // namespace syncer |
353 | 354 |
354 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 355 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
OLD | NEW |