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. | 102 // during initial sync or reconfiguration. We don't run all steps of |
| 103 // the sync cycle for these (e.g. CleanupDisabledTypes is skipped). |
103 CONFIGURATION, | 104 CONFIGURATION, |
| 105 // The user disabled some types and we have to clean up the data |
| 106 // for those. |
| 107 CLEANUP_DISABLED_TYPES, |
104 }; | 108 }; |
105 SyncSessionJob(); | 109 SyncSessionJob(); |
106 SyncSessionJob(SyncSessionJobPurpose purpose, base::TimeTicks start, | 110 SyncSessionJob(SyncSessionJobPurpose purpose, base::TimeTicks start, |
107 linked_ptr<sessions::SyncSession> session, bool is_canary_job, | 111 linked_ptr<sessions::SyncSession> session, bool is_canary_job, |
108 const ConfigurationParams& config_params, | 112 const ConfigurationParams& config_params, |
109 const tracked_objects::Location& nudge_location); | 113 const tracked_objects::Location& nudge_location); |
110 ~SyncSessionJob(); | 114 ~SyncSessionJob(); |
111 static const char* GetPurposeString(SyncSessionJobPurpose purpose); | 115 static const char* GetPurposeString(SyncSessionJobPurpose purpose); |
112 | 116 |
113 SyncSessionJobPurpose purpose; | 117 SyncSessionJobPurpose purpose; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // Helper to assemble a job and post a delayed task to sync. | 213 // Helper to assemble a job and post a delayed task to sync. |
210 void ScheduleSyncSessionJob(const SyncSessionJob& job); | 214 void ScheduleSyncSessionJob(const SyncSessionJob& job); |
211 | 215 |
212 // Invoke the Syncer to perform a sync. | 216 // Invoke the Syncer to perform a sync. |
213 void DoSyncSessionJob(const SyncSessionJob& job); | 217 void DoSyncSessionJob(const SyncSessionJob& job); |
214 | 218 |
215 // Called after the Syncer has performed the sync represented by |job|, to | 219 // Called after the Syncer has performed the sync represented by |job|, to |
216 // reset our state. | 220 // reset our state. |
217 void FinishSyncSessionJob(const SyncSessionJob& job); | 221 void FinishSyncSessionJob(const SyncSessionJob& job); |
218 | 222 |
| 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 |
219 // Helper to FinishSyncSessionJob to schedule the next sync operation. | 227 // Helper to FinishSyncSessionJob to schedule the next sync operation. |
220 void ScheduleNextSync(const SyncSessionJob& old_job); | 228 void ScheduleNextSync(const SyncSessionJob& old_job); |
221 | 229 |
222 // Helper to configure polling intervals. Used by Start and ScheduleNextSync. | 230 // Helper to configure polling intervals. Used by Start and ScheduleNextSync. |
223 void AdjustPolling(const SyncSessionJob* old_job); | 231 void AdjustPolling(const SyncSessionJob* old_job); |
224 | 232 |
225 // Helper to restart waiting with |wait_interval_|'s timer. | 233 // Helper to restart waiting with |wait_interval_|'s timer. |
226 void RestartWaiting(); | 234 void RestartWaiting(); |
227 | 235 |
228 // Helper to ScheduleNextSync in case of consecutive sync errors. | 236 // Helper to ScheduleNextSync in case of consecutive sync errors. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 scoped_ptr<Syncer> syncer_; | 351 scoped_ptr<Syncer> syncer_; |
344 | 352 |
345 sessions::SyncSessionContext *session_context_; | 353 sessions::SyncSessionContext *session_context_; |
346 | 354 |
347 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); | 355 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
348 }; | 356 }; |
349 | 357 |
350 } // namespace syncer | 358 } // namespace syncer |
351 | 359 |
352 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 360 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
OLD | NEW |