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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 const base::TimeDelta& throttle_duration) OVERRIDE; | 81 const base::TimeDelta& throttle_duration) OVERRIDE; |
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 SyncProtocolError& sync_protocol_error) OVERRIDE; |
92 virtual void OnReceivedGuRetryDelay(const base::TimeDelta& delay) OVERRIDE; | 92 virtual void OnReceivedGuRetryDelay(const base::TimeDelta& delay) OVERRIDE; |
93 | 93 |
94 // Returns true if the client is currently in exponential backoff. | 94 // Returns true if the client is currently in exponential backoff. |
95 bool IsBackingOff() const; | 95 bool IsBackingOff() const; |
96 | 96 |
97 private: | 97 private: |
98 enum JobPriority { | 98 enum JobPriority { |
99 // Non-canary jobs respect exponential backoff. | 99 // Non-canary jobs respect exponential backoff. |
100 NORMAL_PRIORITY, | 100 NORMAL_PRIORITY, |
101 // Canary jobs bypass exponential backoff, so use with extreme caution. | 101 // Canary jobs bypass exponential backoff, so use with extreme caution. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 bool CanRunNudgeJobNow(JobPriority priority); | 180 bool CanRunNudgeJobNow(JobPriority priority); |
181 | 181 |
182 // If the scheduler's current state supports it, this will create a job based | 182 // If the scheduler's current state supports it, this will create a job based |
183 // on the passed in parameters and coalesce it with any other pending jobs, | 183 // on the passed in parameters and coalesce it with any other pending jobs, |
184 // then post a delayed task to run it. It may also choose to drop the job or | 184 // then post a delayed task to run it. It may also choose to drop the job or |
185 // save it for later, depending on the scheduler's current state. | 185 // save it for later, depending on the scheduler's current state. |
186 void ScheduleNudgeImpl( | 186 void ScheduleNudgeImpl( |
187 const base::TimeDelta& delay, | 187 const base::TimeDelta& delay, |
188 const tracked_objects::Location& nudge_location); | 188 const tracked_objects::Location& nudge_location); |
189 | 189 |
190 // Helper to signal all listeners registered with |session_context_|. | |
191 void Notify(SyncEngineEvent::EventCause cause); | |
192 | |
193 // Helper to signal listeners about changed retry time. | 190 // Helper to signal listeners about changed retry time. |
194 void NotifyRetryTime(base::Time retry_time); | 191 void NotifyRetryTime(base::Time retry_time); |
195 | 192 |
196 // Helper to signal listeners about changed throttled types. | 193 // Helper to signal listeners about changed throttled types. |
197 void NotifyThrottledTypesChanged(ModelTypeSet types); | 194 void NotifyThrottledTypesChanged(ModelTypeSet types); |
198 | 195 |
199 // Looks for pending work and, if it finds any, run this work at "canary" | 196 // Looks for pending work and, if it finds any, run this work at "canary" |
200 // priority. | 197 // priority. |
201 void TryCanaryJob(); | 198 void TryCanaryJob(); |
202 | 199 |
(...skipping 30 matching lines...) Expand all Loading... |
233 // containing data like initial_sync_ended. Important when the client starts | 230 // containing data like initial_sync_ended. Important when the client starts |
234 // up and does not need to perform an initial sync. | 231 // up and does not need to perform an initial sync. |
235 void SendInitialSnapshot(); | 232 void SendInitialSnapshot(); |
236 | 233 |
237 // This is used for histogramming and analysis of ScheduleNudge* APIs. | 234 // This is used for histogramming and analysis of ScheduleNudge* APIs. |
238 // SyncScheduler is the ultimate choke-point for all such invocations (with | 235 // SyncScheduler is the ultimate choke-point for all such invocations (with |
239 // and without InvalidationState variants, all NudgeSources, etc) and as such | 236 // and without InvalidationState variants, all NudgeSources, etc) and as such |
240 // is the most flexible place to do this bookkeeping. | 237 // is the most flexible place to do this bookkeeping. |
241 void UpdateNudgeTimeRecords(ModelTypeSet types); | 238 void UpdateNudgeTimeRecords(ModelTypeSet types); |
242 | 239 |
243 virtual void OnActionableError(const sessions::SyncSessionSnapshot& snapshot); | |
244 | |
245 // For certain methods that need to worry about X-thread posting. | 240 // For certain methods that need to worry about X-thread posting. |
246 WeakHandle<SyncSchedulerImpl> weak_handle_this_; | 241 WeakHandle<SyncSchedulerImpl> weak_handle_this_; |
247 | 242 |
248 // Used for logging. | 243 // Used for logging. |
249 const std::string name_; | 244 const std::string name_; |
250 | 245 |
251 // Set in Start(), unset in Stop(). | 246 // Set in Start(), unset in Stop(). |
252 bool started_; | 247 bool started_; |
253 | 248 |
254 // Modifiable versions of kDefaultLongPollIntervalSeconds which can be | 249 // Modifiable versions of kDefaultLongPollIntervalSeconds which can be |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 // A second factory specially for weak_handle_this_, to allow the handle | 329 // A second factory specially for weak_handle_this_, to allow the handle |
335 // to be const and alleviate threading concerns. | 330 // to be const and alleviate threading concerns. |
336 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; | 331 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; |
337 | 332 |
338 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); | 333 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
339 }; | 334 }; |
340 | 335 |
341 } // namespace syncer | 336 } // namespace syncer |
342 | 337 |
343 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 338 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
OLD | NEW |