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

Unified Diff: chrome/browser/sync_file_system/drive_backend/sync_engine.cc

Issue 470403004: [SyncFS] Initialize SyncWorker when sync is enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c2ca930e24397fe9fbef61f66455aa41de0dfaf4..320e6f6604a0101caa012ed577ada6b33bcf01d9 100644
--- a/chrome/browser/sync_file_system/drive_backend/sync_engine.cc
+++ b/chrome/browser/sync_file_system/drive_backend/sync_engine.cc
@@ -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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698