Chromium Code Reviews| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 Syncer* syncer); | 49 Syncer* syncer); |
| 50 | 50 |
| 51 // Calls Stop(). | 51 // Calls Stop(). |
| 52 virtual ~SyncSchedulerImpl(); | 52 virtual ~SyncSchedulerImpl(); |
| 53 | 53 |
| 54 virtual void Start(Mode mode) OVERRIDE; | 54 virtual void Start(Mode mode) OVERRIDE; |
| 55 virtual void ScheduleConfiguration( | 55 virtual void ScheduleConfiguration( |
| 56 const ConfigurationParams& params) OVERRIDE; | 56 const ConfigurationParams& params) OVERRIDE; |
| 57 virtual void Stop() OVERRIDE; | 57 virtual void Stop() OVERRIDE; |
| 58 virtual void ScheduleLocalNudge( | 58 virtual void ScheduleLocalNudge( |
| 59 const base::TimeDelta& desired_delay, | |
| 60 ModelTypeSet types, | 59 ModelTypeSet types, |
| 61 const tracked_objects::Location& nudge_location) OVERRIDE; | 60 const tracked_objects::Location& nudge_location) OVERRIDE; |
| 62 virtual void ScheduleLocalRefreshRequest( | 61 virtual void ScheduleLocalRefreshRequest( |
| 63 const base::TimeDelta& desired_delay, | |
| 64 ModelTypeSet types, | 62 ModelTypeSet types, |
| 65 const tracked_objects::Location& nudge_location) OVERRIDE; | 63 const tracked_objects::Location& nudge_location) OVERRIDE; |
| 66 virtual void ScheduleInvalidationNudge( | 64 virtual void ScheduleInvalidationNudge( |
| 67 const base::TimeDelta& desired_delay, | |
| 68 syncer::ModelType type, | 65 syncer::ModelType type, |
| 69 scoped_ptr<InvalidationInterface> invalidation, | 66 scoped_ptr<InvalidationInterface> invalidation, |
| 70 const tracked_objects::Location& nudge_location) OVERRIDE; | 67 const tracked_objects::Location& nudge_location) OVERRIDE; |
| 71 virtual void ScheduleInitialSyncNudge(syncer::ModelType model_type) OVERRIDE; | 68 virtual void ScheduleInitialSyncNudge(syncer::ModelType model_type) OVERRIDE; |
| 72 virtual void SetNotificationsEnabled(bool notifications_enabled) OVERRIDE; | 69 virtual void SetNotificationsEnabled(bool notifications_enabled) OVERRIDE; |
| 73 | 70 |
| 74 virtual base::TimeDelta GetSessionsCommitDelay() const OVERRIDE; | |
| 75 | |
| 76 virtual void OnCredentialsUpdated() OVERRIDE; | 71 virtual void OnCredentialsUpdated() OVERRIDE; |
| 77 virtual void OnConnectionStatusChange() OVERRIDE; | 72 virtual void OnConnectionStatusChange() OVERRIDE; |
| 78 | 73 |
| 79 // SyncSession::Delegate implementation. | 74 // SyncSession::Delegate implementation. |
| 80 virtual void OnThrottled(const base::TimeDelta& throttle_duration) OVERRIDE; | 75 virtual void OnThrottled(const base::TimeDelta& throttle_duration) OVERRIDE; |
| 81 virtual void OnTypesThrottled( | 76 virtual void OnTypesThrottled( |
| 82 ModelTypeSet types, | 77 ModelTypeSet types, |
| 83 const base::TimeDelta& throttle_duration) OVERRIDE; | 78 const base::TimeDelta& throttle_duration) OVERRIDE; |
| 84 virtual bool IsCurrentlyThrottled() OVERRIDE; | 79 virtual bool IsCurrentlyThrottled() OVERRIDE; |
| 85 virtual void OnReceivedShortPollIntervalUpdate( | 80 virtual void OnReceivedShortPollIntervalUpdate( |
| 86 const base::TimeDelta& new_interval) OVERRIDE; | 81 const base::TimeDelta& new_interval) OVERRIDE; |
| 87 virtual void OnReceivedLongPollIntervalUpdate( | 82 virtual void OnReceivedLongPollIntervalUpdate( |
| 88 const base::TimeDelta& new_interval) OVERRIDE; | 83 const base::TimeDelta& new_interval) OVERRIDE; |
| 89 virtual void OnReceivedSessionsCommitDelay( | 84 virtual void OnReceivedCustomNudgeDelays( |
| 90 const base::TimeDelta& new_delay) OVERRIDE; | 85 const std::map<ModelType, int>& nudge_delays) OVERRIDE; |
| 91 virtual void OnReceivedClientInvalidationHintBufferSize(int size) OVERRIDE; | 86 virtual void OnReceivedClientInvalidationHintBufferSize(int size) OVERRIDE; |
| 92 virtual void OnSyncProtocolError( | 87 virtual void OnSyncProtocolError( |
| 93 const SyncProtocolError& sync_protocol_error) OVERRIDE; | 88 const SyncProtocolError& sync_protocol_error) OVERRIDE; |
| 94 virtual void OnReceivedGuRetryDelay(const base::TimeDelta& delay) OVERRIDE; | 89 virtual void OnReceivedGuRetryDelay(const base::TimeDelta& delay) OVERRIDE; |
| 95 virtual void OnReceivedMigrationRequest(syncer::ModelTypeSet types) OVERRIDE; | 90 virtual void OnReceivedMigrationRequest(syncer::ModelTypeSet types) OVERRIDE; |
| 96 | 91 |
| 97 // Returns true if the client is currently in exponential backoff. | 92 // Returns true if the client is currently in exponential backoff. |
| 98 bool IsBackingOff() const; | 93 bool IsBackingOff() const; |
| 99 | 94 |
| 95 // Returns the nudge delay to be used based on |types|. | |
| 96 base::TimeDelta GetNudgeDelayForTypes(ModelTypeSet types) const; | |
| 97 | |
| 100 private: | 98 private: |
| 101 enum JobPriority { | 99 enum JobPriority { |
| 102 // Non-canary jobs respect exponential backoff. | 100 // Non-canary jobs respect exponential backoff. |
| 103 NORMAL_PRIORITY, | 101 NORMAL_PRIORITY, |
| 104 // Canary jobs bypass exponential backoff, so use with extreme caution. | 102 // Canary jobs bypass exponential backoff, so use with extreme caution. |
| 105 CANARY_PRIORITY | 103 CANARY_PRIORITY |
| 106 }; | 104 }; |
| 107 | 105 |
| 108 enum PollAdjustType { | 106 enum PollAdjustType { |
| 109 // Restart the poll interval. | 107 // Restart the poll interval. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 WaitInterval(Mode mode, base::TimeDelta length); | 141 WaitInterval(Mode mode, base::TimeDelta length); |
| 144 | 142 |
| 145 static const char* GetModeString(Mode mode); | 143 static const char* GetModeString(Mode mode); |
| 146 | 144 |
| 147 Mode mode; | 145 Mode mode; |
| 148 base::TimeDelta length; | 146 base::TimeDelta length; |
| 149 }; | 147 }; |
| 150 | 148 |
| 151 static const char* GetModeString(Mode mode); | 149 static const char* GetModeString(Mode mode); |
| 152 | 150 |
| 151 void SetDefaultNudgeDelay(int delay_ms); | |
| 152 | |
| 153 // Invoke the syncer to perform a nudge job. | 153 // Invoke the syncer to perform a nudge job. |
| 154 void DoNudgeSyncSessionJob(JobPriority priority); | 154 void DoNudgeSyncSessionJob(JobPriority priority); |
| 155 | 155 |
| 156 // Invoke the syncer to perform a configuration job. | 156 // Invoke the syncer to perform a configuration job. |
| 157 void DoConfigurationSyncSessionJob(JobPriority priority); | 157 void DoConfigurationSyncSessionJob(JobPriority priority); |
| 158 | 158 |
| 159 // Helper function for Do{Nudge,Configuration}SyncSessionJob. | 159 // Helper function for Do{Nudge,Configuration}SyncSessionJob. |
| 160 void HandleFailure( | 160 void HandleFailure( |
| 161 const sessions::ModelNeutralState& model_neutral_state); | 161 const sessions::ModelNeutralState& model_neutral_state); |
| 162 | 162 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 const std::string name_; | 244 const std::string name_; |
| 245 | 245 |
| 246 // Set in Start(), unset in Stop(). | 246 // Set in Start(), unset in Stop(). |
| 247 bool started_; | 247 bool started_; |
| 248 | 248 |
| 249 // Modifiable versions of kDefaultLongPollIntervalSeconds which can be | 249 // Modifiable versions of kDefaultLongPollIntervalSeconds which can be |
| 250 // updated by the server. | 250 // updated by the server. |
| 251 base::TimeDelta syncer_short_poll_interval_seconds_; | 251 base::TimeDelta syncer_short_poll_interval_seconds_; |
| 252 base::TimeDelta syncer_long_poll_interval_seconds_; | 252 base::TimeDelta syncer_long_poll_interval_seconds_; |
| 253 | 253 |
| 254 // Server-tweakable sessions commit delay. | 254 // Server-tweakable custom nudge delays. |
|
rlarocque
2014/08/20 00:13:31
The nudge delay tracking code is somewhat complica
Nicolas Zea
2014/08/20 22:49:43
Discussed offline, moved this state into NudgeTrac
| |
| 255 base::TimeDelta sessions_commit_delay_; | 255 int minimum_nudge_delay_ms_; |
| 256 std::map<ModelType, base::TimeDelta> nudge_delays_; | |
| 256 | 257 |
| 257 // Periodic timer for polling. See AdjustPolling. | 258 // Periodic timer for polling. See AdjustPolling. |
| 258 base::RepeatingTimer<SyncSchedulerImpl> poll_timer_; | 259 base::RepeatingTimer<SyncSchedulerImpl> poll_timer_; |
| 259 | 260 |
| 260 // The mode of operation. | 261 // The mode of operation. |
| 261 Mode mode_; | 262 Mode mode_; |
| 262 | 263 |
| 263 // Current wait state. Null if we're not in backoff and not throttled. | 264 // Current wait state. Null if we're not in backoff and not throttled. |
| 264 scoped_ptr<WaitInterval> wait_interval_; | 265 scoped_ptr<WaitInterval> wait_interval_; |
| 265 | 266 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 // A second factory specially for weak_handle_this_, to allow the handle | 330 // A second factory specially for weak_handle_this_, to allow the handle |
| 330 // to be const and alleviate threading concerns. | 331 // to be const and alleviate threading concerns. |
| 331 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; | 332 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; |
| 332 | 333 |
| 333 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); | 334 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
| 334 }; | 335 }; |
| 335 | 336 |
| 336 } // namespace syncer | 337 } // namespace syncer |
| 337 | 338 |
| 338 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 339 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
| OLD | NEW |