| 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 |
| 11 #include <list> | 11 #include <list> |
| 12 #include <map> | 12 #include <map> |
| 13 #include <queue> | 13 #include <queue> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 17 #include "base/condition_variable.h" | 17 #include "base/condition_variable.h" |
| 18 #include "base/gtest_prod_util.h" |
| 18 #include "base/ref_counted.h" | 19 #include "base/ref_counted.h" |
| 19 #include "base/scoped_ptr.h" | 20 #include "base/scoped_ptr.h" |
| 20 #include "base/thread.h" | 21 #include "base/thread.h" |
| 21 #include "base/time.h" | 22 #include "base/time.h" |
| 22 #include "base/waitable_event.h" | 23 #include "base/waitable_event.h" |
| 23 #include "chrome/browser/sync/engine/all_status.h" | 24 #include "chrome/browser/sync/engine/all_status.h" |
| 24 #if defined(OS_LINUX) | 25 #if defined(OS_LINUX) |
| 25 #include "chrome/browser/sync/engine/idle_query_linux.h" | 26 #include "chrome/browser/sync/engine/idle_query_linux.h" |
| 26 #endif | 27 #endif |
| 27 #include "chrome/browser/sync/sessions/sync_session.h" | 28 #include "chrome/browser/sync/sessions/sync_session.h" |
| 28 #include "chrome/common/deprecated/event_sys-inl.h" | 29 #include "chrome/common/deprecated/event_sys-inl.h" |
| 29 #include "testing/gtest/include/gtest/gtest_prod.h" // For FRIEND_TEST | |
| 30 | 30 |
| 31 class EventListenerHookup; | 31 class EventListenerHookup; |
| 32 | 32 |
| 33 namespace syncable { | 33 namespace syncable { |
| 34 class DirectoryManager; | 34 class DirectoryManager; |
| 35 struct DirectoryManagerEvent; | 35 struct DirectoryManagerEvent; |
| 36 } | 36 } |
| 37 | 37 |
| 38 namespace browser_sync { | 38 namespace browser_sync { |
| 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 FRIEND_TEST(SyncerThreadTest, CalculateSyncWaitTime); | 50 FRIEND_TEST_ALL_PREFIXES(SyncerThreadTest, CalculateSyncWaitTime); |
| 51 FRIEND_TEST(SyncerThreadTest, CalculatePollingWaitTime); | 51 FRIEND_TEST_ALL_PREFIXES(SyncerThreadTest, CalculatePollingWaitTime); |
| 52 FRIEND_TEST(SyncerThreadWithSyncerTest, Polling); | 52 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, Polling); |
| 53 FRIEND_TEST(SyncerThreadWithSyncerTest, Nudge); | 53 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, Nudge); |
| 54 FRIEND_TEST(SyncerThreadWithSyncerTest, Throttling); | 54 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, Throttling); |
| 55 FRIEND_TEST(SyncerThreadWithSyncerTest, AuthInvalid); | 55 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, AuthInvalid); |
| 56 FRIEND_TEST(SyncerThreadWithSyncerTest, DISABLED_Pause); | 56 FRIEND_TEST_ALL_PREFIXES(SyncerThreadWithSyncerTest, Pause); |
| 57 friend class SyncerThreadWithSyncerTest; | 57 friend class SyncerThreadWithSyncerTest; |
| 58 friend class SyncerThreadFactory; | 58 friend class SyncerThreadFactory; |
| 59 public: | 59 public: |
| 60 // Encapsulates the parameters that make up an interval on which the | 60 // Encapsulates the parameters that make up an interval on which the |
| 61 // syncer thread is sleeping. | 61 // syncer thread is sleeping. |
| 62 struct WaitInterval { | 62 struct WaitInterval { |
| 63 enum Mode { | 63 enum Mode { |
| 64 // A wait interval whose duration has not been affected by exponential | 64 // A wait interval whose duration has not been affected by exponential |
| 65 // backoff. The base case for exponential backoff falls in to this case | 65 // backoff. The base case for exponential backoff falls in to this case |
| 66 // (e.g when the exponent is 1). So far, we don't need a separate case. | 66 // (e.g when the exponent is 1). So far, we don't need a separate case. |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 326 |
| 327 // Useful for unit tests | 327 // Useful for unit tests |
| 328 bool disable_idle_detection_; | 328 bool disable_idle_detection_; |
| 329 | 329 |
| 330 DISALLOW_COPY_AND_ASSIGN(SyncerThread); | 330 DISALLOW_COPY_AND_ASSIGN(SyncerThread); |
| 331 }; | 331 }; |
| 332 | 332 |
| 333 } // namespace browser_sync | 333 } // namespace browser_sync |
| 334 | 334 |
| 335 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD_H_ | 335 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD_H_ |
| OLD | NEW |