| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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 any running syncer task stop as soon as possible and | 
| 79   // cancel all scheduled tasks. This function can be called from any thread, | 79   // cancel all scheduled tasks. This function can be called from any thread, | 
| 80   // and should in fact be called from a thread that isn't the sync loop to | 80   // and should in fact be called from a thread that isn't the sync loop to | 
| 81   // allow preempting ongoing sync cycles. | 81   // allow preempting ongoing sync cycles. | 
| 82   // Invokes |callback| from the sync loop once syncer is idle and all tasks | 82   // Invokes |callback| from the sync loop once syncer is idle and all tasks | 
| 83   // are cancelled. | 83   // are cancelled. | 
| 84   virtual void RequestStop(const base::Closure& callback) = 0; | 84   virtual void RequestStop(const base::Closure& callback) = 0; | 
| 85 | 85 | 
| 86   // The meat and potatoes. Both of these methods will post a delayed task | 86   // The meat and potatoes. All three of the following methods will post a | 
| 87   // to attempt the actual nudge (see ScheduleNudgeImpl). | 87   // delayed task to attempt the actual nudge (see ScheduleNudgeImpl). | 
|  | 88   // | 
| 88   // NOTE: |desired_delay| is best-effort. If a nudge is already scheduled to | 89   // NOTE: |desired_delay| is best-effort. If a nudge is already scheduled to | 
| 89   // depart earlier than Now() + delay, the scheduler can and will prefer to | 90   // depart earlier than Now() + delay, the scheduler can and will prefer to | 
| 90   // batch the two so that only one nudge is sent (at the earlier time). Also, | 91   // batch the two so that only one nudge is sent (at the earlier time). Also, | 
| 91   // as always with delayed tasks and timers, it's possible the task gets run | 92   // as always with delayed tasks and timers, it's possible the task gets run | 
| 92   // any time after |desired_delay|. | 93   // any time after |desired_delay|. | 
| 93   virtual void ScheduleNudgeAsync( | 94 | 
|  | 95   // The LocalNudge indicates that we've made a local change, and that the | 
|  | 96   // syncer should plan to commit this to the server some time soon. | 
|  | 97   virtual void ScheduleLocalNudge( | 
| 94       const base::TimeDelta& desired_delay, | 98       const base::TimeDelta& desired_delay, | 
| 95       NudgeSource source, |  | 
| 96       ModelTypeSet types, | 99       ModelTypeSet types, | 
| 97       const tracked_objects::Location& nudge_location) = 0; | 100       const tracked_objects::Location& nudge_location) = 0; | 
| 98   virtual void ScheduleNudgeWithStatesAsync( | 101 | 
| 99       const base::TimeDelta& desired_delay, NudgeSource source, | 102   // The LocalRefreshRequest occurs when we decide for some reason to manually | 
|  | 103   // request updates.  This should be used sparingly.  For example, one of its | 
|  | 104   // uses is to fetch the latest tab sync data when it's relevant to the UI on | 
|  | 105   // platforms where tab sync is not registered for invalidations. | 
|  | 106   virtual void ScheduleLocalRefreshRequest( | 
|  | 107       const base::TimeDelta& desired_delay, | 
|  | 108       ModelTypeSet types, | 
|  | 109       const tracked_objects::Location& nudge_location) = 0; | 
|  | 110 | 
|  | 111   // Invalidations are notifications the server sends to let us know when other | 
|  | 112   // clients have committed data.  We need to contact the sync server (being | 
|  | 113   // careful to pass along the "hints" delivered with those invalidations) in | 
|  | 114   // order to fetch the update. | 
|  | 115   virtual void ScheduleInvalidationNudge( | 
|  | 116       const base::TimeDelta& desired_delay, | 
| 100       const ModelTypeInvalidationMap& invalidation_map, | 117       const ModelTypeInvalidationMap& invalidation_map, | 
| 101       const tracked_objects::Location& nudge_location) = 0; | 118       const tracked_objects::Location& nudge_location) = 0; | 
| 102 | 119 | 
| 103   // Change status of notifications in the SyncSessionContext. | 120   // Change status of notifications in the SyncSessionContext. | 
| 104   virtual void SetNotificationsEnabled(bool notifications_enabled) = 0; | 121   virtual void SetNotificationsEnabled(bool notifications_enabled) = 0; | 
| 105 | 122 | 
| 106   virtual base::TimeDelta GetSessionsCommitDelay() const = 0; | 123   virtual base::TimeDelta GetSessionsCommitDelay() const = 0; | 
| 107 | 124 | 
| 108   // Called when credentials are updated by the user. | 125   // Called when credentials are updated by the user. | 
| 109   virtual void OnCredentialsUpdated() = 0; | 126   virtual void OnCredentialsUpdated() = 0; | 
| 110 | 127 | 
| 111   // Called when the network layer detects a connection status change. | 128   // Called when the network layer detects a connection status change. | 
| 112   virtual void OnConnectionStatusChange() = 0; | 129   virtual void OnConnectionStatusChange() = 0; | 
| 113 }; | 130 }; | 
| 114 | 131 | 
| 115 }  // namespace syncer | 132 }  // namespace syncer | 
| 116 | 133 | 
| 117 #endif  // SYNC_ENGINE_SYNC_SCHEDULER_H_ | 134 #endif  // SYNC_ENGINE_SYNC_SCHEDULER_H_ | 
| OLD | NEW | 
|---|