| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 enum SyncSessionJobPurpose { | 92 enum SyncSessionJobPurpose { |
| 93 // Uninitialized state, should never be hit in practice. | 93 // Uninitialized state, should never be hit in practice. |
| 94 UNKNOWN = -1, | 94 UNKNOWN = -1, |
| 95 // Our poll timer schedules POLL jobs periodically based on a server | 95 // Our poll timer schedules POLL jobs periodically based on a server |
| 96 // assigned poll interval. | 96 // assigned poll interval. |
| 97 POLL, | 97 POLL, |
| 98 // A nudge task can come from a variety of components needing to force | 98 // A nudge task can come from a variety of components needing to force |
| 99 // a sync. The source is inferable from |session.source()|. | 99 // a sync. The source is inferable from |session.source()|. |
| 100 NUDGE, | 100 NUDGE, |
| 101 // Typically used for fetching updates for a subset of the enabled types | 101 // Typically used for fetching updates for a subset of the enabled types |
| 102 // during initial sync or reconfiguration. We don't run all steps of | 102 // during initial sync or reconfiguration. |
| 103 // the sync cycle for these (e.g. CleanupDisabledTypes is skipped). | |
| 104 CONFIGURATION, | 103 CONFIGURATION, |
| 105 // The user disabled some types and we have to clean up the data | |
| 106 // for those. | |
| 107 CLEANUP_DISABLED_TYPES, | |
| 108 }; | 104 }; |
| 109 SyncSessionJob(); | 105 SyncSessionJob(); |
| 110 SyncSessionJob(SyncSessionJobPurpose purpose, base::TimeTicks start, | 106 SyncSessionJob(SyncSessionJobPurpose purpose, base::TimeTicks start, |
| 111 linked_ptr<sessions::SyncSession> session, bool is_canary_job, | 107 linked_ptr<sessions::SyncSession> session, bool is_canary_job, |
| 112 const ConfigurationParams& config_params, | 108 const ConfigurationParams& config_params, |
| 113 const tracked_objects::Location& nudge_location); | 109 const tracked_objects::Location& nudge_location); |
| 114 ~SyncSessionJob(); | 110 ~SyncSessionJob(); |
| 115 static const char* GetPurposeString(SyncSessionJobPurpose purpose); | 111 static const char* GetPurposeString(SyncSessionJobPurpose purpose); |
| 116 | 112 |
| 117 SyncSessionJobPurpose purpose; | 113 SyncSessionJobPurpose purpose; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // Helper to assemble a job and post a delayed task to sync. | 209 // Helper to assemble a job and post a delayed task to sync. |
| 214 void ScheduleSyncSessionJob(const SyncSessionJob& job); | 210 void ScheduleSyncSessionJob(const SyncSessionJob& job); |
| 215 | 211 |
| 216 // Invoke the Syncer to perform a sync. | 212 // Invoke the Syncer to perform a sync. |
| 217 void DoSyncSessionJob(const SyncSessionJob& job); | 213 void DoSyncSessionJob(const SyncSessionJob& job); |
| 218 | 214 |
| 219 // Called after the Syncer has performed the sync represented by |job|, to | 215 // Called after the Syncer has performed the sync represented by |job|, to |
| 220 // reset our state. | 216 // reset our state. |
| 221 void FinishSyncSessionJob(const SyncSessionJob& job); | 217 void FinishSyncSessionJob(const SyncSessionJob& job); |
| 222 | 218 |
| 223 // Record important state that might be needed in future syncs, such as which | |
| 224 // data types may require cleanup. | |
| 225 void UpdateCarryoverSessionState(const SyncSessionJob& old_job); | |
| 226 | |
| 227 // Helper to FinishSyncSessionJob to schedule the next sync operation. | 219 // Helper to FinishSyncSessionJob to schedule the next sync operation. |
| 228 void ScheduleNextSync(const SyncSessionJob& old_job); | 220 void ScheduleNextSync(const SyncSessionJob& old_job); |
| 229 | 221 |
| 230 // Helper to configure polling intervals. Used by Start and ScheduleNextSync. | 222 // Helper to configure polling intervals. Used by Start and ScheduleNextSync. |
| 231 void AdjustPolling(const SyncSessionJob* old_job); | 223 void AdjustPolling(const SyncSessionJob* old_job); |
| 232 | 224 |
| 233 // Helper to restart waiting with |wait_interval_|'s timer. | 225 // Helper to restart waiting with |wait_interval_|'s timer. |
| 234 void RestartWaiting(); | 226 void RestartWaiting(); |
| 235 | 227 |
| 236 // Helper to ScheduleNextSync in case of consecutive sync errors. | 228 // Helper to ScheduleNextSync in case of consecutive sync errors. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 scoped_ptr<Syncer> syncer_; | 343 scoped_ptr<Syncer> syncer_; |
| 352 | 344 |
| 353 sessions::SyncSessionContext *session_context_; | 345 sessions::SyncSessionContext *session_context_; |
| 354 | 346 |
| 355 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); | 347 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
| 356 }; | 348 }; |
| 357 | 349 |
| 358 } // namespace syncer | 350 } // namespace syncer |
| 359 | 351 |
| 360 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 352 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
| OLD | NEW |