Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: components/browser_sync/profile_sync_service.cc

Issue 2732333003: [Sync] ModelTypeStore factory shouldn't require valid PSS to function correctly (Closed)
Patch Set: Address comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/browser_sync/profile_sync_service.h ('k') | components/browser_sync/profile_sync_test_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/browser_sync/profile_sync_service.cc
diff --git a/components/browser_sync/profile_sync_service.cc b/components/browser_sync/profile_sync_service.cc
index 34924acfd233a60fea08d540a4569438d8379b58..9e63dfeb33a7c7b80180c7a2e40eb792d63a7bea 100644
--- a/components/browser_sync/profile_sync_service.cc
+++ b/components/browser_sync/profile_sync_service.cc
@@ -148,9 +148,6 @@ const net::BackoffEntry::Policy kRequestAccessTokenBackoffPolicy = {
false,
};
-const base::FilePath::CharType kLevelDBFolderName[] =
- FILE_PATH_LITERAL("LevelDB");
-
} // namespace
ProfileSyncService::InitParams::InitParams() = default;
@@ -171,7 +168,6 @@ ProfileSyncService::ProfileSyncService(InitParams init_params)
network_time_update_callback_(
std::move(init_params.network_time_update_callback)),
url_request_context_(init_params.url_request_context),
- blocking_task_runner_(std::move(init_params.blocking_task_runner)),
is_first_time_sync_configure_(false),
engine_initialized_(false),
sync_disabled_by_admin_(false),
@@ -249,8 +245,11 @@ void ProfileSyncService::Initialize() {
// TODO(skym): Stop creating leveldb files when signed out.
// TODO(skym): Verify using AsUTF8Unsafe is okay here. Should work as long
// as the Local State file is guaranteed to be UTF-8.
+ const syncer::ModelTypeStoreFactory& store_factory =
+ GetModelTypeStoreFactory(syncer::DEVICE_INFO, base_directory_,
+ sync_client_->GetBlockingPool());
device_info_sync_bridge_ = base::MakeUnique<DeviceInfoSyncBridge>(
- local_device_.get(), GetModelTypeStoreFactory(syncer::DEVICE_INFO),
+ local_device_.get(), store_factory,
base::BindRepeating(
&ModelTypeChangeProcessor::Create,
base::BindRepeating(&syncer::ReportUnrecoverableError, channel_)));
@@ -558,7 +557,7 @@ void ProfileSyncService::StartUpSlowEngineComponents() {
engine_.reset(sync_client_->GetSyncApiComponentFactory()->CreateSyncEngine(
debug_identifier_, invalidator, sync_prefs_.AsWeakPtr(),
- sync_data_folder_));
+ FormatSyncDataPath(base_directory_)));
// Clear any old errors the first time sync starts.
if (!IsFirstSetupComplete())
@@ -694,7 +693,7 @@ void ProfileSyncService::ShutdownImpl(syncer::ShutdownReason reason) {
sync_thread_->task_runner()->PostTask(
FROM_HERE,
base::Bind(&syncer::syncable::Directory::DeleteDirectoryFiles,
- sync_data_folder_));
+ FormatSyncDataPath(base_directory_)));
}
return;
}
@@ -930,7 +929,7 @@ void ProfileSyncService::OnEngineInitialized(
// Initialize local device info.
local_device_->Initialize(cache_guid, signin_scoped_device_id,
- blocking_task_runner_);
+ sync_client_->GetBlockingPool());
if (protocol_event_observers_.might_have_observers()) {
engine_->RequestBufferedProtocolEventsAndEnableForwarding();
@@ -1670,12 +1669,21 @@ void ProfileSyncService::SetPlatformSyncAllowedProvider(
platform_sync_allowed_provider_ = platform_sync_allowed_provider;
}
+// static
syncer::ModelTypeStoreFactory ProfileSyncService::GetModelTypeStoreFactory(
- ModelType type) {
- return base::Bind(&ModelTypeStore::CreateStore, type,
- sync_data_folder_.Append(base::FilePath(kLevelDBFolderName))
- .AsUTF8Unsafe(),
- blocking_task_runner_);
+ ModelType type,
+ const base::FilePath& base_path,
+ base::SequencedWorkerPool* blocking_pool) {
+ // TODO(skym): Verify using AsUTF8Unsafe is okay here. Should work as long
+ // as the Local State file is guaranteed to be UTF-8.
+ std::string path = FormatSharedModelTypeStorePath(base_path).AsUTF8Unsafe();
+ base::SequencedWorkerPool::SequenceToken sequence_token =
+ blocking_pool->GetNamedSequenceToken(path);
+ scoped_refptr<base::SequencedTaskRunner> task_runner =
+ blocking_pool->GetSequencedTaskRunnerWithShutdownBehavior(
+ blocking_pool->GetNamedSequenceToken(path),
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
+ return base::Bind(&ModelTypeStore::CreateStore, type, path, task_runner);
}
void ProfileSyncService::ConfigureDataTypeManager() {
@@ -2330,7 +2338,7 @@ void ProfileSyncService::FlushDirectory() const {
base::FilePath ProfileSyncService::GetDirectoryPathForTest() const {
DCHECK(thread_checker_.CalledOnValidThread());
- return sync_data_folder_;
+ return FormatSyncDataPath(base_directory_);
}
base::MessageLoop* ProfileSyncService::GetSyncLoopForTest() const {
« no previous file with comments | « components/browser_sync/profile_sync_service.h ('k') | components/browser_sync/profile_sync_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698