| 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 "components/sync/engine_impl/sync_scheduler_impl.h" | 5 #include "components/sync/engine_impl/sync_scheduler_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/memory/ptr_util.h" |
| 14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 16 #include "base/test/test_timeouts.h" | 17 #include "base/test/test_timeouts.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "components/sync/base/cancelation_signal.h" | 19 #include "components/sync/base/cancelation_signal.h" |
| 19 #include "components/sync/base/extensions_activity.h" | 20 #include "components/sync/base/extensions_activity.h" |
| 20 #include "components/sync/base/model_type_test_util.h" | 21 #include "components/sync/base/model_type_test_util.h" |
| 21 #include "components/sync/engine_impl/backoff_delay_provider.h" | 22 #include "components/sync/engine_impl/backoff_delay_provider.h" |
| 22 #include "components/sync/engine_impl/cycle/test_util.h" | 23 #include "components/sync/engine_impl/cycle/test_util.h" |
| 23 #include "components/sync/test/callback_counter.h" | 24 #include "components/sync/test/callback_counter.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 routing_info_[THEMES] = GROUP_UI; | 132 routing_info_[THEMES] = GROUP_UI; |
| 132 routing_info_[TYPED_URLS] = GROUP_DB; | 133 routing_info_[TYPED_URLS] = GROUP_DB; |
| 133 routing_info_[THEMES] = GROUP_UI; | 134 routing_info_[THEMES] = GROUP_UI; |
| 134 routing_info_[NIGORI] = GROUP_PASSIVE; | 135 routing_info_[NIGORI] = GROUP_PASSIVE; |
| 135 | 136 |
| 136 workers_.clear(); | 137 workers_.clear(); |
| 137 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_UI))); | 138 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_UI))); |
| 138 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_DB))); | 139 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_DB))); |
| 139 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE))); | 140 workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE))); |
| 140 | 141 |
| 141 connection_.reset( | 142 connection_ = base::MakeUnique<MockConnectionManager>(directory(), |
| 142 new MockConnectionManager(directory(), &cancelation_signal_)); | 143 &cancelation_signal_); |
| 143 connection_->SetServerReachable(); | 144 connection_->SetServerReachable(); |
| 144 | 145 |
| 145 model_type_registry_.reset( | 146 model_type_registry_ = base::MakeUnique<ModelTypeRegistry>( |
| 146 new ModelTypeRegistry(workers_, directory(), &mock_nudge_handler_)); | 147 workers_, directory(), &mock_nudge_handler_); |
| 147 | 148 |
| 148 context_.reset(new SyncCycleContext( | 149 context_ = base::MakeUnique<SyncCycleContext>( |
| 149 connection_.get(), directory(), extensions_activity_.get(), | 150 connection_.get(), directory(), extensions_activity_.get(), |
| 150 std::vector<SyncEngineEventListener*>(), NULL, | 151 std::vector<SyncEngineEventListener*>(), nullptr, |
| 151 model_type_registry_.get(), | 152 model_type_registry_.get(), |
| 152 true, // enable keystore encryption | 153 true, // enable keystore encryption |
| 153 false, // force enable pre-commit GU avoidance | 154 false, // force enable pre-commit GU avoidance |
| 154 "fake_invalidator_client_id")); | 155 "fake_invalidator_client_id"); |
| 155 context_->SetRoutingInfo(routing_info_); | 156 context_->SetRoutingInfo(routing_info_); |
| 156 context_->set_notifications_enabled(true); | 157 context_->set_notifications_enabled(true); |
| 157 context_->set_account_name("Test"); | 158 context_->set_account_name("Test"); |
| 158 scheduler_.reset(new SyncSchedulerImpl("TestSyncScheduler", | 159 scheduler_ = base::MakeUnique<SyncSchedulerImpl>( |
| 159 BackoffDelayProvider::FromDefaults(), | 160 "TestSyncScheduler", BackoffDelayProvider::FromDefaults(), context(), |
| 160 context(), syncer_)); | 161 syncer_); |
| 161 scheduler_->SetDefaultNudgeDelay(default_delay()); | 162 scheduler_->SetDefaultNudgeDelay(default_delay()); |
| 162 } | 163 } |
| 163 | 164 |
| 164 SyncSchedulerImpl* scheduler() { return scheduler_.get(); } | 165 SyncSchedulerImpl* scheduler() { return scheduler_.get(); } |
| 165 const ModelSafeRoutingInfo& routing_info() { return routing_info_; } | 166 const ModelSafeRoutingInfo& routing_info() { return routing_info_; } |
| 166 MockSyncer* syncer() { return syncer_; } | 167 MockSyncer* syncer() { return syncer_; } |
| 167 MockDelayProvider* delay() { return delay_; } | 168 MockDelayProvider* delay() { return delay_; } |
| 168 MockConnectionManager* connection() { return connection_.get(); } | 169 MockConnectionManager* connection() { return connection_.get(); } |
| 169 TimeDelta default_delay() { return TimeDelta::FromSeconds(0); } | 170 TimeDelta default_delay() { return TimeDelta::FromSeconds(0); } |
| 170 TimeDelta timeout() { return TestTimeouts::action_timeout(); } | 171 TimeDelta timeout() { return TestTimeouts::action_timeout(); } |
| (...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 ASSERT_TRUE(scheduler()->IsBackingOff()); | 1430 ASSERT_TRUE(scheduler()->IsBackingOff()); |
| 1430 | 1431 |
| 1431 // Now succeed. | 1432 // Now succeed. |
| 1432 connection()->SetServerReachable(); | 1433 connection()->SetServerReachable(); |
| 1433 PumpLoopFor(2 * delta); | 1434 PumpLoopFor(2 * delta); |
| 1434 ASSERT_EQ(1, success_counter.times_called()); | 1435 ASSERT_EQ(1, success_counter.times_called()); |
| 1435 ASSERT_FALSE(scheduler()->IsBackingOff()); | 1436 ASSERT_FALSE(scheduler()->IsBackingOff()); |
| 1436 } | 1437 } |
| 1437 | 1438 |
| 1438 } // namespace syncer | 1439 } // namespace syncer |
| OLD | NEW |