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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 linked_ptr<sessions::SyncSession> session; | 172 linked_ptr<sessions::SyncSession> session; |
173 bool is_canary_job; | 173 bool is_canary_job; |
174 | 174 |
175 // This is the location the job came from. Used for debugging. | 175 // This is the location the job came from. Used for debugging. |
176 // In case of multiple nudges getting coalesced this stores the | 176 // In case of multiple nudges getting coalesced this stores the |
177 // first location that came in. | 177 // first location that came in. |
178 tracked_objects::Location from_here; | 178 tracked_objects::Location from_here; |
179 }; | 179 }; |
180 friend class SyncSchedulerTest; | 180 friend class SyncSchedulerTest; |
181 friend class SyncSchedulerWhiteboxTest; | 181 friend class SyncSchedulerWhiteboxTest; |
182 friend class SyncerTest; | |
183 | 182 |
184 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | 183 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, |
185 DropNudgeWhileExponentialBackOff); | 184 DropNudgeWhileExponentialBackOff); |
186 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, SaveNudge); | 185 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, SaveNudge); |
187 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | 186 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, |
188 SaveNudgeWhileTypeThrottled); | 187 SaveNudgeWhileTypeThrottled); |
189 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinueNudge); | 188 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinueNudge); |
190 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, DropPoll); | 189 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, DropPoll); |
191 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinuePoll); | 190 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinuePoll); |
192 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinueConfiguration); | 191 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinueConfiguration); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 240 |
242 // Configure jobs are saved only when backing off or throttling. So we | 241 // Configure jobs are saved only when backing off or throttling. So we |
243 // expose the pointer here. | 242 // expose the pointer here. |
244 scoped_ptr<SyncSessionJob> pending_configure_job; | 243 scoped_ptr<SyncSessionJob> pending_configure_job; |
245 }; | 244 }; |
246 | 245 |
247 static const char* GetModeString(Mode mode); | 246 static const char* GetModeString(Mode mode); |
248 | 247 |
249 static const char* GetDecisionString(JobProcessDecision decision); | 248 static const char* GetDecisionString(JobProcessDecision decision); |
250 | 249 |
251 // Assign |start| and |end| to appropriate SyncerStep values for the | |
252 // specified |purpose|. | |
253 static void SetSyncerStepsForPurpose( | |
254 SyncSessionJob::SyncSessionJobPurpose purpose, | |
255 SyncerStep* start, SyncerStep* end); | |
256 | |
257 // Helpers that log before posting to |sync_loop_|. These will only post | 250 // Helpers that log before posting to |sync_loop_|. These will only post |
258 // the task in between calls to Start/Stop. | 251 // the task in between calls to Start/Stop. |
259 void PostTask(const tracked_objects::Location& from_here, | 252 void PostTask(const tracked_objects::Location& from_here, |
260 const char* name, | 253 const char* name, |
261 const base::Closure& task); | 254 const base::Closure& task); |
262 void PostDelayedTask(const tracked_objects::Location& from_here, | 255 void PostDelayedTask(const tracked_objects::Location& from_here, |
263 const char* name, | 256 const char* name, |
264 const base::Closure& task, | 257 const base::Closure& task, |
265 base::TimeDelta delay); | 258 base::TimeDelta delay); |
266 | 259 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 // Called when the root cause of the current connection error is fixed. | 333 // Called when the root cause of the current connection error is fixed. |
341 void OnServerConnectionErrorFixed(); | 334 void OnServerConnectionErrorFixed(); |
342 | 335 |
343 // The pointer is owned by the caller. | 336 // The pointer is owned by the caller. |
344 browser_sync::sessions::SyncSession* CreateSyncSession( | 337 browser_sync::sessions::SyncSession* CreateSyncSession( |
345 const browser_sync::sessions::SyncSourceInfo& info); | 338 const browser_sync::sessions::SyncSourceInfo& info); |
346 | 339 |
347 // Creates a session for a poll and performs the sync. | 340 // Creates a session for a poll and performs the sync. |
348 void PollTimerCallback(); | 341 void PollTimerCallback(); |
349 | 342 |
| 343 // Assign |start| and |end| to appropriate SyncerStep values for the |
| 344 // specified |purpose|. |
| 345 void SetSyncerStepsForPurpose(SyncSessionJob::SyncSessionJobPurpose purpose, |
| 346 SyncerStep* start, |
| 347 SyncerStep* end); |
| 348 |
350 // Used to update |connection_code_|, see below. | 349 // Used to update |connection_code_|, see below. |
351 void UpdateServerConnectionManagerStatus( | 350 void UpdateServerConnectionManagerStatus( |
352 HttpResponse::ServerConnectionCode code); | 351 HttpResponse::ServerConnectionCode code); |
353 | 352 |
354 // Called once the first time thread_ is started to broadcast an initial | 353 // Called once the first time thread_ is started to broadcast an initial |
355 // session snapshot containing data like initial_sync_ended. Important when | 354 // session snapshot containing data like initial_sync_ended. Important when |
356 // the client starts up and does not need to perform an initial sync. | 355 // the client starts up and does not need to perform an initial sync. |
357 void SendInitialSnapshot(); | 356 void SendInitialSnapshot(); |
358 | 357 |
359 virtual void OnActionableError(const sessions::SyncSessionSnapshot& snapshot); | 358 virtual void OnActionableError(const sessions::SyncSessionSnapshot& snapshot); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 scoped_ptr<Syncer> syncer_; | 409 scoped_ptr<Syncer> syncer_; |
411 | 410 |
412 scoped_ptr<sessions::SyncSessionContext> session_context_; | 411 scoped_ptr<sessions::SyncSessionContext> session_context_; |
413 | 412 |
414 DISALLOW_COPY_AND_ASSIGN(SyncScheduler); | 413 DISALLOW_COPY_AND_ASSIGN(SyncScheduler); |
415 }; | 414 }; |
416 | 415 |
417 } // namespace browser_sync | 416 } // namespace browser_sync |
418 | 417 |
419 #endif // SYNC_ENGINE_SYNC_SCHEDULER_H_ | 418 #endif // SYNC_ENGINE_SYNC_SCHEDULER_H_ |
OLD | NEW |