| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 virtual bool IsCurrentlyThrottled() OVERRIDE; | 82 virtual bool IsCurrentlyThrottled() OVERRIDE; |
| 83 virtual void OnReceivedShortPollIntervalUpdate( | 83 virtual void OnReceivedShortPollIntervalUpdate( |
| 84 const base::TimeDelta& new_interval) OVERRIDE; | 84 const base::TimeDelta& new_interval) OVERRIDE; |
| 85 virtual void OnReceivedLongPollIntervalUpdate( | 85 virtual void OnReceivedLongPollIntervalUpdate( |
| 86 const base::TimeDelta& new_interval) OVERRIDE; | 86 const base::TimeDelta& new_interval) OVERRIDE; |
| 87 virtual void OnReceivedSessionsCommitDelay( | 87 virtual void OnReceivedSessionsCommitDelay( |
| 88 const base::TimeDelta& new_delay) OVERRIDE; | 88 const base::TimeDelta& new_delay) OVERRIDE; |
| 89 virtual void OnReceivedClientInvalidationHintBufferSize(int size) OVERRIDE; | 89 virtual void OnReceivedClientInvalidationHintBufferSize(int size) OVERRIDE; |
| 90 virtual void OnSyncProtocolError( | 90 virtual void OnSyncProtocolError( |
| 91 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE; | 91 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE; |
| 92 virtual void OnReceivedGuRetryDelaySeconds(int delay_seconds) OVERRIDE; |
| 92 | 93 |
| 93 private: | 94 private: |
| 94 enum JobPriority { | 95 enum JobPriority { |
| 95 // Non-canary jobs respect exponential backoff. | 96 // Non-canary jobs respect exponential backoff. |
| 96 NORMAL_PRIORITY, | 97 NORMAL_PRIORITY, |
| 97 // Canary jobs bypass exponential backoff, so use with extreme caution. | 98 // Canary jobs bypass exponential backoff, so use with extreme caution. |
| 98 CANARY_PRIORITY | 99 CANARY_PRIORITY |
| 99 }; | 100 }; |
| 100 | 101 |
| 101 enum PollAdjustType { | 102 enum PollAdjustType { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // Invoke the syncer to perform a configuration job. | 161 // Invoke the syncer to perform a configuration job. |
| 161 void DoConfigurationSyncSessionJob(JobPriority priority); | 162 void DoConfigurationSyncSessionJob(JobPriority priority); |
| 162 | 163 |
| 163 // Helper function for Do{Nudge,Configuration}SyncSessionJob. | 164 // Helper function for Do{Nudge,Configuration}SyncSessionJob. |
| 164 void HandleFailure( | 165 void HandleFailure( |
| 165 const sessions::ModelNeutralState& model_neutral_state); | 166 const sessions::ModelNeutralState& model_neutral_state); |
| 166 | 167 |
| 167 // Invoke the Syncer to perform a poll job. | 168 // Invoke the Syncer to perform a poll job. |
| 168 void DoPollSyncSessionJob(); | 169 void DoPollSyncSessionJob(); |
| 169 | 170 |
| 171 // Invoke the Syncer to perform a retry job. |
| 172 void DoRetrySyncSessionJob(); |
| 173 |
| 170 // Helper function to calculate poll interval. | 174 // Helper function to calculate poll interval. |
| 171 base::TimeDelta GetPollInterval(); | 175 base::TimeDelta GetPollInterval(); |
| 172 | 176 |
| 173 // Adjusts the poll timer to account for new poll interval, and possibly | 177 // Adjusts the poll timer to account for new poll interval, and possibly |
| 174 // resets the poll interval, depedning on the flag's value. | 178 // resets the poll interval, depedning on the flag's value. |
| 175 void AdjustPolling(PollAdjustType type); | 179 void AdjustPolling(PollAdjustType type); |
| 176 | 180 |
| 177 // Helper to restart waiting with |wait_interval_|'s timer. | 181 // Helper to restart waiting with |wait_interval_|'s timer. |
| 178 void RestartWaiting(); | 182 void RestartWaiting(); |
| 179 | 183 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 227 |
| 224 // Attempts to exit EXPONENTIAL_BACKOFF by calling TryCanaryJob(). | 228 // Attempts to exit EXPONENTIAL_BACKOFF by calling TryCanaryJob(). |
| 225 void ExponentialBackoffRetry(); | 229 void ExponentialBackoffRetry(); |
| 226 | 230 |
| 227 // Called when the root cause of the current connection error is fixed. | 231 // Called when the root cause of the current connection error is fixed. |
| 228 void OnServerConnectionErrorFixed(); | 232 void OnServerConnectionErrorFixed(); |
| 229 | 233 |
| 230 // Creates a session for a poll and performs the sync. | 234 // Creates a session for a poll and performs the sync. |
| 231 void PollTimerCallback(); | 235 void PollTimerCallback(); |
| 232 | 236 |
| 237 // Creates a session for a retry and performs the sync. |
| 238 void RetryTimerCallback(); |
| 239 |
| 233 // Returns the set of types that are enabled and not currently throttled. | 240 // Returns the set of types that are enabled and not currently throttled. |
| 234 ModelTypeSet GetEnabledAndUnthrottledTypes(); | 241 ModelTypeSet GetEnabledAndUnthrottledTypes(); |
| 235 | 242 |
| 236 // Called as we are started to broadcast an initial session snapshot | 243 // Called as we are started to broadcast an initial session snapshot |
| 237 // containing data like initial_sync_ended. Important when the client starts | 244 // containing data like initial_sync_ended. Important when the client starts |
| 238 // up and does not need to perform an initial sync. | 245 // up and does not need to perform an initial sync. |
| 239 void SendInitialSnapshot(); | 246 void SendInitialSnapshot(); |
| 240 | 247 |
| 241 // This is used for histogramming and analysis of ScheduleNudge* APIs. | 248 // This is used for histogramming and analysis of ScheduleNudge* APIs. |
| 242 // SyncScheduler is the ultimate choke-point for all such invocations (with | 249 // SyncScheduler is the ultimate choke-point for all such invocations (with |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // after NETWORK_UNAVAILABLE error). | 336 // after NETWORK_UNAVAILABLE error). |
| 330 // It is reset back to NORMAL_PRIORITY on every call to TrySyncSessionJobImpl. | 337 // It is reset back to NORMAL_PRIORITY on every call to TrySyncSessionJobImpl. |
| 331 JobPriority next_sync_session_job_priority_; | 338 JobPriority next_sync_session_job_priority_; |
| 332 | 339 |
| 333 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_; | 340 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_; |
| 334 | 341 |
| 335 // A second factory specially for weak_handle_this_, to allow the handle | 342 // A second factory specially for weak_handle_this_, to allow the handle |
| 336 // to be const and alleviate threading concerns. | 343 // to be const and alleviate threading concerns. |
| 337 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; | 344 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; |
| 338 | 345 |
| 346 // One-shot timer for scheduling GU retry according to delay set by server. |
| 347 base::OneShotTimer<SyncSchedulerImpl> retry_timer_; |
| 348 |
| 339 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); | 349 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
| 340 }; | 350 }; |
| 341 | 351 |
| 342 } // namespace syncer | 352 } // namespace syncer |
| 343 | 353 |
| 344 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 354 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
| OLD | NEW |