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 #ifndef SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 5 #ifndef SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
6 #define SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 6 #define SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
18 #include "base/time.h" | 18 #include "base/time.h" |
19 #include "base/timer.h" | 19 #include "base/timer.h" |
20 #include "sync/engine/net/server_connection_manager.h" | 20 #include "sync/engine/net/server_connection_manager.h" |
21 #include "sync/engine/nudge_source.h" | 21 #include "sync/engine/nudge_source.h" |
22 #include "sync/engine/sync_scheduler.h" | 22 #include "sync/engine/sync_scheduler.h" |
| 23 #include "sync/engine/sync_session_job.h" |
23 #include "sync/engine/syncer.h" | 24 #include "sync/engine/syncer.h" |
24 #include "sync/internal_api/public/base/model_type_invalidation_map.h" | 25 #include "sync/internal_api/public/base/model_type_invalidation_map.h" |
25 #include "sync/internal_api/public/engine/polling_constants.h" | 26 #include "sync/internal_api/public/engine/polling_constants.h" |
26 #include "sync/internal_api/public/util/weak_handle.h" | 27 #include "sync/internal_api/public/util/weak_handle.h" |
27 #include "sync/sessions/sync_session.h" | 28 #include "sync/sessions/sync_session.h" |
28 #include "sync/sessions/sync_session_context.h" | 29 #include "sync/sessions/sync_session_context.h" |
29 | 30 |
30 namespace syncer { | 31 namespace syncer { |
31 | 32 |
32 class BackoffDelayProvider; | 33 class BackoffDelayProvider; |
33 | 34 |
34 class SyncSchedulerImpl : public SyncScheduler { | 35 class SyncSchedulerImpl : public SyncScheduler { |
35 public: | 36 public: |
36 // |name| is a display string to identify the syncer thread. Takes | 37 // |name| is a display string to identify the syncer thread. Takes |
37 // |ownership of |syncer| and |delay_provider|. | 38 // |ownership of |syncer| and |delay_provider|. |
38 SyncSchedulerImpl(const std::string& name, | 39 SyncSchedulerImpl(const std::string& name, |
39 BackoffDelayProvider* delay_provider, | 40 BackoffDelayProvider* delay_provider, |
40 sessions::SyncSessionContext* context, | 41 sessions::SyncSessionContext* context, |
41 Syncer* syncer); | 42 Syncer* syncer); |
42 | 43 |
43 // Calls Stop(). | 44 // Calls Stop(). |
44 virtual ~SyncSchedulerImpl(); | 45 virtual ~SyncSchedulerImpl(); |
45 | 46 |
46 virtual void Start(Mode mode) OVERRIDE; | 47 virtual void Start(Mode mode) OVERRIDE; |
47 virtual bool ScheduleConfiguration( | 48 virtual bool ScheduleConfiguration( |
48 const ConfigurationParams& params) OVERRIDE; | 49 const ConfigurationParams& params) OVERRIDE; |
49 virtual void RequestStop(const base::Closure& callback) OVERRIDE; | 50 virtual void RequestStop(const base::Closure& callback) OVERRIDE; |
50 virtual void ScheduleNudgeAsync( | 51 virtual void ScheduleNudgeAsync( |
51 const base::TimeDelta& delay, | 52 const base::TimeDelta& desired_delay, |
52 NudgeSource source, | 53 NudgeSource source, |
53 ModelTypeSet types, | 54 ModelTypeSet types, |
54 const tracked_objects::Location& nudge_location) OVERRIDE; | 55 const tracked_objects::Location& nudge_location) OVERRIDE; |
55 virtual void ScheduleNudgeWithStatesAsync( | 56 virtual void ScheduleNudgeWithStatesAsync( |
56 const base::TimeDelta& delay, NudgeSource source, | 57 const base::TimeDelta& desired_delay, NudgeSource source, |
57 const ModelTypeInvalidationMap& invalidation_map, | 58 const ModelTypeInvalidationMap& invalidation_map, |
58 const tracked_objects::Location& nudge_location) OVERRIDE; | 59 const tracked_objects::Location& nudge_location) OVERRIDE; |
59 virtual void SetNotificationsEnabled(bool notifications_enabled) OVERRIDE; | 60 virtual void SetNotificationsEnabled(bool notifications_enabled) OVERRIDE; |
60 | 61 |
61 virtual base::TimeDelta GetSessionsCommitDelay() const OVERRIDE; | 62 virtual base::TimeDelta GetSessionsCommitDelay() const OVERRIDE; |
62 | 63 |
63 virtual void OnCredentialsUpdated() OVERRIDE; | 64 virtual void OnCredentialsUpdated() OVERRIDE; |
64 virtual void OnConnectionStatusChange() OVERRIDE; | 65 virtual void OnConnectionStatusChange() OVERRIDE; |
65 | 66 |
66 // SyncSession::Delegate implementation. | 67 // SyncSession::Delegate implementation. |
(...skipping 13 matching lines...) Expand all Loading... |
80 private: | 81 private: |
81 enum JobProcessDecision { | 82 enum JobProcessDecision { |
82 // Indicates we should continue with the current job. | 83 // Indicates we should continue with the current job. |
83 CONTINUE, | 84 CONTINUE, |
84 // Indicates that we should save it to be processed later. | 85 // Indicates that we should save it to be processed later. |
85 SAVE, | 86 SAVE, |
86 // Indicates we should drop this job. | 87 // Indicates we should drop this job. |
87 DROP, | 88 DROP, |
88 }; | 89 }; |
89 | 90 |
90 struct SyncSessionJob { | |
91 // An enum used to describe jobs for scheduling purposes. | |
92 enum SyncSessionJobPurpose { | |
93 // Uninitialized state, should never be hit in practice. | |
94 UNKNOWN = -1, | |
95 // Our poll timer schedules POLL jobs periodically based on a server | |
96 // assigned poll interval. | |
97 POLL, | |
98 // A nudge task can come from a variety of components needing to force | |
99 // a sync. The source is inferable from |session.source()|. | |
100 NUDGE, | |
101 // Typically used for fetching updates for a subset of the enabled types | |
102 // during initial sync or reconfiguration. | |
103 CONFIGURATION, | |
104 }; | |
105 SyncSessionJob(); | |
106 SyncSessionJob(SyncSessionJobPurpose purpose, base::TimeTicks start, | |
107 linked_ptr<sessions::SyncSession> session, bool is_canary_job, | |
108 const ConfigurationParams& config_params, | |
109 const tracked_objects::Location& nudge_location); | |
110 ~SyncSessionJob(); | |
111 static const char* GetPurposeString(SyncSessionJobPurpose purpose); | |
112 | |
113 SyncSessionJobPurpose purpose; | |
114 base::TimeTicks scheduled_start; | |
115 linked_ptr<sessions::SyncSession> session; | |
116 bool is_canary_job; | |
117 ConfigurationParams config_params; | |
118 | |
119 // This is the location the job came from. Used for debugging. | |
120 // In case of multiple nudges getting coalesced this stores the | |
121 // first location that came in. | |
122 tracked_objects::Location from_here; | |
123 }; | |
124 friend class SyncSchedulerTest; | 91 friend class SyncSchedulerTest; |
125 friend class SyncSchedulerWhiteboxTest; | 92 friend class SyncSchedulerWhiteboxTest; |
126 friend class SyncerTest; | 93 friend class SyncerTest; |
127 | 94 |
128 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | 95 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, |
129 DropNudgeWhileExponentialBackOff); | 96 DropNudgeWhileExponentialBackOff); |
130 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, SaveNudge); | 97 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, SaveNudge); |
131 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | 98 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, |
132 SaveNudgeWhileTypeThrottled); | 99 SaveNudgeWhileTypeThrottled); |
133 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinueNudge); | 100 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinueNudge); |
134 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, DropPoll); | 101 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, DropPoll); |
135 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinuePoll); | 102 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinuePoll); |
136 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinueConfiguration); | 103 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinueConfiguration); |
137 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | 104 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, |
138 SaveConfigurationWhileThrottled); | 105 SaveConfigurationWhileThrottled); |
139 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | 106 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, |
140 SaveNudgeWhileThrottled); | 107 SaveNudgeWhileThrottled); |
141 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | 108 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, |
142 ContinueCanaryJobConfig); | 109 ContinueCanaryJobConfig); |
143 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | 110 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, |
144 ContinueNudgeWhileExponentialBackOff); | 111 ContinueNudgeWhileExponentialBackOff); |
145 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, TransientPollFailure); | 112 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, TransientPollFailure); |
146 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, GetInitialBackoffDelay); | 113 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, GetInitialBackoffDelay); |
| 114 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, |
| 115 ServerConnectionChangeDuringBackoff); |
147 | 116 |
148 struct WaitInterval { | 117 struct WaitInterval { |
149 enum Mode { | 118 enum Mode { |
150 // Uninitialized state, should not be set in practice. | 119 // Uninitialized state, should not be set in practice. |
151 UNKNOWN = -1, | 120 UNKNOWN = -1, |
152 // A wait interval whose duration has been affected by exponential | 121 // A wait interval whose duration has been affected by exponential |
153 // backoff. | 122 // backoff. |
154 // EXPONENTIAL_BACKOFF intervals are nudge-rate limited to 1 per interval. | 123 // EXPONENTIAL_BACKOFF intervals are nudge-rate limited to 1 per interval. |
155 EXPONENTIAL_BACKOFF, | 124 EXPONENTIAL_BACKOFF, |
156 // A server-initiated throttled interval. We do not allow any syncing | 125 // A server-initiated throttled interval. We do not allow any syncing |
157 // during such an interval. | 126 // during such an interval. |
158 THROTTLED, | 127 THROTTLED, |
159 }; | 128 }; |
160 WaitInterval(); | 129 WaitInterval(); |
161 ~WaitInterval(); | 130 ~WaitInterval(); |
162 WaitInterval(Mode mode, base::TimeDelta length); | 131 WaitInterval(Mode mode, base::TimeDelta length); |
163 | 132 |
164 static const char* GetModeString(Mode mode); | 133 static const char* GetModeString(Mode mode); |
165 | 134 |
166 Mode mode; | 135 Mode mode; |
167 | 136 |
168 // This bool is set to true if we have observed a nudge during this | 137 // This bool is set to true if we have observed a nudge during this |
169 // interval and mode == EXPONENTIAL_BACKOFF. | 138 // interval and mode == EXPONENTIAL_BACKOFF. |
170 bool had_nudge; | 139 bool had_nudge; |
171 base::TimeDelta length; | 140 base::TimeDelta length; |
172 base::OneShotTimer<SyncSchedulerImpl> timer; | 141 base::OneShotTimer<SyncSchedulerImpl> timer; |
173 | 142 |
174 // Configure jobs are saved only when backing off or throttling. So we | 143 // Configure jobs are saved only when backing off or throttling. So we |
175 // expose the pointer here. | 144 // expose the pointer here (does not own, similar to pending_nudge). |
176 scoped_ptr<SyncSessionJob> pending_configure_job; | 145 SyncSessionJob* pending_configure_job; |
177 }; | 146 }; |
178 | 147 |
179 static const char* GetModeString(Mode mode); | 148 static const char* GetModeString(Mode mode); |
180 | 149 |
181 static const char* GetDecisionString(JobProcessDecision decision); | 150 static const char* GetDecisionString(JobProcessDecision decision); |
182 | 151 |
183 // Assign |start| and |end| to appropriate SyncerStep values for the | |
184 // specified |purpose|. | |
185 static void SetSyncerStepsForPurpose( | |
186 SyncSessionJob::SyncSessionJobPurpose purpose, | |
187 SyncerStep* start, SyncerStep* end); | |
188 | |
189 // Helpers that log before posting to |sync_loop_|. These will only post | 152 // Helpers that log before posting to |sync_loop_|. These will only post |
190 // the task in between calls to Start/Stop. | 153 // the task in between calls to Start/Stop. |
191 void PostTask(const tracked_objects::Location& from_here, | 154 void PostTask(const tracked_objects::Location& from_here, |
192 const char* name, | 155 const char* name, |
193 const base::Closure& task); | 156 const base::Closure& task); |
194 void PostDelayedTask(const tracked_objects::Location& from_here, | 157 void PostDelayedTask(const tracked_objects::Location& from_here, |
195 const char* name, | 158 const char* name, |
196 const base::Closure& task, | 159 const base::Closure& task, |
197 base::TimeDelta delay); | 160 base::TimeDelta delay); |
198 | 161 |
199 // Helper to assemble a job and post a delayed task to sync. | 162 // Helper to assemble a job and post a delayed task to sync. |
200 void ScheduleSyncSessionJob(const SyncSessionJob& job); | 163 void ScheduleSyncSessionJob(scoped_ptr<SyncSessionJob> job); |
201 | 164 |
202 // Invoke the Syncer to perform a sync. | 165 // Invoke the Syncer to perform a sync. |
203 void DoSyncSessionJob(const SyncSessionJob& job); | 166 bool DoSyncSessionJob(scoped_ptr<SyncSessionJob> job); |
204 | 167 |
205 // Called after the Syncer has performed the sync represented by |job|, to | 168 // Called after the Syncer has performed the sync represented by |job|, to |
206 // reset our state. | 169 // reset our state. |exited_prematurely| is true if the Syncer did not |
207 void FinishSyncSessionJob(const SyncSessionJob& job); | 170 // cycle from job.start_step() to job.end_step(), likely because the |
| 171 // scheduler was forced to quit the job mid-way through. |
| 172 bool FinishSyncSessionJob(scoped_ptr<SyncSessionJob> job, |
| 173 bool exited_prematurely); |
208 | 174 |
209 // Helper to FinishSyncSessionJob to schedule the next sync operation. | 175 // Helper to FinishSyncSessionJob to schedule the next sync operation. |
210 void ScheduleNextSync(const SyncSessionJob& old_job); | 176 // |succeeded| carries the return value of |old_job|->Finish. |
| 177 void ScheduleNextSync(scoped_ptr<SyncSessionJob> finished_job, |
| 178 bool succeeded); |
211 | 179 |
212 // Helper to configure polling intervals. Used by Start and ScheduleNextSync. | 180 // Helper to configure polling intervals. Used by Start and ScheduleNextSync. |
213 void AdjustPolling(const SyncSessionJob* old_job); | 181 void AdjustPolling(const SyncSessionJob* old_job); |
214 | 182 |
215 // Helper to restart waiting with |wait_interval_|'s timer. | 183 // Helper to restart waiting with |wait_interval_|'s timer. |
216 void RestartWaiting(); | 184 void RestartWaiting(scoped_ptr<SyncSessionJob> job); |
217 | 185 |
218 // Helper to ScheduleNextSync in case of consecutive sync errors. | 186 // Helper to ScheduleNextSync in case of consecutive sync errors. |
219 void HandleContinuationError(const SyncSessionJob& old_job); | 187 void HandleContinuationError(scoped_ptr<SyncSessionJob> old_job); |
220 | |
221 // Determines if it is legal to run |job| by checking current | |
222 // operational mode, backoff or throttling, freshness | |
223 // (so we don't make redundant syncs), and connection. | |
224 bool ShouldRunJob(const SyncSessionJob& job); | |
225 | 188 |
226 // Decide whether we should CONTINUE, SAVE or DROP the job. | 189 // Decide whether we should CONTINUE, SAVE or DROP the job. |
227 JobProcessDecision DecideOnJob(const SyncSessionJob& job); | 190 JobProcessDecision DecideOnJob(const SyncSessionJob& job); |
228 | 191 |
| 192 // If DecideOnJob decides that |job| should be SAVEd, this function will |
| 193 // carry out the task of actually "saving" (or coalescing) the job. |
| 194 void HandleSaveJobDecision(scoped_ptr<SyncSessionJob> job); |
| 195 |
229 // Decide on whether to CONTINUE, SAVE or DROP the job when we are in | 196 // Decide on whether to CONTINUE, SAVE or DROP the job when we are in |
230 // backoff mode. | 197 // backoff mode. |
231 JobProcessDecision DecideWhileInWaitInterval(const SyncSessionJob& job); | 198 JobProcessDecision DecideWhileInWaitInterval(const SyncSessionJob& job); |
232 | 199 |
233 // Saves the job for future execution. Note: It drops all the poll jobs. | |
234 void SaveJob(const SyncSessionJob& job); | |
235 | |
236 // Coalesces the current job with the pending nudge. | |
237 void InitOrCoalescePendingJob(const SyncSessionJob& job); | |
238 | |
239 // 'Impl' here refers to real implementation of public functions, running on | 200 // 'Impl' here refers to real implementation of public functions, running on |
240 // |thread_|. | 201 // |thread_|. |
241 void StopImpl(const base::Closure& callback); | 202 void StopImpl(const base::Closure& callback); |
242 void ScheduleNudgeImpl( | 203 void ScheduleNudgeImpl( |
243 const base::TimeDelta& delay, | 204 const base::TimeDelta& delay, |
244 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, | 205 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, |
245 const ModelTypeInvalidationMap& invalidation_map, | 206 const ModelTypeInvalidationMap& invalidation_map, |
246 bool is_canary_job, const tracked_objects::Location& nudge_location); | 207 const tracked_objects::Location& nudge_location); |
247 | 208 |
248 // Returns true if the client is currently in exponential backoff. | 209 // Returns true if the client is currently in exponential backoff. |
249 bool IsBackingOff() const; | 210 bool IsBackingOff() const; |
250 | 211 |
251 // Helper to signal all listeners registered with |session_context_|. | 212 // Helper to signal all listeners registered with |session_context_|. |
252 void Notify(SyncEngineEvent::EventCause cause); | 213 void Notify(SyncEngineEvent::EventCause cause); |
253 | 214 |
254 // Callback to change backoff state. | 215 // Callback to change backoff state. |to_be_canary| in both cases is the job |
255 void DoCanaryJob(); | 216 // that should be granted canary privileges. Note: it is possible that the |
256 void Unthrottle(); | 217 // job that gets scheduled when this callback is scheduled is different from |
| 218 // the job that will actually get executed, because other jobs may have been |
| 219 // scheduled while we were waiting for the callback. |
| 220 void DoCanaryJob(scoped_ptr<SyncSessionJob> to_be_canary); |
| 221 void Unthrottle(scoped_ptr<SyncSessionJob> to_be_canary); |
257 | 222 |
258 // Executes the pending job. Called whenever an event occurs that may | 223 // Returns a pending job that has potential to run given the state of the |
259 // change conditions permitting a job to run. Like when network connection is | 224 // scheduler, if it exists. Useful whenever an event occurs that may |
260 // re-established, mode changes etc. | 225 // change conditions that permit a job to run, such as re-establishing |
261 void DoPendingJobIfPossible(bool is_canary_job); | 226 // network connection, auth refresh, mode changes etc. Note that the returned |
| 227 // job may have been scheduled to run at a later time, or may have been |
| 228 // unscheduled. In the former case, this will result in abandoning the old |
| 229 // job and effectively cancelling it. |
| 230 scoped_ptr<SyncSessionJob> TakePendingJobForCurrentMode(); |
262 | 231 |
263 // Called when the root cause of the current connection error is fixed. | 232 // Called when the root cause of the current connection error is fixed. |
264 void OnServerConnectionErrorFixed(); | 233 void OnServerConnectionErrorFixed(); |
265 | 234 |
266 // The pointer is owned by the caller. | 235 scoped_ptr<sessions::SyncSession> CreateSyncSession( |
267 sessions::SyncSession* CreateSyncSession( | |
268 const sessions::SyncSourceInfo& info); | 236 const sessions::SyncSourceInfo& info); |
269 | 237 |
270 // Creates a session for a poll and performs the sync. | 238 // Creates a session for a poll and performs the sync. |
271 void PollTimerCallback(); | 239 void PollTimerCallback(); |
272 | 240 |
273 // Used to update |connection_code_|, see below. | 241 // Used to update |connection_code_|, see below. |
274 void UpdateServerConnectionManagerStatus( | 242 void UpdateServerConnectionManagerStatus( |
275 HttpResponse::ServerConnectionCode code); | 243 HttpResponse::ServerConnectionCode code); |
276 | 244 |
277 // Called once the first time thread_ is started to broadcast an initial | 245 // Called once the first time thread_ is started to broadcast an initial |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 | 284 |
317 // Periodic timer for polling. See AdjustPolling. | 285 // Periodic timer for polling. See AdjustPolling. |
318 base::RepeatingTimer<SyncSchedulerImpl> poll_timer_; | 286 base::RepeatingTimer<SyncSchedulerImpl> poll_timer_; |
319 | 287 |
320 // The mode of operation. | 288 // The mode of operation. |
321 Mode mode_; | 289 Mode mode_; |
322 | 290 |
323 // The latest connection code we got while trying to connect. | 291 // The latest connection code we got while trying to connect. |
324 HttpResponse::ServerConnectionCode connection_code_; | 292 HttpResponse::ServerConnectionCode connection_code_; |
325 | 293 |
326 // Tracks in-flight nudges so we can coalesce. | 294 // Tracks (does not own) in-flight nudges (scheduled or unscheduled), |
327 scoped_ptr<SyncSessionJob> pending_nudge_; | 295 // so we can coalesce. NULL if there is no pending nudge. |
| 296 SyncSessionJob* pending_nudge_; |
| 297 |
| 298 // There are certain situations where we want to remember a nudge, but |
| 299 // there is no well defined moment in time in the future when that nudge |
| 300 // should run, e.g. if it requires a mode switch or updated auth credentials. |
| 301 // This member will own NUDGE jobs in those cases, until an external event |
| 302 // (mode switch or fixed auth) occurs to trigger a retry. Should be treated |
| 303 // as opaque / not interacted with (i.e. we could build a wrapper to |
| 304 // hide the type, but that's probably overkill). |
| 305 scoped_ptr<SyncSessionJob> unscheduled_nudge_storage_; |
328 | 306 |
329 // Current wait state. Null if we're not in backoff and not throttled. | 307 // Current wait state. Null if we're not in backoff and not throttled. |
330 scoped_ptr<WaitInterval> wait_interval_; | 308 scoped_ptr<WaitInterval> wait_interval_; |
331 | 309 |
332 scoped_ptr<BackoffDelayProvider> delay_provider_; | 310 scoped_ptr<BackoffDelayProvider> delay_provider_; |
333 | 311 |
334 // Invoked to run through the sync cycle. | 312 // Invoked to run through the sync cycle. |
335 scoped_ptr<Syncer> syncer_; | 313 scoped_ptr<Syncer> syncer_; |
336 | 314 |
337 sessions::SyncSessionContext* session_context_; | 315 sessions::SyncSessionContext* session_context_; |
(...skipping 10 matching lines...) Expand all Loading... |
348 // take place during a sync cycle. We call this out because such violations | 326 // take place during a sync cycle. We call this out because such violations |
349 // could result in tight sync loops hitting sync servers. | 327 // could result in tight sync loops hitting sync servers. |
350 bool no_scheduling_allowed_; | 328 bool no_scheduling_allowed_; |
351 | 329 |
352 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); | 330 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
353 }; | 331 }; |
354 | 332 |
355 } // namespace syncer | 333 } // namespace syncer |
356 | 334 |
357 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 335 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
OLD | NEW |