OLD | NEW |
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 if (raw_id.empty()) { | 65 if (raw_id.empty()) { |
66 LogMachineIdState(ID_GENERATION_FAILED); | 66 LogMachineIdState(ID_GENERATION_FAILED); |
67 local_state->ClearPref(prefs::kMetricsMachineId); | 67 local_state->ClearPref(prefs::kMetricsMachineId); |
68 return; | 68 return; |
69 } | 69 } |
70 | 70 |
71 int hashed_id = HashRawId(raw_id); | 71 int hashed_id = HashRawId(raw_id); |
72 | 72 |
73 MachineIdState id_state = ID_NO_STORED_VALUE; | 73 MachineIdState id_state = ID_NO_STORED_VALUE; |
74 if (local_state->HasPrefPath(prefs::kMetricsMachineId)) { | 74 if (local_state->HasPrefPath(prefs::kMetricsMachineId)) { |
75 id_state = local_state->GetInteger(prefs::kMetricsMachineId) == hashed_id ? | 75 if (local_state->GetInteger(prefs::kMetricsMachineId) != hashed_id) { |
76 ID_UNCHANGED : ID_CHANGED; | 76 id_state = ID_CHANGED; |
| 77 // TODO(jwd): Use a callback to set the reset pref. That way |
| 78 // ClonedInstallDetector doesn't need to know about this pref. |
| 79 local_state->SetBoolean(prefs::kMetricsResetIds, true); |
| 80 } else { |
| 81 id_state = ID_UNCHANGED; |
| 82 } |
77 } | 83 } |
78 | 84 |
79 LogMachineIdState(id_state); | 85 LogMachineIdState(id_state); |
80 | 86 |
81 local_state->SetInteger(prefs::kMetricsMachineId, hashed_id); | 87 local_state->SetInteger(prefs::kMetricsMachineId, hashed_id); |
82 } | 88 } |
83 | 89 |
84 // static | 90 // static |
85 void ClonedInstallDetector::RegisterPrefs(PrefRegistrySimple* registry) { | 91 void ClonedInstallDetector::RegisterPrefs(PrefRegistrySimple* registry) { |
86 registry->RegisterIntegerPref(prefs::kMetricsMachineId, 0); | 92 registry->RegisterIntegerPref(prefs::kMetricsMachineId, 0); |
87 } | 93 } |
88 | 94 |
89 } // namespace metrics | 95 } // namespace metrics |
OLD | NEW |