summaryrefslogtreecommitdiffstats
path: root/components/sync_driver/device_info_sync_service.cc
diff options
context:
space:
mode:
authorpavely <pavely@chromium.org>2015-04-27 19:11:44 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-28 02:11:46 +0000
commita3d731e5e0cd0a687cd0883b0d79f0f02bc4a069 (patch)
treec7ccd6792e8eb51a946429ca23f8b5fddb392e1e /components/sync_driver/device_info_sync_service.cc
parentc5ab93d728a42b9eeeea4994097aed1b2fcea478 (diff)
downloadchromium_src-a3d731e5e0cd0a687cd0883b0d79f0f02bc4a069.zip
chromium_src-a3d731e5e0cd0a687cd0883b0d79f0f02bc4a069.tar.gz
chromium_src-a3d731e5e0cd0a687cd0883b0d79f0f02bc4a069.tar.bz2
[Sync] Record histogram for mismatched device_ids
Server side logs indicate that device_id passed in refresh token annotation request differs from device_id recorded on LST. Scenario is not clear how device_id changes between minting LST and sending annotation request. It is possible that some programs/tools restore preferences to some early state therefore removing devic_id from preferences and causing generation of new device_id. This change adds histogram to see how often this happens. R=stanisc@chromium.org BUG=481596 Review URL: https://codereview.chromium.org/1082853007 Cr-Commit-Position: refs/heads/master@{#327218}
Diffstat (limited to 'components/sync_driver/device_info_sync_service.cc')
-rw-r--r--components/sync_driver/device_info_sync_service.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/components/sync_driver/device_info_sync_service.cc b/components/sync_driver/device_info_sync_service.cc
index 76ea831..fb441a4 100644
--- a/components/sync_driver/device_info_sync_service.cc
+++ b/components/sync_driver/device_info_sync_service.cc
@@ -4,6 +4,7 @@
#include "components/sync_driver/device_info_sync_service.h"
+#include "base/metrics/histogram_macros.h"
#include "base/strings/stringprintf.h"
#include "components/sync_driver/local_device_info_provider.h"
#include "sync/api/sync_change.h"
@@ -21,6 +22,38 @@ using syncer::SyncDataList;
using syncer::SyncErrorFactory;
using syncer::SyncMergeResult;
+namespace {
+
+// TODO(pavely): Remove histogram once device_id mismatch is understood
+// (crbug/481596).
+// When signin_scoped_device_id from pref doesn't match the one in
+// DeviceInfoSpecfics record histogram telling if sync or pref copy was empty.
+// This will indicate how often such mismatch happens and what was the state
+// before.
+enum DeviceIdMismatchForHistogram {
+ DEVICE_ID_MISMATCH_BOTH_NONEMPTY = 0,
+ DEVICE_ID_MISMATCH_SYNC_EMPTY,
+ DEVICE_ID_MISMATCH_PREF_EMPTY,
+ DEVICE_ID_MISMATCH_COUNT,
+};
+
+void RecordDeviceIdChangedHistogram(const std::string& device_id_from_sync,
+ const std::string& device_id_from_pref) {
+ DCHECK(device_id_from_sync != device_id_from_pref);
+ DeviceIdMismatchForHistogram device_id_mismatch_for_histogram =
+ DEVICE_ID_MISMATCH_BOTH_NONEMPTY;
+ if (device_id_from_sync.empty()) {
+ device_id_mismatch_for_histogram = DEVICE_ID_MISMATCH_SYNC_EMPTY;
+ } else if (device_id_from_pref.empty()) {
+ device_id_mismatch_for_histogram = DEVICE_ID_MISMATCH_PREF_EMPTY;
+ }
+ UMA_HISTOGRAM_ENUMERATION("Sync.DeviceIdMismatchDetails",
+ device_id_mismatch_for_histogram,
+ DEVICE_ID_MISMATCH_COUNT);
+}
+
+} // namespace
+
DeviceInfoSyncService::DeviceInfoSyncService(
LocalDeviceInfoProvider* local_device_info_provider)
: local_device_backup_time_(-1),
@@ -85,6 +118,14 @@ SyncMergeResult DeviceInfoSyncService::MergeDataAndStartSyncing(
if (!has_local_device_backup_time() && has_synced_backup_time) {
set_local_device_backup_time(synced_backup_time);
}
+ // TODO(pavely): Remove histogram once device_id mismatch is understood
+ // (crbug/481596).
+ if (synced_local_device_info->signin_scoped_device_id() !=
+ local_device_info->signin_scoped_device_id()) {
+ RecordDeviceIdChangedHistogram(
+ synced_local_device_info->signin_scoped_device_id(),
+ local_device_info->signin_scoped_device_id());
+ }
// Store the synced device info for the local device only
// it is the same as the local info. Otherwise store the local