OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/time.h" | 6 #include "base/time.h" |
7 #include "sync/engine/backoff_delay_provider.h" | 7 #include "sync/engine/backoff_delay_provider.h" |
8 #include "sync/engine/sync_scheduler_impl.h" | 8 #include "sync/engine/sync_scheduler_impl.h" |
9 #include "sync/engine/throttled_data_type_tracker.h" | 9 #include "sync/engine/throttled_data_type_tracker.h" |
10 #include "sync/internal_api/public/engine/polling_constants.h" | 10 #include "sync/internal_api/public/engine/polling_constants.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 new SyncSchedulerImpl::WaitInterval( | 86 new SyncSchedulerImpl::WaitInterval( |
87 SyncSchedulerImpl::WaitInterval::EXPONENTIAL_BACKOFF, | 87 SyncSchedulerImpl::WaitInterval::EXPONENTIAL_BACKOFF, |
88 TimeDelta::FromSeconds(1))); | 88 TimeDelta::FromSeconds(1))); |
89 } | 89 } |
90 | 90 |
91 void SetWaitIntervalHadNudge(bool had_nudge) { | 91 void SetWaitIntervalHadNudge(bool had_nudge) { |
92 scheduler_->wait_interval_->had_nudge = had_nudge; | 92 scheduler_->wait_interval_->had_nudge = had_nudge; |
93 } | 93 } |
94 | 94 |
95 SyncSchedulerImpl::JobProcessDecision DecideOnJob( | 95 SyncSchedulerImpl::JobProcessDecision DecideOnJob( |
96 const SyncSessionJob& job) { | 96 const SyncSessionJob& job, |
97 return scheduler_->DecideOnJob(job); | 97 SyncSchedulerImpl::JobPriority priority) { |
| 98 return scheduler_->DecideOnJob(job, priority); |
98 } | 99 } |
99 | 100 |
100 void InitializeSyncerOnNormalMode() { | 101 void InitializeSyncerOnNormalMode() { |
101 SetMode(SyncScheduler::NORMAL_MODE); | 102 SetMode(SyncScheduler::NORMAL_MODE); |
102 ResetWaitInterval(); | 103 ResetWaitInterval(); |
103 } | 104 } |
104 | 105 |
105 SyncSchedulerImpl::JobProcessDecision CreateAndDecideJob( | 106 SyncSchedulerImpl::JobProcessDecision CreateAndDecideJob( |
106 SyncSessionJob::Purpose purpose) { | 107 SyncSessionJob::Purpose purpose) { |
107 scoped_ptr<SyncSession> s(scheduler_->CreateSyncSession(SyncSourceInfo())); | 108 scoped_ptr<SyncSession> s(scheduler_->CreateSyncSession(SyncSourceInfo())); |
108 SyncSessionJob job(purpose, TimeTicks::Now(), s.Pass(), | 109 SyncSessionJob job(purpose, TimeTicks::Now(), s.Pass(), |
109 ConfigurationParams()); | 110 ConfigurationParams()); |
110 return DecideOnJob(job); | 111 return DecideOnJob(job, SyncSchedulerImpl::NORMAL_PRIORITY); |
111 } | 112 } |
112 | 113 |
113 SyncSessionContext* context() { return context_.get(); } | 114 SyncSessionContext* context() { return context_.get(); } |
114 | 115 |
115 private: | 116 private: |
116 MessageLoop message_loop_; | 117 MessageLoop message_loop_; |
117 scoped_ptr<MockConnectionManager> connection_; | 118 scoped_ptr<MockConnectionManager> connection_; |
118 scoped_ptr<SyncSessionContext> context_; | 119 scoped_ptr<SyncSessionContext> context_; |
119 std::vector<scoped_refptr<FakeModelWorker> > workers_; | 120 std::vector<scoped_refptr<FakeModelWorker> > workers_; |
120 FakeExtensionsActivityMonitor extensions_activity_monitor_; | 121 FakeExtensionsActivityMonitor extensions_activity_monitor_; |
(...skipping 30 matching lines...) Expand all Loading... |
151 ModelTypeSetToInvalidationMap(types, std::string()); | 152 ModelTypeSetToInvalidationMap(types, std::string()); |
152 | 153 |
153 SyncSourceInfo info(GetUpdatesCallerInfo::LOCAL, invalidation_map); | 154 SyncSourceInfo info(GetUpdatesCallerInfo::LOCAL, invalidation_map); |
154 scoped_ptr<SyncSession> s(scheduler_->CreateSyncSession(info)); | 155 scoped_ptr<SyncSession> s(scheduler_->CreateSyncSession(info)); |
155 | 156 |
156 // Now schedule a nudge with just bookmarks and the change is local. | 157 // Now schedule a nudge with just bookmarks and the change is local. |
157 SyncSessionJob job(SyncSessionJob::NUDGE, | 158 SyncSessionJob job(SyncSessionJob::NUDGE, |
158 TimeTicks::Now(), | 159 TimeTicks::Now(), |
159 s.Pass(), | 160 s.Pass(), |
160 ConfigurationParams()); | 161 ConfigurationParams()); |
161 SyncSchedulerImpl::JobProcessDecision decision = DecideOnJob(job); | 162 SyncSchedulerImpl::JobProcessDecision decision = |
| 163 DecideOnJob(job, SyncSchedulerImpl::NORMAL_PRIORITY); |
162 // TODO(tim): This shouldn't drop. Bug 177659. | 164 // TODO(tim): This shouldn't drop. Bug 177659. |
163 EXPECT_EQ(decision, SyncSchedulerImpl::DROP); | 165 EXPECT_EQ(decision, SyncSchedulerImpl::DROP); |
164 } | 166 } |
165 | 167 |
166 TEST_F(SyncSchedulerWhiteboxTest, ContinueNudge) { | 168 TEST_F(SyncSchedulerWhiteboxTest, ContinueNudge) { |
167 InitializeSyncerOnNormalMode(); | 169 InitializeSyncerOnNormalMode(); |
168 | 170 |
169 SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob( | 171 SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob( |
170 SyncSessionJob::NUDGE); | 172 SyncSessionJob::NUDGE); |
171 | 173 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 252 |
251 TEST_F(SyncSchedulerWhiteboxTest, ContinueCanaryJobConfig) { | 253 TEST_F(SyncSchedulerWhiteboxTest, ContinueCanaryJobConfig) { |
252 InitializeSyncerOnNormalMode(); | 254 InitializeSyncerOnNormalMode(); |
253 SetMode(SyncScheduler::CONFIGURATION_MODE); | 255 SetMode(SyncScheduler::CONFIGURATION_MODE); |
254 SetWaitIntervalToExponentialBackoff(); | 256 SetWaitIntervalToExponentialBackoff(); |
255 | 257 |
256 SyncSessionJob job(SyncSessionJob::CONFIGURATION, | 258 SyncSessionJob job(SyncSessionJob::CONFIGURATION, |
257 TimeTicks::Now(), scoped_ptr<SyncSession>(), | 259 TimeTicks::Now(), scoped_ptr<SyncSession>(), |
258 ConfigurationParams()); | 260 ConfigurationParams()); |
259 | 261 |
260 job.GrantCanaryPrivilege(); | 262 SyncSchedulerImpl::JobProcessDecision decision = |
261 SyncSchedulerImpl::JobProcessDecision decision = DecideOnJob(job); | 263 DecideOnJob(job, SyncSchedulerImpl::CANARY_PRIORITY); |
262 | 264 |
263 EXPECT_EQ(decision, SyncSchedulerImpl::CONTINUE); | 265 EXPECT_EQ(decision, SyncSchedulerImpl::CONTINUE); |
264 } | 266 } |
265 | 267 |
266 } // namespace syncer | 268 } // namespace syncer |
OLD | NEW |