Commit d5bf7dd2 authored by tzik's avatar tzik Committed by Commit bot

[SyncFS] Initialize SyncWorker when sync is enabled.

If a service is enabled after initialization failed,
 SyncEngine didn't try initializing SyncWorker again, and that makes SyncFS stuck.

BUG=402356

Review URL: https://codereview.chromium.org/470403004

Cr-Commit-Position: refs/heads/master@{#292831}
parent add64ae0
......@@ -576,16 +576,37 @@ void SyncEngine::DumpDatabase(const ListCallback& callback) {
}
void SyncEngine::SetSyncEnabled(bool sync_enabled) {
if (sync_enabled_ == sync_enabled)
return;
sync_enabled_ = sync_enabled;
if (sync_enabled_) {
if (!sync_worker_)
Initialize();
// Have no login credential.
if (!sync_worker_)
return;
worker_task_runner_->PostTask(
FROM_HERE,
base::Bind(&SyncWorkerInterface::SetSyncEnabled,
base::Unretained(sync_worker_.get()),
sync_enabled_));
return;
}
if (!sync_worker_)
return;
// TODO(tzik): Consider removing SyncWorkerInterface::SetSyncEnabled and
// let SyncEngine handle the flag.
worker_task_runner_->PostTask(
FROM_HERE,
base::Bind(&SyncWorkerInterface::SetSyncEnabled,
base::Unretained(sync_worker_.get()),
sync_enabled));
sync_enabled_));
Reset();
}
void SyncEngine::PromoteDemotedChanges(const base::Closure& callback) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment