| 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 | 10 |
| 10 TrackedPreferenceHelper::TrackedPreferenceHelper( | 11 TrackedPreferenceHelper::TrackedPreferenceHelper( |
| 11 const std::string& pref_path, | 12 const std::string& pref_path, |
| 12 size_t reporting_id, | 13 size_t reporting_id, |
| 13 size_t reporting_ids_count, | 14 size_t reporting_ids_count, |
| 14 PrefHashFilter::EnforcementLevel enforcement_level, | 15 PrefHashFilter::EnforcementLevel enforcement_level, |
| 15 PrefHashFilter::ValueType value_type) | 16 PrefHashFilter::ValueType value_type) |
| 16 : pref_path_(pref_path), | 17 : pref_path_(pref_path), |
| 17 reporting_id_(reporting_id), | 18 reporting_id_(reporting_id), |
| 18 reporting_ids_count_(reporting_ids_count), | 19 reporting_ids_count_(reporting_ids_count), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 46 } | 47 } |
| 47 | 48 |
| 48 bool TrackedPreferenceHelper::IsPersonal() const { | 49 bool TrackedPreferenceHelper::IsPersonal() const { |
| 49 return personal_; | 50 return personal_; |
| 50 } | 51 } |
| 51 | 52 |
| 52 void TrackedPreferenceHelper::ReportValidationResult( | 53 void TrackedPreferenceHelper::ReportValidationResult( |
| 53 PrefHashStoreTransaction::ValueState value_state) const { | 54 PrefHashStoreTransaction::ValueState value_state) const { |
| 54 switch (value_state) { | 55 switch (value_state) { |
| 55 case PrefHashStoreTransaction::UNCHANGED: | 56 case PrefHashStoreTransaction::UNCHANGED: |
| 56 UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceUnchanged", | 57 UMA_HISTOGRAM_ENUMERATION( |
| 57 reporting_id_, reporting_ids_count_); | 58 user_prefs::tracked::kTrackedPrefHistogramUnchanged, reporting_id_, |
| 59 reporting_ids_count_); |
| 58 return; | 60 return; |
| 59 case PrefHashStoreTransaction::CLEARED: | 61 case PrefHashStoreTransaction::CLEARED: |
| 60 UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceCleared", | 62 UMA_HISTOGRAM_ENUMERATION( |
| 61 reporting_id_, reporting_ids_count_); | 63 user_prefs::tracked::kTrackedPrefHistogramCleared, reporting_id_, |
| 64 reporting_ids_count_); |
| 62 return; | 65 return; |
| 63 case PrefHashStoreTransaction::SECURE_LEGACY: | 66 case PrefHashStoreTransaction::SECURE_LEGACY: |
| 64 UMA_HISTOGRAM_ENUMERATION( | 67 UMA_HISTOGRAM_ENUMERATION( |
| 65 "Settings.TrackedPreferenceMigratedLegacyDeviceId", reporting_id_, | 68 user_prefs::tracked::kTrackedPrefHistogramMigratedLegacyDeviceId, |
| 69 reporting_id_, reporting_ids_count_); |
| 70 return; |
| 71 case PrefHashStoreTransaction::CHANGED: |
| 72 UMA_HISTOGRAM_ENUMERATION( |
| 73 user_prefs::tracked::kTrackedPrefHistogramChanged, reporting_id_, |
| 66 reporting_ids_count_); | 74 reporting_ids_count_); |
| 67 return; | 75 return; |
| 68 case PrefHashStoreTransaction::CHANGED: | |
| 69 UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceChanged", | |
| 70 reporting_id_, reporting_ids_count_); | |
| 71 return; | |
| 72 case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE: | 76 case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE: |
| 73 UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceInitialized", | 77 UMA_HISTOGRAM_ENUMERATION( |
| 74 reporting_id_, reporting_ids_count_); | 78 user_prefs::tracked::kTrackedPrefHistogramInitialized, reporting_id_, |
| 79 reporting_ids_count_); |
| 75 return; | 80 return; |
| 76 case PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE: | 81 case PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE: |
| 77 UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceTrustedInitialized", | 82 UMA_HISTOGRAM_ENUMERATION( |
| 78 reporting_id_, reporting_ids_count_); | 83 user_prefs::tracked::kTrackedPrefHistogramTrustedInitialized, |
| 84 reporting_id_, reporting_ids_count_); |
| 79 return; | 85 return; |
| 80 case PrefHashStoreTransaction::TRUSTED_NULL_VALUE: | 86 case PrefHashStoreTransaction::TRUSTED_NULL_VALUE: |
| 81 UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceNullInitialized", | 87 UMA_HISTOGRAM_ENUMERATION( |
| 82 reporting_id_, reporting_ids_count_); | 88 user_prefs::tracked::kTrackedPrefHistogramNullInitialized, |
| 89 reporting_id_, reporting_ids_count_); |
| 83 return; | 90 return; |
| 84 } | 91 } |
| 85 NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: " | 92 NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: " |
| 86 << value_state; | 93 << value_state; |
| 87 } | 94 } |
| 88 | 95 |
| 89 void TrackedPreferenceHelper::ReportAction(ResetAction reset_action) const { | 96 void TrackedPreferenceHelper::ReportAction(ResetAction reset_action) const { |
| 90 switch (reset_action) { | 97 switch (reset_action) { |
| 91 case DONT_RESET: | 98 case DONT_RESET: |
| 92 // No report for DONT_RESET. | 99 // No report for DONT_RESET. |
| 93 break; | 100 break; |
| 94 case WANTED_RESET: | 101 case WANTED_RESET: |
| 95 UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceWantedReset", | 102 UMA_HISTOGRAM_ENUMERATION( |
| 96 reporting_id_, reporting_ids_count_); | 103 user_prefs::tracked::kTrackedPrefHistogramWantedReset, reporting_id_, |
| 104 reporting_ids_count_); |
| 97 break; | 105 break; |
| 98 case DO_RESET: | 106 case DO_RESET: |
| 99 UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceReset", | 107 UMA_HISTOGRAM_ENUMERATION(user_prefs::tracked::kTrackedPrefHistogramReset, |
| 100 reporting_id_, reporting_ids_count_); | 108 reporting_id_, reporting_ids_count_); |
| 101 break; | 109 break; |
| 102 } | 110 } |
| 103 } | 111 } |
| 104 | 112 |
| 105 void TrackedPreferenceHelper::ReportSplitPreferenceChangedCount( | 113 void TrackedPreferenceHelper::ReportSplitPreferenceChangedCount( |
| 106 size_t count) const { | 114 size_t count) const { |
| 107 // The histogram below is an expansion of the UMA_HISTOGRAM_COUNTS_100 macro | 115 // The histogram below is an expansion of the UMA_HISTOGRAM_COUNTS_100 macro |
| 108 // adapted to allow for a dynamically suffixed histogram name. | 116 // adapted to allow for a dynamically suffixed histogram name. |
| 109 // Note: The factory creates and owns the histogram. | 117 // Note: The factory creates and owns the histogram. |
| 110 base::HistogramBase* histogram = | 118 base::HistogramBase* histogram = base::LinearHistogram::FactoryGet( |
| 111 base::LinearHistogram::FactoryGet( | 119 user_prefs::tracked::kTrackedSplitPrefHistogramChanged + pref_path_, 1, |
| 112 "Settings.TrackedSplitPreferenceChanged." + pref_path_, | 120 100, // Allow counts up to 100. |
| 113 1, | 121 101, base::HistogramBase::kUmaTargetedHistogramFlag); |
| 114 100, // Allow counts up to 100. | |
| 115 101, | |
| 116 base::HistogramBase::kUmaTargetedHistogramFlag); | |
| 117 histogram->Add(count); | 122 histogram->Add(count); |
| 118 } | 123 } |
| OLD | NEW |