| 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 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 class ModelSafeWorker; | 40 class ModelSafeWorker; |
| 41 class ServerConnectionManager; | 41 class ServerConnectionManager; |
| 42 class Syncer; | 42 class Syncer; |
| 43 class URLFactory; | 43 class URLFactory; |
| 44 struct ServerConnectionEvent; | 44 struct ServerConnectionEvent; |
| 45 struct SyncerEvent; | 45 struct SyncerEvent; |
| 46 struct SyncerShutdownEvent; | 46 struct SyncerShutdownEvent; |
| 47 | 47 |
| 48 class SyncerThread : public base::RefCountedThreadSafe<SyncerThread>, | 48 class SyncerThread : public base::RefCountedThreadSafe<SyncerThread>, |
| 49 public sessions::SyncSession::Delegate { | 49 public sessions::SyncSession::Delegate, |
| 50 public ChannelEventHandler<SyncerEvent> { |
| 50 FRIEND_TEST(SyncerThreadTest, CalculateSyncWaitTime); | 51 FRIEND_TEST(SyncerThreadTest, CalculateSyncWaitTime); |
| 51 FRIEND_TEST(SyncerThreadTest, CalculatePollingWaitTime); | 52 FRIEND_TEST(SyncerThreadTest, CalculatePollingWaitTime); |
| 52 FRIEND_TEST(SyncerThreadWithSyncerTest, Polling); | 53 FRIEND_TEST(SyncerThreadWithSyncerTest, Polling); |
| 53 FRIEND_TEST(SyncerThreadWithSyncerTest, Nudge); | 54 FRIEND_TEST(SyncerThreadWithSyncerTest, Nudge); |
| 54 FRIEND_TEST(SyncerThreadWithSyncerTest, Throttling); | 55 FRIEND_TEST(SyncerThreadWithSyncerTest, Throttling); |
| 55 FRIEND_TEST(SyncerThreadWithSyncerTest, AuthInvalid); | 56 FRIEND_TEST(SyncerThreadWithSyncerTest, AuthInvalid); |
| 56 FRIEND_TEST(SyncerThreadWithSyncerTest, DISABLED_Pause); | 57 FRIEND_TEST(SyncerThreadWithSyncerTest, DISABLED_Pause); |
| 57 friend class SyncerThreadWithSyncerTest; | 58 friend class SyncerThreadWithSyncerTest; |
| 58 friend class SyncerThreadFactory; | 59 friend class SyncerThreadFactory; |
| 59 public: | 60 public: |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 Lock lock_; | 214 Lock lock_; |
| 214 | 215 |
| 215 private: | 216 private: |
| 216 // Threshold multipler for how long before user should be considered idle. | 217 // Threshold multipler for how long before user should be considered idle. |
| 217 static const int kPollBackoffThresholdMultiplier = 10; | 218 static const int kPollBackoffThresholdMultiplier = 10; |
| 218 | 219 |
| 219 friend void* RunSyncerThread(void* syncer_thread); | 220 friend void* RunSyncerThread(void* syncer_thread); |
| 220 void* Run(); | 221 void* Run(); |
| 221 void HandleDirectoryManagerEvent( | 222 void HandleDirectoryManagerEvent( |
| 222 const syncable::DirectoryManagerEvent& event); | 223 const syncable::DirectoryManagerEvent& event); |
| 223 void HandleSyncerEvent(const SyncerEvent& event); | 224 void HandleChannelEvent(const SyncerEvent& event); |
| 224 | 225 |
| 225 // SyncSession::Delegate implementation. | 226 // SyncSession::Delegate implementation. |
| 226 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until); | 227 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until); |
| 227 virtual bool IsSyncingCurrentlySilenced(); | 228 virtual bool IsSyncingCurrentlySilenced(); |
| 228 virtual void OnReceivedShortPollIntervalUpdate( | 229 virtual void OnReceivedShortPollIntervalUpdate( |
| 229 const base::TimeDelta& new_interval); | 230 const base::TimeDelta& new_interval); |
| 230 virtual void OnReceivedLongPollIntervalUpdate( | 231 virtual void OnReceivedLongPollIntervalUpdate( |
| 231 const base::TimeDelta& new_interval); | 232 const base::TimeDelta& new_interval); |
| 232 | 233 |
| 233 void HandleServerConnectionEvent(const ServerConnectionEvent& event); | 234 void HandleServerConnectionEvent(const ServerConnectionEvent& event); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 // this bounds the "nominal" poll interval, while the the actual interval | 296 // this bounds the "nominal" poll interval, while the the actual interval |
| 296 // also takes previous failures into account. | 297 // also takes previous failures into account. |
| 297 int syncer_max_interval_; | 298 int syncer_max_interval_; |
| 298 | 299 |
| 299 // This causes syncer to start syncing ASAP. If the rate of requests is too | 300 // This causes syncer to start syncing ASAP. If the rate of requests is too |
| 300 // high the request will be silently dropped. mutex_ should be held when | 301 // high the request will be silently dropped. mutex_ should be held when |
| 301 // this is called. | 302 // this is called. |
| 302 void NudgeSyncImpl(int milliseconds_from_now, NudgeSource source); | 303 void NudgeSyncImpl(int milliseconds_from_now, NudgeSource source); |
| 303 | 304 |
| 304 scoped_ptr<EventListenerHookup> directory_manager_hookup_; | 305 scoped_ptr<EventListenerHookup> directory_manager_hookup_; |
| 305 scoped_ptr<EventListenerHookup> syncer_events_; | 306 scoped_ptr<ChannelHookup<SyncerEvent> > syncer_events_; |
| 306 | 307 |
| 307 #if defined(OS_LINUX) | 308 #if defined(OS_LINUX) |
| 308 // On Linux, we need this information in order to query idle time. | 309 // On Linux, we need this information in order to query idle time. |
| 309 scoped_ptr<IdleQueryLinux> idle_query_; | 310 scoped_ptr<IdleQueryLinux> idle_query_; |
| 310 #endif | 311 #endif |
| 311 | 312 |
| 312 scoped_ptr<sessions::SyncSessionContext> session_context_; | 313 scoped_ptr<sessions::SyncSessionContext> session_context_; |
| 313 | 314 |
| 314 // Events from the Syncer's syncer_event_channel are first processed by the | 315 // Events from the Syncer's syncer_event_channel are first processed by the |
| 315 // SyncerThread and then get relayed onto this channel for consumers. | 316 // SyncerThread and then get relayed onto this channel for consumers. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 326 | 327 |
| 327 // Useful for unit tests | 328 // Useful for unit tests |
| 328 bool disable_idle_detection_; | 329 bool disable_idle_detection_; |
| 329 | 330 |
| 330 DISALLOW_COPY_AND_ASSIGN(SyncerThread); | 331 DISALLOW_COPY_AND_ASSIGN(SyncerThread); |
| 331 }; | 332 }; |
| 332 | 333 |
| 333 } // namespace browser_sync | 334 } // namespace browser_sync |
| 334 | 335 |
| 335 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD_H_ | 336 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD_H_ |
| OLD | NEW |