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 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 // configuration task executes. | 97 // configuration task executes. |
| 98 // Note: must already be in CONFIGURATION mode. | 98 // Note: must already be in CONFIGURATION mode. |
| 99 virtual bool ScheduleConfiguration(const ConfigurationParams& params); | 99 virtual bool ScheduleConfiguration(const ConfigurationParams& params); |
| 100 | 100 |
| 101 // Request that any running syncer task stop as soon as possible and | 101 // Request that any running syncer task stop as soon as possible and |
| 102 // cancel all scheduled tasks. This function can be called from any thread, | 102 // cancel all scheduled tasks. This function can be called from any thread, |
| 103 // and should in fact be called from a thread that isn't the sync loop to | 103 // and should in fact be called from a thread that isn't the sync loop to |
| 104 // allow preempting ongoing sync cycles. | 104 // allow preempting ongoing sync cycles. |
| 105 // Invokes |callback| from the sync loop once syncer is idle and all tasks | 105 // Invokes |callback| from the sync loop once syncer is idle and all tasks |
| 106 // are cancelled. | 106 // are cancelled. |
| 107 void RequestStop(const base::Closure& callback); | 107 virtual void RequestStop(const base::Closure& callback); |
|
Nicolas Zea
2012/07/18 21:10:12
Do I dare wonder if this should be an interface?
| |
| 108 | 108 |
| 109 // The meat and potatoes. Both of these methods will post a delayed task | 109 // The meat and potatoes. Both of these methods will post a delayed task |
| 110 // to attempt the actual nudge (see ScheduleNudgeImpl). | 110 // to attempt the actual nudge (see ScheduleNudgeImpl). |
| 111 void ScheduleNudgeAsync(const base::TimeDelta& delay, NudgeSource source, | 111 virtual void ScheduleNudgeAsync( |
| 112 syncer::ModelTypeSet types, | 112 const base::TimeDelta& delay, |
| 113 const tracked_objects::Location& nudge_location); | 113 NudgeSource source, |
| 114 void ScheduleNudgeWithPayloadsAsync( | 114 syncer::ModelTypeSet types, |
| 115 const tracked_objects::Location& nudge_location); | |
| 116 virtual void ScheduleNudgeWithPayloadsAsync( | |
| 115 const base::TimeDelta& delay, NudgeSource source, | 117 const base::TimeDelta& delay, NudgeSource source, |
| 116 const syncer::ModelTypePayloadMap& types_with_payloads, | 118 const syncer::ModelTypePayloadMap& types_with_payloads, |
| 117 const tracked_objects::Location& nudge_location); | 119 const tracked_objects::Location& nudge_location); |
| 118 | 120 |
| 119 void CleanupDisabledTypes(); | |
| 120 | |
| 121 // Change status of notifications in the SyncSessionContext. | 121 // Change status of notifications in the SyncSessionContext. |
| 122 void set_notifications_enabled(bool notifications_enabled); | 122 virtual void SetNotificationsEnabled(bool notifications_enabled); |
| 123 | 123 |
| 124 base::TimeDelta sessions_commit_delay() const; | 124 base::TimeDelta sessions_commit_delay() const; |
| 125 | 125 |
| 126 // DDOS avoidance function. Calculates how long we should wait before trying | 126 // DDOS avoidance function. Calculates how long we should wait before trying |
| 127 // again after a failed sync attempt, where the last delay was |base_delay|. | 127 // again after a failed sync attempt, where the last delay was |base_delay|. |
| 128 // TODO(tim): Look at URLRequestThrottlerEntryInterface. | 128 // TODO(tim): Look at URLRequestThrottlerEntryInterface. |
| 129 static base::TimeDelta GetRecommendedDelay(const base::TimeDelta& base_delay); | 129 static base::TimeDelta GetRecommendedDelay(const base::TimeDelta& base_delay); |
| 130 | 130 |
| 131 // Called when credentials are updated by the user. | 131 // Called when credentials are updated by the user. |
| 132 void OnCredentialsUpdated(); | 132 void OnCredentialsUpdated(); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 422 scoped_ptr<Syncer> syncer_; | 422 scoped_ptr<Syncer> syncer_; |
| 423 | 423 |
| 424 sessions::SyncSessionContext *session_context_; | 424 sessions::SyncSessionContext *session_context_; |
| 425 | 425 |
| 426 DISALLOW_COPY_AND_ASSIGN(SyncScheduler); | 426 DISALLOW_COPY_AND_ASSIGN(SyncScheduler); |
| 427 }; | 427 }; |
| 428 | 428 |
| 429 } // namespace syncer | 429 } // namespace syncer |
| 430 | 430 |
| 431 #endif // SYNC_ENGINE_SYNC_SCHEDULER_H_ | 431 #endif // SYNC_ENGINE_SYNC_SCHEDULER_H_ |
| OLD | NEW |