Chromium Code Reviews| 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 // A class to schedule syncer tasks intelligently. | 5 // A class to schedule syncer tasks intelligently. |
| 6 #ifndef SYNC_ENGINE_SYNC_SCHEDULER_H_ | 6 #ifndef SYNC_ENGINE_SYNC_SCHEDULER_H_ |
| 7 #define SYNC_ENGINE_SYNC_SCHEDULER_H_ | 7 #define SYNC_ENGINE_SYNC_SCHEDULER_H_ |
| 8 #pragma once | 8 #pragma once |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 void ScheduleNudge(const base::TimeDelta& delay, NudgeSource source, | 80 void ScheduleNudge(const base::TimeDelta& delay, NudgeSource source, |
| 81 syncable::ModelTypeSet types, | 81 syncable::ModelTypeSet types, |
| 82 const tracked_objects::Location& nudge_location); | 82 const tracked_objects::Location& nudge_location); |
| 83 void ScheduleNudgeWithPayloads( | 83 void ScheduleNudgeWithPayloads( |
| 84 const base::TimeDelta& delay, NudgeSource source, | 84 const base::TimeDelta& delay, NudgeSource source, |
| 85 const syncable::ModelTypePayloadMap& types_with_payloads, | 85 const syncable::ModelTypePayloadMap& types_with_payloads, |
| 86 const tracked_objects::Location& nudge_location); | 86 const tracked_objects::Location& nudge_location); |
| 87 | 87 |
| 88 // Note: The source argument of this function must come from the subset of | 88 // Note: The source argument of this function must come from the subset of |
| 89 // GetUpdatesCallerInfo values related to configurations. | 89 // GetUpdatesCallerInfo values related to configurations. |
| 90 void ScheduleConfig( | 90 void Configure( |
|
tim (not reviewing)
2012/06/11 20:06:13
I'm not sure about this rename -- it is still up t
Nicolas Zea
2012/06/11 20:55:09
Done.
| |
| 91 syncable::ModelTypeSet types, | 91 syncable::ModelTypeSet types, |
| 92 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); | 92 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); |
| 93 | 93 |
| 94 void ScheduleClearUserData(); | 94 void ClearUserData(); |
| 95 // If this is called before Start(), the cleanup is guaranteed to | 95 |
| 96 // happen before the Start finishes. | 96 void CleanupDisabledTypes(); |
|
tim (not reviewing)
2012/06/11 20:06:13
nit - You can add a TODO here for me and note bug
Nicolas Zea
2012/06/11 20:55:09
Done.
| |
| 97 // | |
| 98 // TODO(akalin): Figure out how to test this. | |
| 99 void ScheduleCleanupDisabledTypes(); | |
| 100 | 97 |
| 101 // Change status of notifications in the SyncSessionContext. | 98 // Change status of notifications in the SyncSessionContext. |
| 102 void set_notifications_enabled(bool notifications_enabled); | 99 void set_notifications_enabled(bool notifications_enabled); |
| 103 | 100 |
| 104 base::TimeDelta sessions_commit_delay() const; | 101 base::TimeDelta sessions_commit_delay() const; |
| 105 | 102 |
| 106 // DDOS avoidance function. Calculates how long we should wait before trying | 103 // DDOS avoidance function. Calculates how long we should wait before trying |
| 107 // again after a failed sync attempt, where the last delay was |base_delay|. | 104 // again after a failed sync attempt, where the last delay was |base_delay|. |
| 108 // TODO(tim): Look at URLRequestThrottlerEntryInterface. | 105 // TODO(tim): Look at URLRequestThrottlerEntryInterface. |
| 109 static base::TimeDelta GetRecommendedDelay(const base::TimeDelta& base_delay); | 106 static base::TimeDelta GetRecommendedDelay(const base::TimeDelta& base_delay); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 JobProcessDecision DecideWhileInWaitInterval(const SyncSessionJob& job); | 300 JobProcessDecision DecideWhileInWaitInterval(const SyncSessionJob& job); |
| 304 | 301 |
| 305 // Saves the job for future execution. Note: It drops all the poll jobs. | 302 // Saves the job for future execution. Note: It drops all the poll jobs. |
| 306 void SaveJob(const SyncSessionJob& job); | 303 void SaveJob(const SyncSessionJob& job); |
| 307 | 304 |
| 308 // Coalesces the current job with the pending nudge. | 305 // Coalesces the current job with the pending nudge. |
| 309 void InitOrCoalescePendingJob(const SyncSessionJob& job); | 306 void InitOrCoalescePendingJob(const SyncSessionJob& job); |
| 310 | 307 |
| 311 // 'Impl' here refers to real implementation of public functions, running on | 308 // 'Impl' here refers to real implementation of public functions, running on |
| 312 // |thread_|. | 309 // |thread_|. |
| 313 void StartImpl(Mode mode, const base::Closure& callback); | |
| 314 void StopImpl(const base::Closure& callback); | 310 void StopImpl(const base::Closure& callback); |
| 315 void ScheduleNudgeImpl( | 311 void ScheduleNudgeImpl( |
| 316 const base::TimeDelta& delay, | 312 const base::TimeDelta& delay, |
| 317 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, | 313 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, |
| 318 const syncable::ModelTypePayloadMap& types_with_payloads, | 314 const syncable::ModelTypePayloadMap& types_with_payloads, |
| 319 bool is_canary_job, const tracked_objects::Location& nudge_location); | 315 bool is_canary_job, const tracked_objects::Location& nudge_location); |
| 320 void ScheduleConfigImpl(const ModelSafeRoutingInfo& routing_info, | |
| 321 const std::vector<ModelSafeWorker*>& workers, | |
| 322 const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); | |
| 323 void ScheduleClearUserDataImpl(); | |
| 324 | 316 |
| 325 // Returns true if the client is currently in exponential backoff. | 317 // Returns true if the client is currently in exponential backoff. |
| 326 bool IsBackingOff() const; | 318 bool IsBackingOff() const; |
| 327 | 319 |
| 328 // Helper to signal all listeners registered with |session_context_|. | 320 // Helper to signal all listeners registered with |session_context_|. |
| 329 void Notify(SyncEngineEvent::EventCause cause); | 321 void Notify(SyncEngineEvent::EventCause cause); |
| 330 | 322 |
| 331 // Callback to change backoff state. | 323 // Callback to change backoff state. |
| 332 void DoCanaryJob(); | 324 void DoCanaryJob(); |
| 333 void Unthrottle(); | 325 void Unthrottle(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 scoped_ptr<Syncer> syncer_; | 402 scoped_ptr<Syncer> syncer_; |
| 411 | 403 |
| 412 sessions::SyncSessionContext *session_context_; | 404 sessions::SyncSessionContext *session_context_; |
| 413 | 405 |
| 414 DISALLOW_COPY_AND_ASSIGN(SyncScheduler); | 406 DISALLOW_COPY_AND_ASSIGN(SyncScheduler); |
| 415 }; | 407 }; |
| 416 | 408 |
| 417 } // namespace browser_sync | 409 } // namespace browser_sync |
| 418 | 410 |
| 419 #endif // SYNC_ENGINE_SYNC_SCHEDULER_H_ | 411 #endif // SYNC_ENGINE_SYNC_SCHEDULER_H_ |
| OLD | NEW |