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 // A class to run the syncer on a thread. | 5 // A class to run the syncer on a thread. |
6 #ifndef CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD2_H_ | 6 #ifndef CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD2_H_ |
7 #define CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD2_H_ | 7 #define CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD2_H_ |
8 #pragma once | 8 #pragma once |
9 | 9 |
10 #include "base/linked_ptr.h" | 10 #include "base/linked_ptr.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 virtual void OnReceivedShortPollIntervalUpdate( | 77 virtual void OnReceivedShortPollIntervalUpdate( |
78 const base::TimeDelta& new_interval); | 78 const base::TimeDelta& new_interval); |
79 virtual void OnReceivedLongPollIntervalUpdate( | 79 virtual void OnReceivedLongPollIntervalUpdate( |
80 const base::TimeDelta& new_interval); | 80 const base::TimeDelta& new_interval); |
81 virtual void OnShouldStopSyncingPermanently(); | 81 virtual void OnShouldStopSyncingPermanently(); |
82 | 82 |
83 private: | 83 private: |
84 friend class SyncerThread2Test; | 84 friend class SyncerThread2Test; |
85 | 85 |
86 // State pertaining to exponential backoff or throttling periods. | 86 // State pertaining to exponential backoff or throttling periods. |
87 struct WaitInterval { | 87 struct WaitInterval; |
88 enum Mode { | |
89 // A wait interval whose duration has been affected by exponential | |
90 // backoff. | |
91 // EXPONENTIAL_BACKOFF intervals are nudge-rate limited to 1 per interval. | |
92 EXPONENTIAL_BACKOFF, | |
93 // A server-initiated throttled interval. We do not allow any syncing | |
94 // during such an interval. | |
95 THROTTLED, | |
96 }; | |
97 Mode mode; | |
98 | |
99 // This bool is set to true if we have observed a nudge during this | |
100 // interval and mode == EXPONENTIAL_BACKOFF. | |
101 bool had_nudge; | |
102 base::TimeDelta length; | |
103 base::OneShotTimer<SyncerThread> timer; | |
104 WaitInterval(Mode mode, base::TimeDelta length); | |
105 }; | |
106 | 88 |
107 // Internal state for every sync task that is scheduled. | 89 // Internal state for every sync task that is scheduled. |
108 struct SyncSessionJob { | 90 struct SyncSessionJob { |
109 // An enum used to describe jobs for scheduling purposes. | 91 // An enum used to describe jobs for scheduling purposes. |
110 enum Purpose { | 92 enum Purpose { |
111 // Our poll timer schedules POLL jobs periodically based on a server | 93 // Our poll timer schedules POLL jobs periodically based on a server |
112 // assigned poll interval. | 94 // assigned poll interval. |
113 POLL, | 95 POLL, |
114 // A nudge task can come from a variety of components needing to force | 96 // A nudge task can come from a variety of components needing to force |
115 // a sync. The source is inferable from |session.source()|. | 97 // a sync. The source is inferable from |session.source()|. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 210 |
229 } // namespace s3 | 211 } // namespace s3 |
230 | 212 |
231 } // namespace browser_sync | 213 } // namespace browser_sync |
232 | 214 |
233 // The SyncerThread manages its own internal thread and thus outlives it. We | 215 // The SyncerThread manages its own internal thread and thus outlives it. We |
234 // don't need refcounting for posting tasks to this internal thread. | 216 // don't need refcounting for posting tasks to this internal thread. |
235 DISABLE_RUNNABLE_METHOD_REFCOUNT(browser_sync::s3::SyncerThread); | 217 DISABLE_RUNNABLE_METHOD_REFCOUNT(browser_sync::s3::SyncerThread); |
236 | 218 |
237 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD2_H_ | 219 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD2_H_ |
OLD | NEW |