OLD | NEW |
1 // Copyright (c) 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 SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 5 #ifndef SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
6 #define SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 6 #define SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
18 #include "base/time.h" | 18 #include "base/time.h" |
19 #include "base/timer.h" | 19 #include "base/timer.h" |
| 20 #include "sync/base/sync_export.h" |
20 #include "sync/engine/net/server_connection_manager.h" | 21 #include "sync/engine/net/server_connection_manager.h" |
21 #include "sync/engine/nudge_source.h" | 22 #include "sync/engine/nudge_source.h" |
22 #include "sync/engine/sync_scheduler.h" | 23 #include "sync/engine/sync_scheduler.h" |
23 #include "sync/engine/sync_session_job.h" | 24 #include "sync/engine/sync_session_job.h" |
24 #include "sync/engine/syncer.h" | 25 #include "sync/engine/syncer.h" |
25 #include "sync/internal_api/public/base/model_type_invalidation_map.h" | 26 #include "sync/internal_api/public/base/model_type_invalidation_map.h" |
26 #include "sync/internal_api/public/engine/polling_constants.h" | 27 #include "sync/internal_api/public/engine/polling_constants.h" |
27 #include "sync/internal_api/public/util/weak_handle.h" | 28 #include "sync/internal_api/public/util/weak_handle.h" |
28 #include "sync/sessions/sync_session.h" | 29 #include "sync/sessions/sync_session.h" |
29 #include "sync/sessions/sync_session_context.h" | 30 #include "sync/sessions/sync_session_context.h" |
30 | 31 |
31 namespace syncer { | 32 namespace syncer { |
32 | 33 |
33 class BackoffDelayProvider; | 34 class BackoffDelayProvider; |
34 | 35 |
35 class SyncSchedulerImpl : public SyncScheduler { | 36 class SYNC_EXPORT_PRIVATE SyncSchedulerImpl : public SyncScheduler { |
36 public: | 37 public: |
37 // |name| is a display string to identify the syncer thread. Takes | 38 // |name| is a display string to identify the syncer thread. Takes |
38 // |ownership of |syncer| and |delay_provider|. | 39 // |ownership of |syncer| and |delay_provider|. |
39 SyncSchedulerImpl(const std::string& name, | 40 SyncSchedulerImpl(const std::string& name, |
40 BackoffDelayProvider* delay_provider, | 41 BackoffDelayProvider* delay_provider, |
41 sessions::SyncSessionContext* context, | 42 sessions::SyncSessionContext* context, |
42 Syncer* syncer); | 43 Syncer* syncer); |
43 | 44 |
44 // Calls Stop(). | 45 // Calls Stop(). |
45 virtual ~SyncSchedulerImpl(); | 46 virtual ~SyncSchedulerImpl(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 ContinueCanaryJobConfig); | 110 ContinueCanaryJobConfig); |
110 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | 111 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, |
111 ContinueNudgeWhileExponentialBackOff); | 112 ContinueNudgeWhileExponentialBackOff); |
112 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, TransientPollFailure); | 113 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, TransientPollFailure); |
113 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, GetInitialBackoffDelay); | 114 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, GetInitialBackoffDelay); |
114 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, | 115 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, |
115 ServerConnectionChangeDuringBackoff); | 116 ServerConnectionChangeDuringBackoff); |
116 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, | 117 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, |
117 ConnectionChangeCanaryPreemptedByNudge); | 118 ConnectionChangeCanaryPreemptedByNudge); |
118 | 119 |
119 struct WaitInterval { | 120 struct SYNC_EXPORT_PRIVATE WaitInterval { |
120 enum Mode { | 121 enum Mode { |
121 // Uninitialized state, should not be set in practice. | 122 // Uninitialized state, should not be set in practice. |
122 UNKNOWN = -1, | 123 UNKNOWN = -1, |
123 // A wait interval whose duration has been affected by exponential | 124 // A wait interval whose duration has been affected by exponential |
124 // backoff. | 125 // backoff. |
125 // EXPONENTIAL_BACKOFF intervals are nudge-rate limited to 1 per interval. | 126 // EXPONENTIAL_BACKOFF intervals are nudge-rate limited to 1 per interval. |
126 EXPONENTIAL_BACKOFF, | 127 EXPONENTIAL_BACKOFF, |
127 // A server-initiated throttled interval. We do not allow any syncing | 128 // A server-initiated throttled interval. We do not allow any syncing |
128 // during such an interval. | 129 // during such an interval. |
129 THROTTLED, | 130 THROTTLED, |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 // take place during a sync cycle. We call this out because such violations | 329 // take place during a sync cycle. We call this out because such violations |
329 // could result in tight sync loops hitting sync servers. | 330 // could result in tight sync loops hitting sync servers. |
330 bool no_scheduling_allowed_; | 331 bool no_scheduling_allowed_; |
331 | 332 |
332 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); | 333 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
333 }; | 334 }; |
334 | 335 |
335 } // namespace syncer | 336 } // namespace syncer |
336 | 337 |
337 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 338 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
OLD | NEW |