| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/driver/glue/sync_backend_host_impl.h" | 5 #include "components/sync/driver/glue/sync_backend_host_impl.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/memory/ptr_util.h" |
| 13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 15 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.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 "base/time/time.h" | 19 #include "base/time/time.h" |
| 19 #include "components/invalidation/impl/invalidator_storage.h" | 20 #include "components/invalidation/impl/invalidator_storage.h" |
| 20 #include "components/invalidation/impl/profile_invalidation_provider.h" | 21 #include "components/invalidation/impl/profile_invalidation_provider.h" |
| 21 #include "components/invalidation/public/invalidator_state.h" | 22 #include "components/invalidation/public/invalidator_state.h" |
| 22 #include "components/invalidation/public/object_id_invalidation_map.h" | 23 #include "components/invalidation/public/object_id_invalidation_map.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 protected: | 157 protected: |
| 157 SyncBackendHostTest() : fake_manager_(NULL) {} | 158 SyncBackendHostTest() : fake_manager_(NULL) {} |
| 158 | 159 |
| 159 ~SyncBackendHostTest() override {} | 160 ~SyncBackendHostTest() override {} |
| 160 | 161 |
| 161 void SetUp() override { | 162 void SetUp() override { |
| 162 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 163 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 163 | 164 |
| 164 SyncPrefs::RegisterProfilePrefs(pref_service_.registry()); | 165 SyncPrefs::RegisterProfilePrefs(pref_service_.registry()); |
| 165 | 166 |
| 166 sync_prefs_.reset(new SyncPrefs(&pref_service_)); | 167 sync_prefs_ = base::MakeUnique<SyncPrefs>(&pref_service_); |
| 167 backend_.reset(new SyncBackendHostImpl( | 168 backend_ = base::MakeUnique<SyncBackendHostImpl>( |
| 168 "dummyDebugName", &sync_client_, base::ThreadTaskRunnerHandle::Get(), | 169 "dummyDebugName", &sync_client_, base::ThreadTaskRunnerHandle::Get(), |
| 169 nullptr, sync_prefs_->AsWeakPtr(), | 170 nullptr, sync_prefs_->AsWeakPtr(), |
| 170 temp_dir_.GetPath().Append(base::FilePath(kTestSyncDir)))); | 171 temp_dir_.GetPath().Append(base::FilePath(kTestSyncDir))); |
| 171 credentials_.account_id = "user@example.com"; | 172 credentials_.account_id = "user@example.com"; |
| 172 credentials_.email = "user@example.com"; | 173 credentials_.email = "user@example.com"; |
| 173 credentials_.sync_token = "sync_token"; | 174 credentials_.sync_token = "sync_token"; |
| 174 credentials_.scope_set.insert(GaiaConstants::kChromeSyncOAuth2Scope); | 175 credentials_.scope_set.insert(GaiaConstants::kChromeSyncOAuth2Scope); |
| 175 | 176 |
| 176 fake_manager_factory_.reset(new FakeSyncManagerFactory(&fake_manager_)); | 177 fake_manager_factory_ = |
| 178 base::MakeUnique<FakeSyncManagerFactory>(&fake_manager_); |
| 177 | 179 |
| 178 // These types are always implicitly enabled. | 180 // These types are always implicitly enabled. |
| 179 enabled_types_.PutAll(ControlTypes()); | 181 enabled_types_.PutAll(ControlTypes()); |
| 180 | 182 |
| 181 // NOTE: We can't include Passwords or Typed URLs due to the Sync Backend | 183 // NOTE: We can't include Passwords or Typed URLs due to the Sync Backend |
| 182 // Registrar removing them if it can't find their model workers. | 184 // Registrar removing them if it can't find their model workers. |
| 183 enabled_types_.Put(BOOKMARKS); | 185 enabled_types_.Put(BOOKMARKS); |
| 184 enabled_types_.Put(PREFERENCES); | 186 enabled_types_.Put(PREFERENCES); |
| 185 enabled_types_.Put(SESSIONS); | 187 enabled_types_.Put(SESSIONS); |
| 186 enabled_types_.Put(SEARCH_ENGINES); | 188 enabled_types_.Put(SEARCH_ENGINES); |
| 187 enabled_types_.Put(AUTOFILL); | 189 enabled_types_.Put(AUTOFILL); |
| 188 | 190 |
| 189 network_resources_.reset(new HttpBridgeNetworkResources()); | 191 network_resources_ = base::MakeUnique<HttpBridgeNetworkResources>(); |
| 190 } | 192 } |
| 191 | 193 |
| 192 void TearDown() override { | 194 void TearDown() override { |
| 193 if (backend_) { | 195 if (backend_) { |
| 194 backend_->StopSyncingForShutdown(); | 196 backend_->StopSyncingForShutdown(); |
| 195 backend_->Shutdown(STOP_SYNC); | 197 backend_->Shutdown(STOP_SYNC); |
| 196 } | 198 } |
| 197 backend_.reset(); | 199 backend_.reset(); |
| 198 sync_prefs_.reset(); | 200 sync_prefs_.reset(); |
| 199 // Pump messages posted by the sync thread. | 201 // Pump messages posted by the sync thread. |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 backend_->StopSyncingForShutdown(); | 823 backend_->StopSyncingForShutdown(); |
| 822 // Verify that call to DeactivateNonBlockingDataType doesn't assert. | 824 // Verify that call to DeactivateNonBlockingDataType doesn't assert. |
| 823 backend_->DeactivateNonBlockingDataType(AUTOFILL); | 825 backend_->DeactivateNonBlockingDataType(AUTOFILL); |
| 824 backend_->Shutdown(STOP_SYNC); | 826 backend_->Shutdown(STOP_SYNC); |
| 825 backend_.reset(); | 827 backend_.reset(); |
| 826 } | 828 } |
| 827 | 829 |
| 828 } // namespace | 830 } // namespace |
| 829 | 831 |
| 830 } // namespace syncer | 832 } // namespace syncer |
| OLD | NEW |