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