OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_SYNC_SCHEDULER_IMPL_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_SYNC_SCHEDULER_IMPL_H_ |
6 #define COMPONENTS_SYNC_ENGINE_IMPL_SYNC_SCHEDULER_IMPL_H_ | 6 #define COMPONENTS_SYNC_ENGINE_IMPL_SYNC_SCHEDULER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/cancelable_callback.h" | 13 #include "base/cancelable_callback.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/linked_ptr.h" | 17 #include "base/memory/linked_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/threading/non_thread_safe.h" | 19 #include "base/threading/non_thread_safe.h" |
20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
21 #include "base/timer/timer.h" | 21 #include "base/timer/timer.h" |
22 #include "components/sync/base/sync_export.h" | |
23 #include "components/sync/base/weak_handle.h" | 22 #include "components/sync/base/weak_handle.h" |
24 #include "components/sync/engine/polling_constants.h" | 23 #include "components/sync/engine/polling_constants.h" |
25 #include "components/sync/engine_impl/net/server_connection_manager.h" | 24 #include "components/sync/engine_impl/net/server_connection_manager.h" |
26 #include "components/sync/engine_impl/nudge_source.h" | 25 #include "components/sync/engine_impl/nudge_source.h" |
27 #include "components/sync/engine_impl/sync_scheduler.h" | 26 #include "components/sync/engine_impl/sync_scheduler.h" |
28 #include "components/sync/engine_impl/syncer.h" | 27 #include "components/sync/engine_impl/syncer.h" |
29 #include "components/sync/sessions_impl/nudge_tracker.h" | 28 #include "components/sync/sessions_impl/nudge_tracker.h" |
30 #include "components/sync/sessions_impl/sync_session.h" | 29 #include "components/sync/sessions_impl/sync_session.h" |
31 #include "components/sync/sessions_impl/sync_session_context.h" | 30 #include "components/sync/sessions_impl/sync_session_context.h" |
32 | 31 |
33 namespace syncer { | 32 namespace syncer { |
34 | 33 |
35 class BackoffDelayProvider; | 34 class BackoffDelayProvider; |
36 | 35 |
37 namespace sessions { | 36 namespace sessions { |
38 struct ModelNeutralState; | 37 struct ModelNeutralState; |
39 } | 38 } |
40 | 39 |
41 class SYNC_EXPORT SyncSchedulerImpl : public SyncScheduler, | 40 class SyncSchedulerImpl : public SyncScheduler, public base::NonThreadSafe { |
42 public base::NonThreadSafe { | |
43 public: | 41 public: |
44 // |name| is a display string to identify the syncer thread. Takes | 42 // |name| is a display string to identify the syncer thread. Takes |
45 // |ownership of |syncer| and |delay_provider|. | 43 // |ownership of |syncer| and |delay_provider|. |
46 SyncSchedulerImpl(const std::string& name, | 44 SyncSchedulerImpl(const std::string& name, |
47 BackoffDelayProvider* delay_provider, | 45 BackoffDelayProvider* delay_provider, |
48 sessions::SyncSessionContext* context, | 46 sessions::SyncSessionContext* context, |
49 Syncer* syncer); | 47 Syncer* syncer); |
50 | 48 |
51 // Calls Stop(). | 49 // Calls Stop(). |
52 ~SyncSchedulerImpl() override; | 50 ~SyncSchedulerImpl() override; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, | 112 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, |
115 ServerConnectionChangeDuringBackoff); | 113 ServerConnectionChangeDuringBackoff); |
116 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, | 114 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, |
117 ConnectionChangeCanaryPreemptedByNudge); | 115 ConnectionChangeCanaryPreemptedByNudge); |
118 FRIEND_TEST_ALL_PREFIXES(BackoffTriggersSyncSchedulerTest, | 116 FRIEND_TEST_ALL_PREFIXES(BackoffTriggersSyncSchedulerTest, |
119 FailGetEncryptionKey); | 117 FailGetEncryptionKey); |
120 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, SuccessfulRetry); | 118 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, SuccessfulRetry); |
121 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, FailedRetry); | 119 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, FailedRetry); |
122 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, ReceiveNewRetryDelay); | 120 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, ReceiveNewRetryDelay); |
123 | 121 |
124 struct SYNC_EXPORT WaitInterval { | 122 struct WaitInterval { |
125 enum Mode { | 123 enum Mode { |
126 // Uninitialized state, should not be set in practice. | 124 // Uninitialized state, should not be set in practice. |
127 UNKNOWN = -1, | 125 UNKNOWN = -1, |
128 // We enter a series of increasingly longer WaitIntervals if we experience | 126 // We enter a series of increasingly longer WaitIntervals if we experience |
129 // repeated transient failures. We retry at the end of each interval. | 127 // repeated transient failures. We retry at the end of each interval. |
130 EXPONENTIAL_BACKOFF, | 128 EXPONENTIAL_BACKOFF, |
131 // A server-initiated throttled interval. We do not allow any syncing | 129 // A server-initiated throttled interval. We do not allow any syncing |
132 // during such an interval. | 130 // during such an interval. |
133 THROTTLED, | 131 THROTTLED, |
134 }; | 132 }; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 // A second factory specially for weak_handle_this_, to allow the handle | 318 // A second factory specially for weak_handle_this_, to allow the handle |
321 // to be const and alleviate threading concerns. | 319 // to be const and alleviate threading concerns. |
322 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; | 320 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; |
323 | 321 |
324 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); | 322 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
325 }; | 323 }; |
326 | 324 |
327 } // namespace syncer | 325 } // namespace syncer |
328 | 326 |
329 #endif // COMPONENTS_SYNC_ENGINE_IMPL_SYNC_SCHEDULER_IMPL_H_ | 327 #endif // COMPONENTS_SYNC_ENGINE_IMPL_SYNC_SCHEDULER_IMPL_H_ |
OLD | NEW |