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

Side by Side Diff: chrome/browser/metrics/cloned_install_detector.cc

Issue 213363004: Resetting metrics ids on clump detection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/metrics/cloned_install_detector.h" 5 #include "chrome/browser/metrics/cloned_install_detector.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/prefs/pref_registry_simple.h" 9 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 } // namespace 43 } // namespace
44 44
45 ClonedInstallDetector::ClonedInstallDetector(MachineIdProvider* raw_id_provider) 45 ClonedInstallDetector::ClonedInstallDetector(MachineIdProvider* raw_id_provider)
46 : raw_id_provider_(raw_id_provider), 46 : raw_id_provider_(raw_id_provider),
47 weak_ptr_factory_(this) {} 47 weak_ptr_factory_(this) {}
48 48
49 ClonedInstallDetector::~ClonedInstallDetector() {} 49 ClonedInstallDetector::~ClonedInstallDetector() {}
50 50
51 void ClonedInstallDetector::CheckForClonedInstall(PrefService* local_state) { 51 void ClonedInstallDetector::CheckForClonedInstall(PrefService* local_state) {
52 content::BrowserThread::PostTaskAndReplyWithResult( 52 DVLOG(2) << "\n\nabout to post some tasks.\n\n";
53 bool res = content::BrowserThread::PostTaskAndReplyWithResult(
53 content::BrowserThread::FILE, 54 content::BrowserThread::FILE,
54 FROM_HERE, 55 FROM_HERE,
55 base::Bind(&metrics::MachineIdProvider::GetMachineId, 56 base::Bind(&metrics::MachineIdProvider::GetMachineId,
56 raw_id_provider_), 57 raw_id_provider_),
57 base::Bind(&metrics::ClonedInstallDetector::SaveMachineId, 58 base::Bind(&metrics::ClonedInstallDetector::SaveMachineId,
58 weak_ptr_factory_.GetWeakPtr(), 59 weak_ptr_factory_.GetWeakPtr(),
59 local_state)); 60 local_state));
61 DVLOG(2) << "\n\ntask posted? " << res << "\n\n";
60 } 62 }
61 63
62 void ClonedInstallDetector::SaveMachineId( 64 void ClonedInstallDetector::SaveMachineId(
63 PrefService* local_state, 65 PrefService* local_state,
64 std::string raw_id) { 66 std::string raw_id) {
67 DVLOG(2) << "\n\nsaving id: " << raw_id << "\n\n";
65 if (raw_id.empty()) { 68 if (raw_id.empty()) {
66 LogMachineIdState(ID_GENERATION_FAILED); 69 LogMachineIdState(ID_GENERATION_FAILED);
67 local_state->ClearPref(prefs::kMetricsMachineId); 70 local_state->ClearPref(prefs::kMetricsMachineId);
68 return; 71 return;
69 } 72 }
70 73
71 int hashed_id = HashRawId(raw_id); 74 int hashed_id = HashRawId(raw_id);
72 75
73 MachineIdState id_state = ID_NO_STORED_VALUE; 76 MachineIdState id_state = ID_NO_STORED_VALUE;
74 if (local_state->HasPrefPath(prefs::kMetricsMachineId)) { 77 if (local_state->HasPrefPath(prefs::kMetricsMachineId)) {
75 id_state = local_state->GetInteger(prefs::kMetricsMachineId) == hashed_id ? 78 if (local_state->GetInteger(prefs::kMetricsMachineId) != hashed_id) {
76 ID_UNCHANGED : ID_CHANGED; 79 id_state = ID_CHANGED;
80 local_state->SetBoolean(prefs::kMetricsResetIds, true);
Alexei Svitkine (slow) 2014/03/28 16:30:48 Can this be a callback passed to this class at con
jwd 2014/03/28 18:59:21 Done.
81 } else {
82 id_state = ID_UNCHANGED;
83 }
77 } 84 }
78 85
79 LogMachineIdState(id_state); 86 LogMachineIdState(id_state);
80 87
81 local_state->SetInteger(prefs::kMetricsMachineId, hashed_id); 88 local_state->SetInteger(prefs::kMetricsMachineId, hashed_id);
82 } 89 }
83 90
84 // static 91 // static
85 void ClonedInstallDetector::RegisterPrefs(PrefRegistrySimple* registry) { 92 void ClonedInstallDetector::RegisterPrefs(PrefRegistrySimple* registry) {
86 registry->RegisterIntegerPref(prefs::kMetricsMachineId, 0); 93 registry->RegisterIntegerPref(prefs::kMetricsMachineId, 0);
87 } 94 }
88 95
89 } // namespace metrics 96 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698