| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // A class to schedule syncer tasks intelligently. | 5 // A class to schedule syncer tasks intelligently. |
| 6 #ifndef CHROME_BROWSER_SYNC_ENGINE_SYNC_SCHEDULER_H_ | 6 #ifndef CHROME_BROWSER_SYNC_ENGINE_SYNC_SCHEDULER_H_ |
| 7 #define CHROME_BROWSER_SYNC_ENGINE_SYNC_SCHEDULER_H_ | 7 #define CHROME_BROWSER_SYNC_ENGINE_SYNC_SCHEDULER_H_ |
| 8 #pragma once | 8 #pragma once |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 void ScheduleNudge(const base::TimeDelta& delay, NudgeSource source, | 86 void ScheduleNudge(const base::TimeDelta& delay, NudgeSource source, |
| 87 const syncable::ModelTypeBitSet& types, | 87 const syncable::ModelTypeBitSet& types, |
| 88 const tracked_objects::Location& nudge_location); | 88 const tracked_objects::Location& nudge_location); |
| 89 void ScheduleNudgeWithPayloads( | 89 void ScheduleNudgeWithPayloads( |
| 90 const base::TimeDelta& delay, NudgeSource source, | 90 const base::TimeDelta& delay, NudgeSource source, |
| 91 const syncable::ModelTypePayloadMap& types_with_payloads, | 91 const syncable::ModelTypePayloadMap& types_with_payloads, |
| 92 const tracked_objects::Location& nudge_location); | 92 const tracked_objects::Location& nudge_location); |
| 93 void ScheduleConfig(const syncable::ModelTypeBitSet& types, | 93 void ScheduleConfig(const syncable::ModelTypeBitSet& types, |
| 94 sync_api::ConfigureReason reason); | 94 sync_api::ConfigureReason reason); |
| 95 void ScheduleClearUserData(); | 95 void ScheduleClearUserData(); |
| 96 void ScheduleCleanupDisabledTypes(); |
| 96 | 97 |
| 97 // Change status of notifications in the SyncSessionContext. | 98 // Change status of notifications in the SyncSessionContext. |
| 98 void set_notifications_enabled(bool notifications_enabled); | 99 void set_notifications_enabled(bool notifications_enabled); |
| 99 | 100 |
| 100 // DDOS avoidance function. Calculates how long we should wait before trying | 101 // DDOS avoidance function. Calculates how long we should wait before trying |
| 101 // again after a failed sync attempt, where the last delay was |base_delay|. | 102 // again after a failed sync attempt, where the last delay was |base_delay|. |
| 102 // TODO(tim): Look at URLRequestThrottlerEntryInterface. | 103 // TODO(tim): Look at URLRequestThrottlerEntryInterface. |
| 103 static base::TimeDelta GetRecommendedDelay(const base::TimeDelta& base_delay); | 104 static base::TimeDelta GetRecommendedDelay(const base::TimeDelta& base_delay); |
| 104 | 105 |
| 105 // SyncSession::Delegate implementation. | 106 // SyncSession::Delegate implementation. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 136 // A nudge task can come from a variety of components needing to force | 137 // A nudge task can come from a variety of components needing to force |
| 137 // a sync. The source is inferable from |session.source()|. | 138 // a sync. The source is inferable from |session.source()|. |
| 138 NUDGE, | 139 NUDGE, |
| 139 // The user invoked a function in the UI to clear their entire account | 140 // The user invoked a function in the UI to clear their entire account |
| 140 // and stop syncing (globally). | 141 // and stop syncing (globally). |
| 141 CLEAR_USER_DATA, | 142 CLEAR_USER_DATA, |
| 142 // Typically used for fetching updates for a subset of the enabled types | 143 // Typically used for fetching updates for a subset of the enabled types |
| 143 // during initial sync or reconfiguration. We don't run all steps of | 144 // during initial sync or reconfiguration. We don't run all steps of |
| 144 // the sync cycle for these (e.g. CleanupDisabledTypes is skipped). | 145 // the sync cycle for these (e.g. CleanupDisabledTypes is skipped). |
| 145 CONFIGURATION, | 146 CONFIGURATION, |
| 147 // The user disabled some types and we have to clean up the data |
| 148 // for those. |
| 149 CLEANUP_DISABLED_TYPES, |
| 146 }; | 150 }; |
| 147 SyncSessionJob(); | 151 SyncSessionJob(); |
| 148 SyncSessionJob(SyncSessionJobPurpose purpose, base::TimeTicks start, | 152 SyncSessionJob(SyncSessionJobPurpose purpose, base::TimeTicks start, |
| 149 linked_ptr<sessions::SyncSession> session, bool is_canary_job, | 153 linked_ptr<sessions::SyncSession> session, bool is_canary_job, |
| 150 const tracked_objects::Location& nudge_location); | 154 const tracked_objects::Location& nudge_location); |
| 151 ~SyncSessionJob(); | 155 ~SyncSessionJob(); |
| 152 static const char* GetPurposeString(SyncSessionJobPurpose purpose); | 156 static const char* GetPurposeString(SyncSessionJobPurpose purpose); |
| 153 | 157 |
| 154 SyncSessionJobPurpose purpose; | 158 SyncSessionJobPurpose purpose; |
| 155 base::TimeTicks scheduled_start; | 159 base::TimeTicks scheduled_start; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 void StartImpl(Mode mode, ModeChangeCallback* callback); | 293 void StartImpl(Mode mode, ModeChangeCallback* callback); |
| 290 void ScheduleNudgeImpl( | 294 void ScheduleNudgeImpl( |
| 291 const base::TimeDelta& delay, | 295 const base::TimeDelta& delay, |
| 292 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, | 296 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, |
| 293 const syncable::ModelTypePayloadMap& types_with_payloads, | 297 const syncable::ModelTypePayloadMap& types_with_payloads, |
| 294 bool is_canary_job, const tracked_objects::Location& nudge_location); | 298 bool is_canary_job, const tracked_objects::Location& nudge_location); |
| 295 void ScheduleConfigImpl(const ModelSafeRoutingInfo& routing_info, | 299 void ScheduleConfigImpl(const ModelSafeRoutingInfo& routing_info, |
| 296 const std::vector<ModelSafeWorker*>& workers, | 300 const std::vector<ModelSafeWorker*>& workers, |
| 297 const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); | 301 const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); |
| 298 void ScheduleClearUserDataImpl(); | 302 void ScheduleClearUserDataImpl(); |
| 303 void ScheduleCleanupDisabledTypesImpl(); |
| 299 | 304 |
| 300 // Returns true if the client is currently in exponential backoff. | 305 // Returns true if the client is currently in exponential backoff. |
| 301 bool IsBackingOff() const; | 306 bool IsBackingOff() const; |
| 302 | 307 |
| 303 // Helper to signal all listeners registered with |session_context_|. | 308 // Helper to signal all listeners registered with |session_context_|. |
| 304 void Notify(SyncEngineEvent::EventCause cause); | 309 void Notify(SyncEngineEvent::EventCause cause); |
| 305 | 310 |
| 306 // Callback to change backoff state. | 311 // Callback to change backoff state. |
| 307 void DoCanaryJob(); | 312 void DoCanaryJob(); |
| 308 void Unthrottle(); | 313 void Unthrottle(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 scoped_ptr<Syncer> syncer_; | 384 scoped_ptr<Syncer> syncer_; |
| 380 | 385 |
| 381 scoped_ptr<sessions::SyncSessionContext> session_context_; | 386 scoped_ptr<sessions::SyncSessionContext> session_context_; |
| 382 | 387 |
| 383 DISALLOW_COPY_AND_ASSIGN(SyncScheduler); | 388 DISALLOW_COPY_AND_ASSIGN(SyncScheduler); |
| 384 }; | 389 }; |
| 385 | 390 |
| 386 } // namespace browser_sync | 391 } // namespace browser_sync |
| 387 | 392 |
| 388 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNC_SCHEDULER_H_ | 393 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNC_SCHEDULER_H_ |
| OLD | NEW |