| 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 // 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // scheduled tasks from the old mode may still run. | 68 // scheduled tasks from the old mode may still run. |
| 69 virtual void Start(Mode mode) = 0; | 69 virtual void Start(Mode mode) = 0; |
| 70 | 70 |
| 71 // Schedules the configuration task specified by |params|. Returns true if | 71 // Schedules the configuration task specified by |params|. Returns true if |
| 72 // the configuration task executed immediately, false if it had to be | 72 // the configuration task executed immediately, false if it had to be |
| 73 // scheduled for a later attempt. |params.ready_task| is invoked whenever the | 73 // scheduled for a later attempt. |params.ready_task| is invoked whenever the |
| 74 // configuration task executes. | 74 // configuration task executes. |
| 75 // Note: must already be in CONFIGURATION mode. | 75 // Note: must already be in CONFIGURATION mode. |
| 76 virtual bool ScheduleConfiguration(const ConfigurationParams& params) = 0; | 76 virtual bool ScheduleConfiguration(const ConfigurationParams& params) = 0; |
| 77 | 77 |
| 78 // Request that any running syncer task stop as soon as possible and | 78 // Request that the syncer avoid starting any new tasks and prepare for |
| 79 // cancel all scheduled tasks. This function can be called from any thread, | 79 // shutdown. |
| 80 // and should in fact be called from a thread that isn't the sync loop to | 80 virtual void Stop() = 0; |
| 81 // allow preempting ongoing sync cycles. | |
| 82 virtual void RequestStop() = 0; | |
| 83 | 81 |
| 84 // The meat and potatoes. All three of the following methods will post a | 82 // The meat and potatoes. All three of the following methods will post a |
| 85 // delayed task to attempt the actual nudge (see ScheduleNudgeImpl). | 83 // delayed task to attempt the actual nudge (see ScheduleNudgeImpl). |
| 86 // | 84 // |
| 87 // NOTE: |desired_delay| is best-effort. If a nudge is already scheduled to | 85 // NOTE: |desired_delay| is best-effort. If a nudge is already scheduled to |
| 88 // depart earlier than Now() + delay, the scheduler can and will prefer to | 86 // depart earlier than Now() + delay, the scheduler can and will prefer to |
| 89 // batch the two so that only one nudge is sent (at the earlier time). Also, | 87 // batch the two so that only one nudge is sent (at the earlier time). Also, |
| 90 // as always with delayed tasks and timers, it's possible the task gets run | 88 // as always with delayed tasks and timers, it's possible the task gets run |
| 91 // any time after |desired_delay|. | 89 // any time after |desired_delay|. |
| 92 | 90 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 123 // Called when credentials are updated by the user. | 121 // Called when credentials are updated by the user. |
| 124 virtual void OnCredentialsUpdated() = 0; | 122 virtual void OnCredentialsUpdated() = 0; |
| 125 | 123 |
| 126 // Called when the network layer detects a connection status change. | 124 // Called when the network layer detects a connection status change. |
| 127 virtual void OnConnectionStatusChange() = 0; | 125 virtual void OnConnectionStatusChange() = 0; |
| 128 }; | 126 }; |
| 129 | 127 |
| 130 } // namespace syncer | 128 } // namespace syncer |
| 131 | 129 |
| 132 #endif // SYNC_ENGINE_SYNC_SCHEDULER_H_ | 130 #endif // SYNC_ENGINE_SYNC_SCHEDULER_H_ |
| OLD | NEW |