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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 | 339 |
340 // Creates a session for a poll and performs the sync. | 340 // Creates a session for a poll and performs the sync. |
341 void PollTimerCallback(); | 341 void PollTimerCallback(); |
342 | 342 |
343 // Assign |start| and |end| to appropriate SyncerStep values for the | 343 // Assign |start| and |end| to appropriate SyncerStep values for the |
344 // specified |purpose|. | 344 // specified |purpose|. |
345 void SetSyncerStepsForPurpose(SyncSessionJob::SyncSessionJobPurpose purpose, | 345 void SetSyncerStepsForPurpose(SyncSessionJob::SyncSessionJobPurpose purpose, |
346 SyncerStep* start, | 346 SyncerStep* start, |
347 SyncerStep* end); | 347 SyncerStep* end); |
348 | 348 |
349 // Used to update |server_connection_ok_|, see below. | 349 // Used to update |connection_code_|, see below. |
350 void UpdateServerConnectionManagerStatus( | 350 void UpdateServerConnectionManagerStatus( |
351 HttpResponse::ServerConnectionCode code); | 351 HttpResponse::ServerConnectionCode code); |
352 | 352 |
353 // 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 |
354 // session snapshot containing data like initial_sync_ended. Important when | 354 // session snapshot containing data like initial_sync_ended. Important when |
355 // 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. |
356 void SendInitialSnapshot(); | 356 void SendInitialSnapshot(); |
357 | 357 |
358 virtual void OnActionableError(const sessions::SyncSessionSnapshot& snapshot); | 358 virtual void OnActionableError(const sessions::SyncSessionSnapshot& snapshot); |
359 | 359 |
(...skipping 27 matching lines...) Expand all Loading... |
387 // Periodic timer for polling. See AdjustPolling. | 387 // Periodic timer for polling. See AdjustPolling. |
388 base::RepeatingTimer<SyncScheduler> poll_timer_; | 388 base::RepeatingTimer<SyncScheduler> poll_timer_; |
389 | 389 |
390 // The mode of operation. | 390 // The mode of operation. |
391 Mode mode_; | 391 Mode mode_; |
392 | 392 |
393 // TODO(tim): Bug 26339. This needs to track more than just time I think, | 393 // TODO(tim): Bug 26339. This needs to track more than just time I think, |
394 // since the nudges could be for different types. Current impl doesn't care. | 394 // since the nudges could be for different types. Current impl doesn't care. |
395 base::TimeTicks last_sync_session_end_time_; | 395 base::TimeTicks last_sync_session_end_time_; |
396 | 396 |
397 // Have we observed a valid server connection? | |
398 bool server_connection_ok_; | |
399 | |
400 // The latest connection code we got while trying to connect. | 397 // The latest connection code we got while trying to connect. |
401 HttpResponse::ServerConnectionCode connection_code_; | 398 HttpResponse::ServerConnectionCode connection_code_; |
402 | 399 |
403 // Tracks in-flight nudges so we can coalesce. | 400 // Tracks in-flight nudges so we can coalesce. |
404 scoped_ptr<SyncSessionJob> pending_nudge_; | 401 scoped_ptr<SyncSessionJob> pending_nudge_; |
405 | 402 |
406 // Current wait state. Null if we're not in backoff and not throttled. | 403 // Current wait state. Null if we're not in backoff and not throttled. |
407 scoped_ptr<WaitInterval> wait_interval_; | 404 scoped_ptr<WaitInterval> wait_interval_; |
408 | 405 |
409 scoped_ptr<DelayProvider> delay_provider_; | 406 scoped_ptr<DelayProvider> delay_provider_; |
410 | 407 |
411 // Invoked to run through the sync cycle. | 408 // Invoked to run through the sync cycle. |
412 scoped_ptr<Syncer> syncer_; | 409 scoped_ptr<Syncer> syncer_; |
413 | 410 |
414 scoped_ptr<sessions::SyncSessionContext> session_context_; | 411 scoped_ptr<sessions::SyncSessionContext> session_context_; |
415 | 412 |
416 DISALLOW_COPY_AND_ASSIGN(SyncScheduler); | 413 DISALLOW_COPY_AND_ASSIGN(SyncScheduler); |
417 }; | 414 }; |
418 | 415 |
419 } // namespace browser_sync | 416 } // namespace browser_sync |
420 | 417 |
421 #endif // SYNC_ENGINE_SYNC_SCHEDULER_H_ | 418 #endif // SYNC_ENGINE_SYNC_SCHEDULER_H_ |
OLD | NEW |