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 "components/metrics/cloned_install_detector.h" | 5 #include "components/metrics/cloned_install_detector.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <string> | 9 #include <string> |
8 | 10 |
9 #include "base/bind.h" | 11 #include "base/bind.h" |
10 #include "base/location.h" | 12 #include "base/location.h" |
11 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
12 #include "base/metrics/metrics_hashes.h" | 14 #include "base/metrics/metrics_hashes.h" |
13 #include "base/prefs/pref_registry_simple.h" | 15 #include "base/prefs/pref_registry_simple.h" |
14 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
15 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
16 #include "base/task_runner_util.h" | 18 #include "base/task_runner_util.h" |
17 #include "components/metrics/machine_id_provider.h" | 19 #include "components/metrics/machine_id_provider.h" |
18 #include "components/metrics/metrics_pref_names.h" | 20 #include "components/metrics/metrics_pref_names.h" |
19 | 21 |
20 namespace metrics { | 22 namespace metrics { |
21 | 23 |
22 namespace { | 24 namespace { |
23 | 25 |
24 uint32 HashRawId(const std::string& value) { | 26 uint32_t HashRawId(const std::string& value) { |
25 uint64 hash = base::HashMetricName(value); | 27 uint64_t hash = base::HashMetricName(value); |
26 | 28 |
27 // Only use 24 bits from the 64-bit hash. | 29 // Only use 24 bits from the 64-bit hash. |
28 return hash & ((1 << 24) - 1); | 30 return hash & ((1 << 24) - 1); |
29 } | 31 } |
30 | 32 |
31 // State of the generated machine id in relation to the previously stored value. | 33 // State of the generated machine id in relation to the previously stored value. |
32 // Note: UMA histogram enum - don't re-order or remove entries | 34 // Note: UMA histogram enum - don't re-order or remove entries |
33 enum MachineIdState { | 35 enum MachineIdState { |
34 ID_GENERATION_FAILED, | 36 ID_GENERATION_FAILED, |
35 ID_NO_STORED_VALUE, | 37 ID_NO_STORED_VALUE, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 92 |
91 local_state->SetInteger(prefs::kMetricsMachineId, hashed_id); | 93 local_state->SetInteger(prefs::kMetricsMachineId, hashed_id); |
92 } | 94 } |
93 | 95 |
94 // static | 96 // static |
95 void ClonedInstallDetector::RegisterPrefs(PrefRegistrySimple* registry) { | 97 void ClonedInstallDetector::RegisterPrefs(PrefRegistrySimple* registry) { |
96 registry->RegisterIntegerPref(prefs::kMetricsMachineId, 0); | 98 registry->RegisterIntegerPref(prefs::kMetricsMachineId, 0); |
97 } | 99 } |
98 | 100 |
99 } // namespace metrics | 101 } // namespace metrics |
OLD | NEW |