| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 const base::Closure& task); | 166 const base::Closure& task); |
| 167 void PostDelayedTask(const tracked_objects::Location& from_here, | 167 void PostDelayedTask(const tracked_objects::Location& from_here, |
| 168 const char* name, | 168 const char* name, |
| 169 const base::Closure& task, | 169 const base::Closure& task, |
| 170 base::TimeDelta delay); | 170 base::TimeDelta delay); |
| 171 | 171 |
| 172 // Helper to assemble a job and post a delayed task to sync. | 172 // Helper to assemble a job and post a delayed task to sync. |
| 173 void ScheduleSyncSessionJob(const tracked_objects::Location& loc, | 173 void ScheduleSyncSessionJob(const tracked_objects::Location& loc, |
| 174 scoped_ptr<SyncSessionJob> job); | 174 scoped_ptr<SyncSessionJob> job); |
| 175 | 175 |
| 176 // Invoke the Syncer to perform a sync. | 176 // Invoke the Syncer to perform a non-poll job. |
| 177 bool DoSyncSessionJob(scoped_ptr<SyncSessionJob> job, | 177 bool DoSyncSessionJob(scoped_ptr<SyncSessionJob> job, |
| 178 JobPriority priority); | 178 JobPriority priority); |
| 179 | 179 |
| 180 // Returns whether or not it's safe to run a poll job at this time. |
| 181 bool DecideOnPollJob(); |
| 182 |
| 183 // Invoke the Syncer to perform a poll job. |
| 184 void DoPollSyncSessionJob(scoped_ptr<SyncSessionJob> job); |
| 185 |
| 180 // Called after the Syncer has performed the sync represented by |job|, to | 186 // Called after the Syncer has performed the sync represented by |job|, to |
| 181 // reset our state. |exited_prematurely| is true if the Syncer did not | 187 // reset our state. |exited_prematurely| is true if the Syncer did not |
| 182 // cycle from job.start_step() to job.end_step(), likely because the | 188 // cycle from job.start_step() to job.end_step(), likely because the |
| 183 // scheduler was forced to quit the job mid-way through. | 189 // scheduler was forced to quit the job mid-way through. |
| 184 bool FinishSyncSessionJob(scoped_ptr<SyncSessionJob> job, | 190 bool FinishSyncSessionJob(SyncSessionJob* job, |
| 185 bool exited_prematurely); | 191 bool exited_prematurely); |
| 186 | 192 |
| 187 // Helper to FinishSyncSessionJob to schedule the next sync operation. | 193 // Helper to schedule retries of a failed configure or nudge job. |
| 188 // |succeeded| carries the return value of |old_job|->Finish. | 194 void ScheduleNextSync(scoped_ptr<SyncSessionJob> finished_job); |
| 189 void ScheduleNextSync(scoped_ptr<SyncSessionJob> finished_job, | |
| 190 bool succeeded); | |
| 191 | 195 |
| 192 // Helper to configure polling intervals. Used by Start and ScheduleNextSync. | 196 // Helper to configure polling intervals. Used by Start and ScheduleNextSync. |
| 193 void AdjustPolling(const SyncSessionJob* old_job); | 197 void AdjustPolling(const SyncSessionJob* old_job); |
| 194 | 198 |
| 195 // Helper to restart waiting with |wait_interval_|'s timer. | 199 // Helper to restart waiting with |wait_interval_|'s timer. |
| 196 void RestartWaiting(scoped_ptr<SyncSessionJob> job); | 200 void RestartWaiting(scoped_ptr<SyncSessionJob> job); |
| 197 | 201 |
| 198 // Helper to ScheduleNextSync in case of consecutive sync errors. | 202 // Helper to ScheduleNextSync in case of consecutive sync errors. |
| 199 void HandleContinuationError(scoped_ptr<SyncSessionJob> old_job); | 203 void HandleContinuationError(scoped_ptr<SyncSessionJob> old_job); |
| 200 | 204 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 // take place during a sync cycle. We call this out because such violations | 340 // take place during a sync cycle. We call this out because such violations |
| 337 // could result in tight sync loops hitting sync servers. | 341 // could result in tight sync loops hitting sync servers. |
| 338 bool no_scheduling_allowed_; | 342 bool no_scheduling_allowed_; |
| 339 | 343 |
| 340 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); | 344 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
| 341 }; | 345 }; |
| 342 | 346 |
| 343 } // namespace syncer | 347 } // namespace syncer |
| 344 | 348 |
| 345 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 349 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
| OLD | NEW |