| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // cancel all scheduled tasks. This function can be called from any thread, | 72 // cancel all scheduled tasks. This function can be called from any thread, |
| 73 // and should in fact be called from a thread that isn't the sync loop to | 73 // and should in fact be called from a thread that isn't the sync loop to |
| 74 // allow preempting ongoing sync cycles. | 74 // allow preempting ongoing sync cycles. |
| 75 // Invokes |callback| from the sync loop once syncer is idle and all tasks | 75 // Invokes |callback| from the sync loop once syncer is idle and all tasks |
| 76 // are cancelled. | 76 // are cancelled. |
| 77 void RequestStop(const base::Closure& callback); | 77 void RequestStop(const base::Closure& callback); |
| 78 | 78 |
| 79 // The meat and potatoes. Both of these methods will post a delayed task | 79 // The meat and potatoes. Both of these methods will post a delayed task |
| 80 // to attempt the actual nudge (see ScheduleNudgeImpl). | 80 // to attempt the actual nudge (see ScheduleNudgeImpl). |
| 81 void ScheduleNudgeAsync(const base::TimeDelta& delay, NudgeSource source, | 81 void ScheduleNudgeAsync(const base::TimeDelta& delay, NudgeSource source, |
| 82 syncable::ModelTypeSet types, | 82 syncer::ModelTypeSet types, |
| 83 const tracked_objects::Location& nudge_location); | 83 const tracked_objects::Location& nudge_location); |
| 84 void ScheduleNudgeWithPayloadsAsync( | 84 void ScheduleNudgeWithPayloadsAsync( |
| 85 const base::TimeDelta& delay, NudgeSource source, | 85 const base::TimeDelta& delay, NudgeSource source, |
| 86 const syncable::ModelTypePayloadMap& types_with_payloads, | 86 const syncer::ModelTypePayloadMap& types_with_payloads, |
| 87 const tracked_objects::Location& nudge_location); | 87 const tracked_objects::Location& nudge_location); |
| 88 | 88 |
| 89 // Schedule a configuration cycle. May execute immediately or at a later time | 89 // Schedule a configuration cycle. May execute immediately or at a later time |
| 90 // (depending on backoff/throttle state). | 90 // (depending on backoff/throttle state). |
| 91 // Note: The source argument of this function must come from the subset of | 91 // Note: The source argument of this function must come from the subset of |
| 92 // GetUpdatesCallerInfo values related to configurations. | 92 // GetUpdatesCallerInfo values related to configurations. |
| 93 void ScheduleConfiguration( | 93 void ScheduleConfiguration( |
| 94 syncable::ModelTypeSet types, | 94 syncer::ModelTypeSet types, |
| 95 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); | 95 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); |
| 96 | 96 |
| 97 void CleanupDisabledTypes(); | 97 void CleanupDisabledTypes(); |
| 98 | 98 |
| 99 // Change status of notifications in the SyncSessionContext. | 99 // Change status of notifications in the SyncSessionContext. |
| 100 void set_notifications_enabled(bool notifications_enabled); | 100 void set_notifications_enabled(bool notifications_enabled); |
| 101 | 101 |
| 102 base::TimeDelta sessions_commit_delay() const; | 102 base::TimeDelta sessions_commit_delay() const; |
| 103 | 103 |
| 104 // DDOS avoidance function. Calculates how long we should wait before trying | 104 // DDOS avoidance function. Calculates how long we should wait before trying |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 | 300 |
| 301 // Coalesces the current job with the pending nudge. | 301 // Coalesces the current job with the pending nudge. |
| 302 void InitOrCoalescePendingJob(const SyncSessionJob& job); | 302 void InitOrCoalescePendingJob(const SyncSessionJob& job); |
| 303 | 303 |
| 304 // 'Impl' here refers to real implementation of public functions, running on | 304 // 'Impl' here refers to real implementation of public functions, running on |
| 305 // |thread_|. | 305 // |thread_|. |
| 306 void StopImpl(const base::Closure& callback); | 306 void StopImpl(const base::Closure& callback); |
| 307 void ScheduleNudgeImpl( | 307 void ScheduleNudgeImpl( |
| 308 const base::TimeDelta& delay, | 308 const base::TimeDelta& delay, |
| 309 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, | 309 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, |
| 310 const syncable::ModelTypePayloadMap& types_with_payloads, | 310 const syncer::ModelTypePayloadMap& types_with_payloads, |
| 311 bool is_canary_job, const tracked_objects::Location& nudge_location); | 311 bool is_canary_job, const tracked_objects::Location& nudge_location); |
| 312 | 312 |
| 313 // Returns true if the client is currently in exponential backoff. | 313 // Returns true if the client is currently in exponential backoff. |
| 314 bool IsBackingOff() const; | 314 bool IsBackingOff() const; |
| 315 | 315 |
| 316 // Helper to signal all listeners registered with |session_context_|. | 316 // Helper to signal all listeners registered with |session_context_|. |
| 317 void Notify(SyncEngineEvent::EventCause cause); | 317 void Notify(SyncEngineEvent::EventCause cause); |
| 318 | 318 |
| 319 // Callback to change backoff state. | 319 // Callback to change backoff state. |
| 320 void DoCanaryJob(); | 320 void DoCanaryJob(); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 scoped_ptr<Syncer> syncer_; | 398 scoped_ptr<Syncer> syncer_; |
| 399 | 399 |
| 400 sessions::SyncSessionContext *session_context_; | 400 sessions::SyncSessionContext *session_context_; |
| 401 | 401 |
| 402 DISALLOW_COPY_AND_ASSIGN(SyncScheduler); | 402 DISALLOW_COPY_AND_ASSIGN(SyncScheduler); |
| 403 }; | 403 }; |
| 404 | 404 |
| 405 } // namespace syncer | 405 } // namespace syncer |
| 406 | 406 |
| 407 #endif // SYNC_ENGINE_SYNC_SCHEDULER_H_ | 407 #endif // SYNC_ENGINE_SYNC_SCHEDULER_H_ |
| OLD | NEW |