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

Unified Diff: components/sync_driver/startup_controller.cc

Issue 2159453002: [Sync] Don't start up sync when FirstSetupCompleted is false and no setup in progress (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self review Created 4 years, 5 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
Index: components/sync_driver/startup_controller.cc
diff --git a/components/sync_driver/startup_controller.cc b/components/sync_driver/startup_controller.cc
index 9dffa5cf22269d4bfc0f76c3e62da687daa81f1e..8eabee19fad2d6c398d975b1fb6925012086246b 100644
--- a/components/sync_driver/startup_controller.cc
+++ b/components/sync_driver/startup_controller.cc
@@ -76,7 +76,7 @@ void StartupController::Reset(const syncer::ModelTypeSet registered_types) {
void StartupController::SetSetupInProgress(bool setup_in_progress) {
setup_in_progress_ = setup_in_progress;
if (setup_in_progress_) {
- TryStart();
+ TryStart(false);
}
}
@@ -113,7 +113,10 @@ void StartupController::OverrideFallbackTimeoutForTest(
fallback_timeout_ = timeout;
}
-bool StartupController::TryStart() {
+bool StartupController::TryStart(bool request_immediate) {
+ if (request_immediate)
+ received_start_request_ = true;
+
if (!can_start_.Run())
return false;
@@ -121,13 +124,18 @@ bool StartupController::TryStart() {
//
// - a datatype has requested an immediate start of sync, or
// - sync needs to start up the backend immediately to provide control state
- // and encryption information to the UI, or
- // - this is the first time sync is ever starting up.
- if (received_start_request_ || setup_in_progress_ ||
- !sync_prefs_->IsFirstSetupComplete()) {
+ // and encryption information to the UI.
+ // Do not start up the sync backend if setup has not completed and isn't
+ // in progress.
+ if (setup_in_progress_) {
return StartUp(STARTUP_IMMEDIATE);
+ } else if (sync_prefs_->IsFirstSetupComplete()) {
+ if (received_start_request_)
+ return StartUp(STARTUP_IMMEDIATE);
+ else
maxbogue 2016/07/15 21:44:48 nit: this is somewhat personal style but I very mu
Nicolas Zea 2016/07/15 22:42:22 Consistency within the file is important in this c
+ return StartUp(STARTUP_BACKEND_DEFERRED);
} else {
- return StartUp(STARTUP_BACKEND_DEFERRED);
+ return false;
}
}
@@ -154,7 +162,7 @@ void StartupController::OnFallbackStartupTimerExpired() {
TRIGGER_FALLBACK_TIMER,
MAX_TRIGGER_VALUE);
received_start_request_ = true;
- TryStart();
+ TryStart(false);
}
std::string StartupController::GetBackendInitializationStateString() const {
@@ -192,7 +200,7 @@ void StartupController::OnDataTypeRequestsSyncStartup(syncer::ModelType type) {
MAX_TRIGGER_VALUE);
}
received_start_request_ = true;
- TryStart();
+ TryStart(false);
}
} // namespace browser_sync

Powered by Google App Engine
This is Rietveld 408576698