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

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: Android fix attempt 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
« no previous file with comments | « components/sync_driver/startup_controller.h ('k') | components/sync_driver/startup_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..26b4ef7e55ea657a6638c07065ab8966023f510c 100644
--- a/components/sync_driver/startup_controller.cc
+++ b/components/sync_driver/startup_controller.cc
@@ -39,7 +39,8 @@ enum DeferredInitTrigger {
StartupController::StartupController(const sync_driver::SyncPrefs* sync_prefs,
base::Callback<bool()> can_start,
base::Closure start_backend)
- : received_start_request_(false),
+ : bypass_setup_complete_(false),
+ received_start_request_(false),
setup_in_progress_(false),
sync_prefs_(sync_prefs),
can_start_(can_start),
@@ -66,6 +67,7 @@ StartupController::~StartupController() {}
void StartupController::Reset(const syncer::ModelTypeSet registered_types) {
received_start_request_ = false;
+ bypass_setup_complete_ = false;
start_up_time_ = base::Time();
start_backend_time_ = base::Time();
// Don't let previous timers affect us post-reset.
@@ -121,16 +123,25 @@ 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, unless told to otherwise.
+ if (setup_in_progress_) {
return StartUp(STARTUP_IMMEDIATE);
+ } else if (sync_prefs_->IsFirstSetupComplete() || bypass_setup_complete_) {
+ return StartUp(received_start_request_ ? STARTUP_IMMEDIATE
+ : STARTUP_BACKEND_DEFERRED);
} else {
- return StartUp(STARTUP_BACKEND_DEFERRED);
+ return false;
}
}
+bool StartupController::TryStartImmediately() {
+ received_start_request_ = true;
+ bypass_setup_complete_ = true;
+ return TryStart();
+}
+
void StartupController::RecordTimeDeferred() {
DCHECK(!start_up_time_.is_null());
base::TimeDelta time_deferred = base::Time::Now() - start_up_time_;
« no previous file with comments | « components/sync_driver/startup_controller.h ('k') | components/sync_driver/startup_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698