• rsimha@chromium.org's avatar
    [sync] Auto-heal sync credential cache on startup, and no longer rely on NOTIFICATION_PREF_CHANGED · a8fa4cae
    rsimha@chromium.org authored
    CredentialCacheService listens for initial sync configuration during
    sign in by directly observing sync preferences in the pref store. This
    is not good because sync preferences are not always re-written
    during sign in, and we cannot rely on NOTIFICATION_PREF_CHANGED.
    
    In addition, if during startup, we find an older version of a credential
    cache with some fields missing (like the last_updated_time), we could
    run into bugs due to the missing fields.
    
    This patch does the following:
    
    1) Makes CredentialCacheService listen to the notification
       NOTIFICATION_SYNC_CONFIGURE_START for sign-in, restart and
       reconfigure scenarios.
    2) No longer relies on NOTIFICATION_PREF_CHANGED for detecting
       changes to sync datatype preferences.
    2) Freshly writes any missing sync credentials during startup to
       auto-heal the cache in case chrome crashed during a previous run,
       or if a signed-in user upgraded chrome from an older version that
       didn't support credential caching or was missing some newer fields.
    3) Adds caching support for both sync encryption tokens:
       kSyncEncryptionBootstrapToken and kSyncKeystoreEncryptionBootstrapToken,
       and makes the required logic changes to sign in / reconfigure with
       one or the other.
    4) Modifies PackAndUpdateStringPref and UpdateBooleanPref to only
       update the cache if the new value being written is different from the
       existing value.
    5) Other misc. changes to support the design described above.
    
    BUG=142550, 143214
    TEST=Sign in to sync, sign out, exit chrome, delete the credential cache from the profile directory or merely delete some fields, and sign in again. All sync preferences must get written to the credential cache.
    
    Review URL: https://chromiumcodereview.appspot.com/10829310
    
    git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152157 0039d316-1c4b-4281-b951-d872f2087c98
    a8fa4cae
credential_cache_service_win.cc 33.7 KB