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, base::TimeDelta>& 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 |
100 private: | 95 private: |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 WaitInterval(Mode mode, base::TimeDelta length); | 138 WaitInterval(Mode mode, base::TimeDelta length); |
144 | 139 |
145 static const char* GetModeString(Mode mode); | 140 static const char* GetModeString(Mode mode); |
146 | 141 |
147 Mode mode; | 142 Mode mode; |
148 base::TimeDelta length; | 143 base::TimeDelta length; |
149 }; | 144 }; |
150 | 145 |
151 static const char* GetModeString(Mode mode); | 146 static const char* GetModeString(Mode mode); |
152 | 147 |
| 148 void SetDefaultNudgeDelay(base::TimeDelta delay_ms); |
| 149 |
153 // Invoke the syncer to perform a nudge job. | 150 // Invoke the syncer to perform a nudge job. |
154 void DoNudgeSyncSessionJob(JobPriority priority); | 151 void DoNudgeSyncSessionJob(JobPriority priority); |
155 | 152 |
156 // Invoke the syncer to perform a configuration job. | 153 // Invoke the syncer to perform a configuration job. |
157 void DoConfigurationSyncSessionJob(JobPriority priority); | 154 void DoConfigurationSyncSessionJob(JobPriority priority); |
158 | 155 |
159 // Helper function for Do{Nudge,Configuration}SyncSessionJob. | 156 // Helper function for Do{Nudge,Configuration}SyncSessionJob. |
160 void HandleFailure( | 157 void HandleFailure( |
161 const sessions::ModelNeutralState& model_neutral_state); | 158 const sessions::ModelNeutralState& model_neutral_state); |
162 | 159 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 const std::string name_; | 241 const std::string name_; |
245 | 242 |
246 // Set in Start(), unset in Stop(). | 243 // Set in Start(), unset in Stop(). |
247 bool started_; | 244 bool started_; |
248 | 245 |
249 // Modifiable versions of kDefaultLongPollIntervalSeconds which can be | 246 // Modifiable versions of kDefaultLongPollIntervalSeconds which can be |
250 // updated by the server. | 247 // updated by the server. |
251 base::TimeDelta syncer_short_poll_interval_seconds_; | 248 base::TimeDelta syncer_short_poll_interval_seconds_; |
252 base::TimeDelta syncer_long_poll_interval_seconds_; | 249 base::TimeDelta syncer_long_poll_interval_seconds_; |
253 | 250 |
254 // Server-tweakable sessions commit delay. | |
255 base::TimeDelta sessions_commit_delay_; | |
256 | |
257 // Periodic timer for polling. See AdjustPolling. | 251 // Periodic timer for polling. See AdjustPolling. |
258 base::RepeatingTimer<SyncSchedulerImpl> poll_timer_; | 252 base::RepeatingTimer<SyncSchedulerImpl> poll_timer_; |
259 | 253 |
260 // The mode of operation. | 254 // The mode of operation. |
261 Mode mode_; | 255 Mode mode_; |
262 | 256 |
263 // Current wait state. Null if we're not in backoff and not throttled. | 257 // Current wait state. Null if we're not in backoff and not throttled. |
264 scoped_ptr<WaitInterval> wait_interval_; | 258 scoped_ptr<WaitInterval> wait_interval_; |
265 | 259 |
266 scoped_ptr<BackoffDelayProvider> delay_provider_; | 260 scoped_ptr<BackoffDelayProvider> delay_provider_; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 // A second factory specially for weak_handle_this_, to allow the handle | 323 // A second factory specially for weak_handle_this_, to allow the handle |
330 // to be const and alleviate threading concerns. | 324 // to be const and alleviate threading concerns. |
331 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; | 325 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; |
332 | 326 |
333 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); | 327 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
334 }; | 328 }; |
335 | 329 |
336 } // namespace syncer | 330 } // namespace syncer |
337 | 331 |
338 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 332 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
OLD | NEW |