Commit 68623971 authored by zea's avatar zea Committed by Commit bot

[Sync] Stop purging sync data on restart for users who haven't finished setup.

Users who don't have first setup complete, but are signed in without sync
suppressed, are in an invalid state, likely from previous issues in the
sign in flow. We were purging their sync data over-aggressively on startup
previously, causing a resync of the control types on each restart. Now we
simply leave the data around, and only purge if the user is actually signed
out.

BUG=624915

Review-Url: https://codereview.chromium.org/2113453006
Cr-Commit-Position: refs/heads/master@{#403382}
parent 2097443a
...@@ -357,8 +357,8 @@ void ProfileSyncService::Initialize() { ...@@ -357,8 +357,8 @@ void ProfileSyncService::Initialize() {
RegisterAuthNotifications(); RegisterAuthNotifications();
if (!IsFirstSetupComplete() || !IsSignedIn()) { if (!IsSignedIn()) {
// Clean up in case of previous crash / setup abort / signout. // Clean up in case of previous crash during signout.
StopImpl(CLEAR_DATA); StopImpl(CLEAR_DATA);
} }
......
...@@ -415,6 +415,27 @@ TEST_F(ProfileSyncServiceTest, SuccessfulInitialization) { ...@@ -415,6 +415,27 @@ TEST_F(ProfileSyncServiceTest, SuccessfulInitialization) {
EXPECT_TRUE(service()->IsSyncActive()); EXPECT_TRUE(service()->IsSyncActive());
} }
// Verify that an initialization where first setup is not complete does not
// purge preferences and/or the directory.
TEST_F(ProfileSyncServiceTest, NeedsConfirmation) {
prefs()->SetManagedPref(sync_driver::prefs::kSyncManaged,
new base::FundamentalValue(false));
IssueTestTokens();
CreateService(ProfileSyncService::MANUAL_START);
ExpectSyncBackendHostCreation(1);
sync_driver::SyncPrefs sync_prefs(prefs());
base::Time now = base::Time::Now();
sync_prefs.SetLastSyncedTime(now);
sync_prefs.SetKeepEverythingSynced(true);
service()->Initialize();
EXPECT_FALSE(service()->IsSyncActive());
// The last sync time shouldn't be cleared.
// TODO(zea): figure out a way to check that the directory itself wasn't
// cleared.
EXPECT_EQ(now, sync_prefs.GetLastSyncedTime());
}
// Verify that the SetSetupInProgress function call updates state // Verify that the SetSetupInProgress function call updates state
// and notifies observers. // and notifies observers.
TEST_F(ProfileSyncServiceTest, SetupInProgress) { TEST_F(ProfileSyncServiceTest, SetupInProgress) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment