OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/sync/engine/syncer_thread2.h" | 5 #include "chrome/browser/sync/engine/syncer_thread2.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "chrome/browser/sync/engine/syncer.h" | 10 #include "chrome/browser/sync/engine/syncer.h" |
11 | 11 |
12 using base::TimeDelta; | 12 using base::TimeDelta; |
13 using base::TimeTicks; | 13 using base::TimeTicks; |
14 | 14 |
15 namespace browser_sync { | 15 namespace browser_sync { |
16 | 16 |
17 using sessions::SyncSession; | 17 using sessions::SyncSession; |
18 using sessions::SyncSessionSnapshot; | 18 using sessions::SyncSessionSnapshot; |
19 using sessions::SyncSourceInfo; | 19 using sessions::SyncSourceInfo; |
20 using syncable::ModelTypeBitSet; | 20 using syncable::ModelTypeBitSet; |
21 using sync_pb::GetUpdatesCallerInfo; | 21 using sync_pb::GetUpdatesCallerInfo; |
22 | 22 |
23 namespace s3 { | 23 namespace s3 { |
24 | 24 |
| 25 struct SyncerThread::WaitInterval { |
| 26 enum Mode { |
| 27 // A wait interval whose duration has been affected by exponential |
| 28 // backoff. |
| 29 // EXPONENTIAL_BACKOFF intervals are nudge-rate limited to 1 per interval. |
| 30 EXPONENTIAL_BACKOFF, |
| 31 // A server-initiated throttled interval. We do not allow any syncing |
| 32 // during such an interval. |
| 33 THROTTLED, |
| 34 }; |
| 35 Mode mode; |
| 36 |
| 37 // This bool is set to true if we have observed a nudge during this |
| 38 // interval and mode == EXPONENTIAL_BACKOFF. |
| 39 bool had_nudge; |
| 40 base::TimeDelta length; |
| 41 base::OneShotTimer<SyncerThread> timer; |
| 42 WaitInterval(Mode mode, base::TimeDelta length); |
| 43 }; |
| 44 |
25 SyncerThread::DelayProvider::DelayProvider() {} | 45 SyncerThread::DelayProvider::DelayProvider() {} |
26 SyncerThread::DelayProvider::~DelayProvider() {} | 46 SyncerThread::DelayProvider::~DelayProvider() {} |
27 | 47 |
28 TimeDelta SyncerThread::DelayProvider::GetDelay( | 48 TimeDelta SyncerThread::DelayProvider::GetDelay( |
29 const base::TimeDelta& last_delay) { | 49 const base::TimeDelta& last_delay) { |
30 return SyncerThread::GetRecommendedDelay(last_delay); | 50 return SyncerThread::GetRecommendedDelay(last_delay); |
31 } | 51 } |
32 | 52 |
33 SyncerThread::WaitInterval::WaitInterval(Mode mode, TimeDelta length) | 53 SyncerThread::WaitInterval::WaitInterval(Mode mode, TimeDelta length) |
34 : mode(mode), had_nudge(false), length(length) { } | 54 : mode(mode), had_nudge(false), length(length) { } |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 const ServerConnectionEvent& event) { | 509 const ServerConnectionEvent& event) { |
490 NOTIMPLEMENTED(); | 510 NOTIMPLEMENTED(); |
491 } | 511 } |
492 | 512 |
493 void SyncerThread::set_notifications_enabled(bool notifications_enabled) { | 513 void SyncerThread::set_notifications_enabled(bool notifications_enabled) { |
494 session_context_->set_notifications_enabled(notifications_enabled); | 514 session_context_->set_notifications_enabled(notifications_enabled); |
495 } | 515 } |
496 | 516 |
497 } // s3 | 517 } // s3 |
498 } // browser_sync | 518 } // browser_sync |
OLD | NEW |