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

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: 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 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) {
« 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