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/user_prefs/tracked/tracked_preference_helper.h" | 5 #include "components/user_prefs/tracked/tracked_preference_helper.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "components/user_prefs/tracked/tracked_preference_histogram_names.h" | 9 #include "components/user_prefs/tracked/tracked_preference_histogram_names.h" |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: " | 44 NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: " |
45 << value_state; | 45 << value_state; |
46 return DONT_RESET; | 46 return DONT_RESET; |
47 } | 47 } |
48 | 48 |
49 bool TrackedPreferenceHelper::IsPersonal() const { | 49 bool TrackedPreferenceHelper::IsPersonal() const { |
50 return personal_; | 50 return personal_; |
51 } | 51 } |
52 | 52 |
53 void TrackedPreferenceHelper::ReportValidationResult( | 53 void TrackedPreferenceHelper::ReportValidationResult( |
54 PrefHashStoreTransaction::ValueState value_state) const { | 54 PrefHashStoreTransaction::ValueState value_state, |
55 HashStoreContentsType validation_type) const { | |
56 std::string histogram_name_prefix; | |
57 switch (validation_type) { | |
58 case HashStoreContentsType::DICTIONARY_HASH_STORE_CONTENTS: | |
59 // Don't add a prefix for consistency with existing metrics. | |
60 histogram_name_prefix = ""; | |
61 break; | |
62 case HashStoreContentsType::REGISTRY_HASH_STORE_CONTENTS: | |
63 histogram_name_prefix = "RegistryStore"; | |
64 break; | |
65 default: | |
66 NOTREACHED() << "Unexpected HashStoreContentsType"; | |
67 } | |
68 | |
69 std::string histogram_name; | |
gab
2016/08/03 18:19:36
const char* histogram_name;
to avoid an unnecessa
proberge
2016/08/04 00:13:47
Done.
| |
55 switch (value_state) { | 70 switch (value_state) { |
56 case PrefHashStoreTransaction::UNCHANGED: | 71 case PrefHashStoreTransaction::UNCHANGED: |
57 UMA_HISTOGRAM_ENUMERATION( | 72 histogram_name = user_prefs::tracked::kTrackedPrefHistogramUnchanged; |
58 user_prefs::tracked::kTrackedPrefHistogramUnchanged, reporting_id_, | 73 break; |
59 reporting_ids_count_); | |
60 return; | |
61 case PrefHashStoreTransaction::CLEARED: | 74 case PrefHashStoreTransaction::CLEARED: |
62 UMA_HISTOGRAM_ENUMERATION( | 75 histogram_name = user_prefs::tracked::kTrackedPrefHistogramCleared; |
63 user_prefs::tracked::kTrackedPrefHistogramCleared, reporting_id_, | 76 break; |
64 reporting_ids_count_); | |
65 return; | |
66 case PrefHashStoreTransaction::SECURE_LEGACY: | 77 case PrefHashStoreTransaction::SECURE_LEGACY: |
67 UMA_HISTOGRAM_ENUMERATION( | 78 histogram_name = |
68 user_prefs::tracked::kTrackedPrefHistogramMigratedLegacyDeviceId, | 79 user_prefs::tracked::kTrackedPrefHistogramMigratedLegacyDeviceId; |
69 reporting_id_, reporting_ids_count_); | 80 break; |
70 return; | |
71 case PrefHashStoreTransaction::CHANGED: | 81 case PrefHashStoreTransaction::CHANGED: |
72 UMA_HISTOGRAM_ENUMERATION( | 82 histogram_name = user_prefs::tracked::kTrackedPrefHistogramChanged; |
73 user_prefs::tracked::kTrackedPrefHistogramChanged, reporting_id_, | 83 break; |
74 reporting_ids_count_); | |
75 return; | |
76 case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE: | 84 case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE: |
77 UMA_HISTOGRAM_ENUMERATION( | 85 histogram_name = user_prefs::tracked::kTrackedPrefHistogramInitialized; |
78 user_prefs::tracked::kTrackedPrefHistogramInitialized, reporting_id_, | 86 break; |
79 reporting_ids_count_); | |
80 return; | |
81 case PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE: | 87 case PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE: |
82 UMA_HISTOGRAM_ENUMERATION( | 88 histogram_name = |
83 user_prefs::tracked::kTrackedPrefHistogramTrustedInitialized, | 89 user_prefs::tracked::kTrackedPrefHistogramTrustedInitialized; |
84 reporting_id_, reporting_ids_count_); | 90 break; |
85 return; | |
86 case PrefHashStoreTransaction::TRUSTED_NULL_VALUE: | 91 case PrefHashStoreTransaction::TRUSTED_NULL_VALUE: |
87 UMA_HISTOGRAM_ENUMERATION( | 92 histogram_name = |
88 user_prefs::tracked::kTrackedPrefHistogramNullInitialized, | 93 user_prefs::tracked::kTrackedPrefHistogramNullInitialized; |
89 reporting_id_, reporting_ids_count_); | 94 break; |
90 return; | 95 default: |
96 NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: " | |
97 << value_state; | |
91 } | 98 } |
92 NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: " | 99 |
93 << value_state; | 100 // Using FactoryGet to allow dynamic histogram names. Should be equivalent to |
101 // UMA_HISTOGRAM_ENUMERATION(name, reporting_id_, reporting_ids_count_); | |
102 // TODO: RegistryStoreSettings.TrackedPreferenceInitialized does not match | |
103 // format from histograms.xml. | |
104 base::HistogramBase* histogram = base::LinearHistogram::FactoryGet( | |
105 histogram_name_prefix.append(histogram_name), 1, reporting_ids_count_, | |
gab
2016/08/03 18:19:36
Add a '.' between prefix and base histogram name
proberge
2016/08/04 00:13:46
Done. Any more efficient way than doing two append
gab
2016/08/05 19:59:25
In C++ strings are mutable so two appends is effic
| |
106 reporting_ids_count_ + 1, base::HistogramBase::kUmaTargetedHistogramFlag); | |
107 histogram->Add(reporting_id_); | |
94 } | 108 } |
95 | 109 |
96 void TrackedPreferenceHelper::ReportAction(ResetAction reset_action) const { | 110 void TrackedPreferenceHelper::ReportAction(ResetAction reset_action) const { |
97 switch (reset_action) { | 111 switch (reset_action) { |
98 case DONT_RESET: | 112 case DONT_RESET: |
99 // No report for DONT_RESET. | 113 // No report for DONT_RESET. |
100 break; | 114 break; |
101 case WANTED_RESET: | 115 case WANTED_RESET: |
102 UMA_HISTOGRAM_ENUMERATION( | 116 UMA_HISTOGRAM_ENUMERATION( |
103 user_prefs::tracked::kTrackedPrefHistogramWantedReset, reporting_id_, | 117 user_prefs::tracked::kTrackedPrefHistogramWantedReset, reporting_id_, |
(...skipping 10 matching lines...) Expand all Loading... | |
114 size_t count) const { | 128 size_t count) const { |
115 // The histogram below is an expansion of the UMA_HISTOGRAM_COUNTS_100 macro | 129 // The histogram below is an expansion of the UMA_HISTOGRAM_COUNTS_100 macro |
116 // adapted to allow for a dynamically suffixed histogram name. | 130 // adapted to allow for a dynamically suffixed histogram name. |
117 // Note: The factory creates and owns the histogram. | 131 // Note: The factory creates and owns the histogram. |
118 base::HistogramBase* histogram = base::LinearHistogram::FactoryGet( | 132 base::HistogramBase* histogram = base::LinearHistogram::FactoryGet( |
119 user_prefs::tracked::kTrackedSplitPrefHistogramChanged + pref_path_, 1, | 133 user_prefs::tracked::kTrackedSplitPrefHistogramChanged + pref_path_, 1, |
120 100, // Allow counts up to 100. | 134 100, // Allow counts up to 100. |
121 101, base::HistogramBase::kUmaTargetedHistogramFlag); | 135 101, base::HistogramBase::kUmaTargetedHistogramFlag); |
122 histogram->Add(count); | 136 histogram->Add(count); |
123 } | 137 } |
OLD | NEW |