Chromium Code Reviews| Index: chrome/browser/sync_file_system/drive_backend/sync_engine.cc |
| diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine.cc |
| index f85825f306c60444a9f94a270f0b9a49c5e13ed3..33b66b8cb5f580bcd7966410dfdf1f914845d32a 100644 |
| --- a/chrome/browser/sync_file_system/drive_backend/sync_engine.cc |
| +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine.cc |
| @@ -578,16 +578,39 @@ 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; |
| + } |
| + |
| + DCHECK(!sync_enabled_); |
|
peria
2014/08/21 08:34:33
nit: This DCHECK looks unnecessary
tzik
2014/08/21 09:23:35
Done.
|
| + |
| 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) { |