Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
[Sync] Add Sync.InitialState UMA metric.
Browse files Browse the repository at this point in the history
We don't know for sure whether sync will succeed at starting up at
initialization time, but we can inspect and report on the state of
various flags.

BUG=555113

Review URL: https://codereview.chromium.org/1463583008

Cr-Commit-Position: refs/heads/master@{#362455}
  • Loading branch information
maxbogue authored and Commit bot committed Dec 1, 2015
1 parent 2bd1f02 commit 33a3aac
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
17 changes: 17 additions & 0 deletions components/browser_sync/browser/profile_sync_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,23 @@ void ProfileSyncService::Initialize() {

sync_prefs_.AddSyncPrefObserver(this);

SyncInitialState sync_state = CAN_START;
if (!IsSignedIn()) {
sync_state = NOT_SIGNED_IN;
} else if (IsManaged()) {
sync_state = IS_MANAGED;
} else if (!IsSyncRequested()) {
if (HasSyncSetupCompleted()) {
sync_state = NOT_REQUESTED;
} else {
sync_state = NOT_REQUESTED_NOT_SETUP;
}
} else if (!HasSyncSetupCompleted()) {
sync_state = NEEDS_CONFIRMATION;
}
UMA_HISTOGRAM_ENUMERATION("Sync.InitialState", sync_state,
SYNC_INITIAL_STATE_LIMIT);

// If sync isn't allowed, the only thing to do is to turn it off.
if (!IsSyncAllowed()) {
RequestStop(CLEAR_DATA);
Expand Down
17 changes: 17 additions & 0 deletions components/browser_sync/browser/profile_sync_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,23 @@ class ProfileSyncService : public sync_driver::SyncService,
AUTH_ERROR_LIMIT
};

// The initial state of sync, for the Sync.InitialState histogram. Even if
// this value is CAN_START, sync startup might fail for reasons that we may
// want to consider logging in the future, such as sync being disabled via
// Google Dashboard (birthday error), a passphrase needed for decryption, or
// the version of Chrome being too old. This enum is used to back a UMA
// histogram, and should therefore be treated as append-only.
enum SyncInitialState {
CAN_START, // Sync can attempt to start up.
NOT_SIGNED_IN, // There is no signed in user.
NOT_REQUESTED, // The user turned off sync.
NOT_REQUESTED_NOT_SETUP, // The user turned off sync and setup completed
// is false. Might indicate a stop-and-clear.
NEEDS_CONFIRMATION, // The user must confirm sync settings.
IS_MANAGED, // Sync is disallowed by enterprise policy.
SYNC_INITIAL_STATE_LIMIT
};

friend class ProfileSyncServicePasswordTest;
friend class SyncTest;
friend class TestProfileSyncService;
Expand Down
21 changes: 21 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47690,6 +47690,18 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>

<histogram name="Sync.InitialState" enum="SyncInitialState">
<owner>[email protected]</owner>
<summary>
An approximate state of sync at startup. Logs a few reasons sync definitely
wouldn't be able to start, or that it probably can start. The user having
turned off sync on mobile will be logged as &quot;turned off by user&quot;.
A dashboard stop and clear will fall under &quot;turned off and setup not
completed&quot;. See the SyncInitialState enum in profile_sync_service.h for
more information.
</summary>
</histogram>

<histogram name="Sync.InvalidationSessionsAndroid" enum="BooleanHit">
<owner>[email protected]</owner>
<summary>
Expand Down Expand Up @@ -76856,6 +76868,15 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="3" label="Disabled"/>
</enum>

<enum name="SyncInitialState" type="int">
<int value="0" label="Can attempt to start"/>
<int value="1" label="No signed in user"/>
<int value="2" label="Turned off by user"/>
<int value="3" label="Turned off and setup not completed"/>
<int value="4" label="Must confirm sync settings"/>
<int value="5" label="Disallowed by enterprise policy"/>
</enum>

<enum name="SyncKeystoreDecryptionFailure" type="int">
<int value="0" label="No keystore key"/>
<int value="1" label="Unknown reason"/>
Expand Down

0 comments on commit 33a3aac

Please sign in to comment.