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/browser_sync/profile_sync_service.h" | 5 #include "components/browser_sync/profile_sync_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 #include <map> | 10 #include <map> |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 sessions_sync_manager_ = base::MakeUnique<SessionsSyncManager>( | 235 sessions_sync_manager_ = base::MakeUnique<SessionsSyncManager>( |
236 sync_client_->GetSyncSessionsClient(), &sync_prefs_, local_device_.get(), | 236 sync_client_->GetSyncSessionsClient(), &sync_prefs_, local_device_.get(), |
237 std::move(router), | 237 std::move(router), |
238 base::Bind(&ProfileSyncService::NotifyForeignSessionUpdated, | 238 base::Bind(&ProfileSyncService::NotifyForeignSessionUpdated, |
239 sync_enabled_weak_factory_.GetWeakPtr()), | 239 sync_enabled_weak_factory_.GetWeakPtr()), |
240 base::Bind(&ProfileSyncService::TriggerRefresh, | 240 base::Bind(&ProfileSyncService::TriggerRefresh, |
241 sync_enabled_weak_factory_.GetWeakPtr(), | 241 sync_enabled_weak_factory_.GetWeakPtr(), |
242 syncer::ModelTypeSet(syncer::SESSIONS))); | 242 syncer::ModelTypeSet(syncer::SESSIONS))); |
243 | 243 |
244 if (base::FeatureList::IsEnabled(switches::kSyncUSSDeviceInfo)) { | 244 if (base::FeatureList::IsEnabled(switches::kSyncUSSDeviceInfo)) { |
245 // TODO(skym): Stop creating leveldb files when signed out. | |
246 // TODO(skym): Verify using AsUTF8Unsafe is okay here. Should work as long | |
247 // as the Local State file is guaranteed to be UTF-8. | |
248 const syncer::ModelTypeStoreFactory& store_factory = | 245 const syncer::ModelTypeStoreFactory& store_factory = |
249 GetModelTypeStoreFactory(syncer::DEVICE_INFO, base_directory_, | 246 GetModelTypeStoreFactory(syncer::DEVICE_INFO, base_directory_); |
250 sync_client_->GetBlockingPool()); | |
251 device_info_sync_bridge_ = base::MakeUnique<DeviceInfoSyncBridge>( | 247 device_info_sync_bridge_ = base::MakeUnique<DeviceInfoSyncBridge>( |
252 local_device_.get(), store_factory, | 248 local_device_.get(), store_factory, |
253 base::BindRepeating( | 249 base::BindRepeating( |
254 &ModelTypeChangeProcessor::Create, | 250 &ModelTypeChangeProcessor::Create, |
255 base::BindRepeating(&syncer::ReportUnrecoverableError, channel_))); | 251 base::BindRepeating(&syncer::ReportUnrecoverableError, channel_))); |
256 } else { | 252 } else { |
257 device_info_sync_service_ = | 253 device_info_sync_service_ = |
258 base::MakeUnique<DeviceInfoSyncService>(local_device_.get()); | 254 base::MakeUnique<DeviceInfoSyncService>(local_device_.get()); |
259 } | 255 } |
260 | 256 |
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1674 | 1670 |
1675 void ProfileSyncService::SetPlatformSyncAllowedProvider( | 1671 void ProfileSyncService::SetPlatformSyncAllowedProvider( |
1676 const PlatformSyncAllowedProvider& platform_sync_allowed_provider) { | 1672 const PlatformSyncAllowedProvider& platform_sync_allowed_provider) { |
1677 DCHECK(thread_checker_.CalledOnValidThread()); | 1673 DCHECK(thread_checker_.CalledOnValidThread()); |
1678 platform_sync_allowed_provider_ = platform_sync_allowed_provider; | 1674 platform_sync_allowed_provider_ = platform_sync_allowed_provider; |
1679 } | 1675 } |
1680 | 1676 |
1681 // static | 1677 // static |
1682 syncer::ModelTypeStoreFactory ProfileSyncService::GetModelTypeStoreFactory( | 1678 syncer::ModelTypeStoreFactory ProfileSyncService::GetModelTypeStoreFactory( |
1683 ModelType type, | 1679 ModelType type, |
1684 const base::FilePath& base_path, | 1680 const base::FilePath& base_path) { |
1685 base::SequencedWorkerPool* blocking_pool) { | |
1686 // TODO(skym): Verify using AsUTF8Unsafe is okay here. Should work as long | 1681 // TODO(skym): Verify using AsUTF8Unsafe is okay here. Should work as long |
1687 // as the Local State file is guaranteed to be UTF-8. | 1682 // as the Local State file is guaranteed to be UTF-8. |
1688 std::string path = FormatSharedModelTypeStorePath(base_path).AsUTF8Unsafe(); | 1683 const std::string path = |
1689 base::SequencedWorkerPool::SequenceToken sequence_token = | 1684 FormatSharedModelTypeStorePath(base_path).AsUTF8Unsafe(); |
1690 blocking_pool->GetNamedSequenceToken(path); | 1685 return base::Bind(&ModelTypeStore::CreateStore, type, path); |
1691 scoped_refptr<base::SequencedTaskRunner> task_runner = | |
1692 blocking_pool->GetSequencedTaskRunnerWithShutdownBehavior( | |
1693 blocking_pool->GetNamedSequenceToken(path), | |
1694 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | |
1695 return base::Bind(&ModelTypeStore::CreateStore, type, path, task_runner); | |
1696 } | 1686 } |
1697 | 1687 |
1698 void ProfileSyncService::ConfigureDataTypeManager() { | 1688 void ProfileSyncService::ConfigureDataTypeManager() { |
1699 // Don't configure datatypes if the setup UI is still on the screen - this | 1689 // Don't configure datatypes if the setup UI is still on the screen - this |
1700 // is to help multi-screen setting UIs (like iOS) where they don't want to | 1690 // is to help multi-screen setting UIs (like iOS) where they don't want to |
1701 // start syncing data until the user is done configuring encryption options, | 1691 // start syncing data until the user is done configuring encryption options, |
1702 // etc. ReconfigureDatatypeManager() will get called again once the UI calls | 1692 // etc. ReconfigureDatatypeManager() will get called again once the UI calls |
1703 // SetSetupInProgress(false). | 1693 // SetSetupInProgress(false). |
1704 if (!CanConfigureDataTypes()) { | 1694 if (!CanConfigureDataTypes()) { |
1705 // If we can't configure the data type manager yet, we should still notify | 1695 // If we can't configure the data type manager yet, we should still notify |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2428 return; | 2418 return; |
2429 | 2419 |
2430 DCHECK(startup_controller_->IsSetupInProgress()); | 2420 DCHECK(startup_controller_->IsSetupInProgress()); |
2431 startup_controller_->SetSetupInProgress(false); | 2421 startup_controller_->SetSetupInProgress(false); |
2432 | 2422 |
2433 if (IsEngineInitialized()) | 2423 if (IsEngineInitialized()) |
2434 ReconfigureDatatypeManager(); | 2424 ReconfigureDatatypeManager(); |
2435 NotifyObservers(); | 2425 NotifyObservers(); |
2436 } | 2426 } |
2437 } // namespace browser_sync | 2427 } // namespace browser_sync |
OLD | NEW |