| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // This is the default implementation of SyncerThread whose Stop implementation | 6 // This is the default implementation of SyncerThread whose Stop implementation |
| 7 // does not support a timeout, but is greatly simplified. | 7 // does not support a timeout, but is greatly simplified. |
| 8 #ifndef CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD_H_ | 8 #ifndef CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD_H_ |
| 9 #define CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD_H_ | 9 #define CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD_H_ |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 public ChannelEventHandler<SyncerEvent> { | 50 public ChannelEventHandler<SyncerEvent> { |
| 51 FRIEND_TEST_ALL_PREFIXES(SyncerThreadTest, CalculateSyncWaitTime); | 51 FRIEND_TEST_ALL_PREFIXES(SyncerThreadTest, CalculateSyncWaitTime); |
| 52 FRIEND_TEST_ALL_PREFIXES(SyncerThreadTest, CalculatePollingWaitTime); | 52 FRIEND_TEST_ALL_PREFIXES(SyncerThreadTest, CalculatePollingWaitTime); |
| 53 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, Polling); | 53 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, Polling); |
| 54 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, Nudge); | 54 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, Nudge); |
| 55 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, Throttling); | 55 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, Throttling); |
| 56 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, AuthInvalid); | 56 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, AuthInvalid); |
| 57 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, Pause); | 57 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, Pause); |
| 58 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, StartWhenNotConnected); | 58 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, StartWhenNotConnected); |
| 59 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, PauseWhenNotConnected); | 59 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, PauseWhenNotConnected); |
| 60 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, StopSyncPermanently); |
| 60 friend class SyncerThreadWithSyncerTest; | 61 friend class SyncerThreadWithSyncerTest; |
| 61 friend class SyncerThreadFactory; | 62 friend class SyncerThreadFactory; |
| 62 public: | 63 public: |
| 63 // Encapsulates the parameters that make up an interval on which the | 64 // Encapsulates the parameters that make up an interval on which the |
| 64 // syncer thread is sleeping. | 65 // syncer thread is sleeping. |
| 65 struct WaitInterval { | 66 struct WaitInterval { |
| 66 enum Mode { | 67 enum Mode { |
| 67 // A wait interval whose duration has not been affected by exponential | 68 // A wait interval whose duration has not been affected by exponential |
| 68 // backoff. The base case for exponential backoff falls in to this case | 69 // backoff. The base case for exponential backoff falls in to this case |
| 69 // (e.g when the exponent is 1). So far, we don't need a separate case. | 70 // (e.g when the exponent is 1). So far, we don't need a separate case. |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 const syncable::DirectoryManagerEvent& event); | 230 const syncable::DirectoryManagerEvent& event); |
| 230 void HandleChannelEvent(const SyncerEvent& event); | 231 void HandleChannelEvent(const SyncerEvent& event); |
| 231 | 232 |
| 232 // SyncSession::Delegate implementation. | 233 // SyncSession::Delegate implementation. |
| 233 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until); | 234 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until); |
| 234 virtual bool IsSyncingCurrentlySilenced(); | 235 virtual bool IsSyncingCurrentlySilenced(); |
| 235 virtual void OnReceivedShortPollIntervalUpdate( | 236 virtual void OnReceivedShortPollIntervalUpdate( |
| 236 const base::TimeDelta& new_interval); | 237 const base::TimeDelta& new_interval); |
| 237 virtual void OnReceivedLongPollIntervalUpdate( | 238 virtual void OnReceivedLongPollIntervalUpdate( |
| 238 const base::TimeDelta& new_interval); | 239 const base::TimeDelta& new_interval); |
| 240 virtual void OnShouldStopSyncingPermanently(); |
| 239 | 241 |
| 240 void HandleServerConnectionEvent(const ServerConnectionEvent& event); | 242 void HandleServerConnectionEvent(const ServerConnectionEvent& event); |
| 241 | 243 |
| 242 void SyncMain(Syncer* syncer); | 244 void SyncMain(Syncer* syncer); |
| 243 | 245 |
| 244 // Calculates the next sync wait time and exponential backoff state. | 246 // Calculates the next sync wait time and exponential backoff state. |
| 245 // last_poll_wait is the time duration of the previous polling timeout which | 247 // last_poll_wait is the time duration of the previous polling timeout which |
| 246 // was used. user_idle_milliseconds is updated by this method, and is a report | 248 // was used. user_idle_milliseconds is updated by this method, and is a report |
| 247 // of the full amount of time since the last period of activity for the user. | 249 // of the full amount of time since the last period of activity for the user. |
| 248 // The continue_sync_cycle parameter is used to determine whether or not we | 250 // The continue_sync_cycle parameter is used to determine whether or not we |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 // or shutdown is started. | 283 // or shutdown is started. |
| 282 void PauseUntilResumedOrQuit(); | 284 void PauseUntilResumedOrQuit(); |
| 283 | 285 |
| 284 void EnterPausedState(); | 286 void EnterPausedState(); |
| 285 | 287 |
| 286 void ExitPausedState(); | 288 void ExitPausedState(); |
| 287 | 289 |
| 288 // For unit tests only. | 290 // For unit tests only. |
| 289 virtual void DisableIdleDetection() { disable_idle_detection_ = true; } | 291 virtual void DisableIdleDetection() { disable_idle_detection_ = true; } |
| 290 | 292 |
| 293 // This sets all conditions for syncer thread termination but does not |
| 294 // actually join threads. It is expected that Stop will be called at some |
| 295 // time after to fully stop and clean up. |
| 296 void RequestSyncerExitAndSetThreadStopConditions(); |
| 297 |
| 291 // State of the notification framework is tracked by these values. | 298 // State of the notification framework is tracked by these values. |
| 292 bool p2p_authenticated_; | 299 bool p2p_authenticated_; |
| 293 bool p2p_subscribed_; | 300 bool p2p_subscribed_; |
| 294 | 301 |
| 295 scoped_ptr<EventListenerHookup> conn_mgr_hookup_; | 302 scoped_ptr<EventListenerHookup> conn_mgr_hookup_; |
| 296 const AllStatus* allstatus_; | 303 const AllStatus* allstatus_; |
| 297 | 304 |
| 298 // Modifiable versions of kDefaultLongPollIntervalSeconds which can be | 305 // Modifiable versions of kDefaultLongPollIntervalSeconds which can be |
| 299 // updated by the server. | 306 // updated by the server. |
| 300 int syncer_short_poll_interval_seconds_; | 307 int syncer_short_poll_interval_seconds_; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 346 |
| 340 // Useful for unit tests | 347 // Useful for unit tests |
| 341 bool disable_idle_detection_; | 348 bool disable_idle_detection_; |
| 342 | 349 |
| 343 DISALLOW_COPY_AND_ASSIGN(SyncerThread); | 350 DISALLOW_COPY_AND_ASSIGN(SyncerThread); |
| 344 }; | 351 }; |
| 345 | 352 |
| 346 } // namespace browser_sync | 353 } // namespace browser_sync |
| 347 | 354 |
| 348 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD_H_ | 355 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD_H_ |
| OLD | NEW |