| 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 sessions::SyncSessionContext* context, | 49 sessions::SyncSessionContext* context, |
| 50 Syncer* syncer); | 50 Syncer* syncer); |
| 51 | 51 |
| 52 // Calls Stop(). | 52 // Calls Stop(). |
| 53 virtual ~SyncSchedulerImpl(); | 53 virtual ~SyncSchedulerImpl(); |
| 54 | 54 |
| 55 virtual void Start(Mode mode) OVERRIDE; | 55 virtual void Start(Mode mode) OVERRIDE; |
| 56 virtual bool ScheduleConfiguration( | 56 virtual bool ScheduleConfiguration( |
| 57 const ConfigurationParams& params) OVERRIDE; | 57 const ConfigurationParams& params) OVERRIDE; |
| 58 virtual void RequestStop(const base::Closure& callback) OVERRIDE; | 58 virtual void RequestStop(const base::Closure& callback) OVERRIDE; |
| 59 virtual void ScheduleNudgeAsync( | 59 virtual void ScheduleLocalNudge( |
| 60 const base::TimeDelta& desired_delay, | 60 const base::TimeDelta& desired_delay, |
| 61 NudgeSource source, | |
| 62 ModelTypeSet types, | 61 ModelTypeSet types, |
| 63 const tracked_objects::Location& nudge_location) OVERRIDE; | 62 const tracked_objects::Location& nudge_location) OVERRIDE; |
| 64 virtual void ScheduleNudgeWithStatesAsync( | 63 virtual void ScheduleLocalRefreshRequest( |
| 65 const base::TimeDelta& desired_delay, NudgeSource source, | 64 const base::TimeDelta& desired_delay, |
| 65 ModelTypeSet types, |
| 66 const tracked_objects::Location& nudge_location) OVERRIDE; |
| 67 virtual void ScheduleInvalidationNudge( |
| 68 const base::TimeDelta& desired_delay, |
| 66 const ModelTypeInvalidationMap& invalidation_map, | 69 const ModelTypeInvalidationMap& invalidation_map, |
| 67 const tracked_objects::Location& nudge_location) OVERRIDE; | 70 const tracked_objects::Location& nudge_location) OVERRIDE; |
| 68 virtual void SetNotificationsEnabled(bool notifications_enabled) OVERRIDE; | 71 virtual void SetNotificationsEnabled(bool notifications_enabled) OVERRIDE; |
| 69 | 72 |
| 70 virtual base::TimeDelta GetSessionsCommitDelay() const OVERRIDE; | 73 virtual base::TimeDelta GetSessionsCommitDelay() const OVERRIDE; |
| 71 | 74 |
| 72 virtual void OnCredentialsUpdated() OVERRIDE; | 75 virtual void OnCredentialsUpdated() OVERRIDE; |
| 73 virtual void OnConnectionStatusChange() OVERRIDE; | 76 virtual void OnConnectionStatusChange() OVERRIDE; |
| 74 | 77 |
| 75 // SyncSession::Delegate implementation. | 78 // SyncSession::Delegate implementation. |
| 76 virtual void OnSilencedUntil( | 79 virtual void OnSilencedUntil( |
| 77 const base::TimeTicks& silenced_until) OVERRIDE; | 80 const base::TimeTicks& silenced_until) OVERRIDE; |
| 78 virtual bool IsSyncingCurrentlySilenced() OVERRIDE; | 81 virtual bool IsSyncingCurrentlySilenced() OVERRIDE; |
| 79 virtual void OnReceivedShortPollIntervalUpdate( | 82 virtual void OnReceivedShortPollIntervalUpdate( |
| 80 const base::TimeDelta& new_interval) OVERRIDE; | 83 const base::TimeDelta& new_interval) OVERRIDE; |
| 81 virtual void OnReceivedLongPollIntervalUpdate( | 84 virtual void OnReceivedLongPollIntervalUpdate( |
| 82 const base::TimeDelta& new_interval) OVERRIDE; | 85 const base::TimeDelta& new_interval) OVERRIDE; |
| 83 virtual void OnReceivedSessionsCommitDelay( | 86 virtual void OnReceivedSessionsCommitDelay( |
| 84 const base::TimeDelta& new_delay) OVERRIDE; | 87 const base::TimeDelta& new_delay) OVERRIDE; |
| 88 virtual void OnReceivedClientInvalidationHintBufferSize(int size) OVERRIDE; |
| 85 virtual void OnShouldStopSyncingPermanently() OVERRIDE; | 89 virtual void OnShouldStopSyncingPermanently() OVERRIDE; |
| 86 virtual void OnSyncProtocolError( | 90 virtual void OnSyncProtocolError( |
| 87 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE; | 91 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE; |
| 88 | 92 |
| 89 private: | 93 private: |
| 90 enum JobPriority { | 94 enum JobPriority { |
| 91 // Non-canary jobs respect exponential backoff. | 95 // Non-canary jobs respect exponential backoff. |
| 92 NORMAL_PRIORITY, | 96 NORMAL_PRIORITY, |
| 93 // Canary jobs bypass exponential backoff, so use with extreme caution. | 97 // Canary jobs bypass exponential backoff, so use with extreme caution. |
| 94 CANARY_PRIORITY | 98 CANARY_PRIORITY |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 184 |
| 181 // 'Impl' here refers to real implementation of public functions. | 185 // 'Impl' here refers to real implementation of public functions. |
| 182 void StopImpl(const base::Closure& callback); | 186 void StopImpl(const base::Closure& callback); |
| 183 | 187 |
| 184 // If the scheduler's current state supports it, this will create a job based | 188 // If the scheduler's current state supports it, this will create a job based |
| 185 // on the passed in parameters and coalesce it with any other pending jobs, | 189 // on the passed in parameters and coalesce it with any other pending jobs, |
| 186 // then post a delayed task to run it. It may also choose to drop the job or | 190 // then post a delayed task to run it. It may also choose to drop the job or |
| 187 // save it for later, depending on the scheduler's current state. | 191 // save it for later, depending on the scheduler's current state. |
| 188 void ScheduleNudgeImpl( | 192 void ScheduleNudgeImpl( |
| 189 const base::TimeDelta& delay, | 193 const base::TimeDelta& delay, |
| 190 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, | |
| 191 const ModelTypeInvalidationMap& invalidation_map, | |
| 192 const tracked_objects::Location& nudge_location); | 194 const tracked_objects::Location& nudge_location); |
| 193 | 195 |
| 194 // Returns true if the client is currently in exponential backoff. | 196 // Returns true if the client is currently in exponential backoff. |
| 195 bool IsBackingOff() const; | 197 bool IsBackingOff() const; |
| 196 | 198 |
| 197 // Helper to signal all listeners registered with |session_context_|. | 199 // Helper to signal all listeners registered with |session_context_|. |
| 198 void Notify(SyncEngineEvent::EventCause cause); | 200 void Notify(SyncEngineEvent::EventCause cause); |
| 199 | 201 |
| 200 // Helper to signal listeners about changed retry time | 202 // Helper to signal listeners about changed retry time |
| 201 void NotifyRetryTime(base::Time retry_time); | 203 void NotifyRetryTime(base::Time retry_time); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 215 | 217 |
| 216 // Called as we are started to broadcast an initial session snapshot | 218 // Called as we are started to broadcast an initial session snapshot |
| 217 // containing data like initial_sync_ended. Important when the client starts | 219 // containing data like initial_sync_ended. Important when the client starts |
| 218 // up and does not need to perform an initial sync. | 220 // up and does not need to perform an initial sync. |
| 219 void SendInitialSnapshot(); | 221 void SendInitialSnapshot(); |
| 220 | 222 |
| 221 // This is used for histogramming and analysis of ScheduleNudge* APIs. | 223 // This is used for histogramming and analysis of ScheduleNudge* APIs. |
| 222 // SyncScheduler is the ultimate choke-point for all such invocations (with | 224 // SyncScheduler is the ultimate choke-point for all such invocations (with |
| 223 // and without InvalidationState variants, all NudgeSources, etc) and as such | 225 // and without InvalidationState variants, all NudgeSources, etc) and as such |
| 224 // is the most flexible place to do this bookkeeping. | 226 // is the most flexible place to do this bookkeeping. |
| 225 void UpdateNudgeTimeRecords(const sessions::SyncSourceInfo& info); | 227 void UpdateNudgeTimeRecords(ModelTypeSet types); |
| 226 | 228 |
| 227 virtual void OnActionableError(const sessions::SyncSessionSnapshot& snapshot); | 229 virtual void OnActionableError(const sessions::SyncSessionSnapshot& snapshot); |
| 228 | 230 |
| 229 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_; | 231 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_; |
| 230 | 232 |
| 231 // A second factory specially for weak_handle_this_, to allow the handle | 233 // A second factory specially for weak_handle_this_, to allow the handle |
| 232 // to be const and alleviate threading concerns. | 234 // to be const and alleviate threading concerns. |
| 233 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; | 235 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; |
| 234 | 236 |
| 235 // For certain methods that need to worry about X-thread posting. | 237 // For certain methods that need to worry about X-thread posting. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // take place during a sync cycle. We call this out because such violations | 292 // take place during a sync cycle. We call this out because such violations |
| 291 // could result in tight sync loops hitting sync servers. | 293 // could result in tight sync loops hitting sync servers. |
| 292 bool no_scheduling_allowed_; | 294 bool no_scheduling_allowed_; |
| 293 | 295 |
| 294 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); | 296 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
| 295 }; | 297 }; |
| 296 | 298 |
| 297 } // namespace syncer | 299 } // namespace syncer |
| 298 | 300 |
| 299 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 301 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
| OLD | NEW |