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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 const base::Closure& task); | 164 const base::Closure& task); |
165 void PostDelayedTask(const tracked_objects::Location& from_here, | 165 void PostDelayedTask(const tracked_objects::Location& from_here, |
166 const char* name, | 166 const char* name, |
167 const base::Closure& task, | 167 const base::Closure& task, |
168 base::TimeDelta delay); | 168 base::TimeDelta delay); |
169 | 169 |
170 // Helper to assemble a job and post a delayed task to sync. | 170 // Helper to assemble a job and post a delayed task to sync. |
171 void ScheduleSyncSessionJob(scoped_ptr<SyncSessionJob> job); | 171 void ScheduleSyncSessionJob(scoped_ptr<SyncSessionJob> job); |
172 | 172 |
173 // Invoke the Syncer to perform a sync. | 173 // Invoke the Syncer to perform a sync. |
174 bool DoSyncSessionJob(scoped_ptr<SyncSessionJob> job); | 174 bool DoSyncSessionJob(scoped_ptr<SyncSessionJob> job, bool is_canary); |
175 | 175 |
176 // Called after the Syncer has performed the sync represented by |job|, to | 176 // Called after the Syncer has performed the sync represented by |job|, to |
177 // reset our state. |exited_prematurely| is true if the Syncer did not | 177 // reset our state. |exited_prematurely| is true if the Syncer did not |
178 // cycle from job.start_step() to job.end_step(), likely because the | 178 // cycle from job.start_step() to job.end_step(), likely because the |
179 // scheduler was forced to quit the job mid-way through. | 179 // scheduler was forced to quit the job mid-way through. |
180 bool FinishSyncSessionJob(scoped_ptr<SyncSessionJob> job, | 180 bool FinishSyncSessionJob(scoped_ptr<SyncSessionJob> job, |
181 bool exited_prematurely); | 181 bool exited_prematurely); |
182 | 182 |
183 // Helper to FinishSyncSessionJob to schedule the next sync operation. | 183 // Helper to FinishSyncSessionJob to schedule the next sync operation. |
184 // |succeeded| carries the return value of |old_job|->Finish. | 184 // |succeeded| carries the return value of |old_job|->Finish. |
185 void ScheduleNextSync(scoped_ptr<SyncSessionJob> finished_job, | 185 void ScheduleNextSync(scoped_ptr<SyncSessionJob> finished_job, |
186 bool succeeded); | 186 bool succeeded); |
187 | 187 |
188 // Helper to configure polling intervals. Used by Start and ScheduleNextSync. | 188 // Helper to configure polling intervals. Used by Start and ScheduleNextSync. |
189 void AdjustPolling(const SyncSessionJob* old_job); | 189 void AdjustPolling(const SyncSessionJob* old_job); |
190 | 190 |
191 // Helper to restart waiting with |wait_interval_|'s timer. | 191 // Helper to restart waiting with |wait_interval_|'s timer. |
192 void RestartWaiting(scoped_ptr<SyncSessionJob> job); | 192 void RestartWaiting(scoped_ptr<SyncSessionJob> job); |
193 | 193 |
194 // Helper to ScheduleNextSync in case of consecutive sync errors. | 194 // Helper to ScheduleNextSync in case of consecutive sync errors. |
195 void HandleContinuationError(scoped_ptr<SyncSessionJob> old_job); | 195 void HandleContinuationError(scoped_ptr<SyncSessionJob> old_job); |
196 | 196 |
197 // Decide whether we should CONTINUE, SAVE or DROP the job. | 197 // Decide whether we should CONTINUE, SAVE or DROP the job. |
198 JobProcessDecision DecideOnJob(const SyncSessionJob& job); | 198 JobProcessDecision DecideOnJob(const SyncSessionJob& job, bool is_canary); |
199 | 199 |
200 // If DecideOnJob decides that |job| should be SAVEd, this function will | 200 // If DecideOnJob decides that |job| should be SAVEd, this function will |
201 // carry out the task of actually "saving" (or coalescing) the job. | 201 // carry out the task of actually "saving" (or coalescing) the job. |
202 void HandleSaveJobDecision(scoped_ptr<SyncSessionJob> job); | 202 void HandleSaveJobDecision(scoped_ptr<SyncSessionJob> job); |
203 | 203 |
204 // Decide on whether to CONTINUE, SAVE or DROP the job when we are in | 204 // Decide on whether to CONTINUE, SAVE or DROP the job when we are in |
205 // backoff mode. | 205 // backoff mode. |
206 JobProcessDecision DecideWhileInWaitInterval(const SyncSessionJob& job); | 206 JobProcessDecision DecideWhileInWaitInterval(const SyncSessionJob& job, |
| 207 bool is_canary); |
207 | 208 |
208 // 'Impl' here refers to real implementation of public functions, running on | 209 // 'Impl' here refers to real implementation of public functions, running on |
209 // |thread_|. | 210 // |thread_|. |
210 void StopImpl(const base::Closure& callback); | 211 void StopImpl(const base::Closure& callback); |
211 void ScheduleNudgeImpl( | 212 void ScheduleNudgeImpl( |
212 const base::TimeDelta& delay, | 213 const base::TimeDelta& delay, |
213 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, | 214 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, |
214 const ModelTypeInvalidationMap& invalidation_map, | 215 const ModelTypeInvalidationMap& invalidation_map, |
215 const tracked_objects::Location& nudge_location); | 216 const tracked_objects::Location& nudge_location); |
216 | 217 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 // 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 |
340 // could result in tight sync loops hitting sync servers. | 341 // could result in tight sync loops hitting sync servers. |
341 bool no_scheduling_allowed_; | 342 bool no_scheduling_allowed_; |
342 | 343 |
343 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); | 344 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
344 }; | 345 }; |
345 | 346 |
346 } // namespace syncer | 347 } // namespace syncer |
347 | 348 |
348 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 349 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
OLD | NEW |