| 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 "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "components/user_prefs/tracked/tracked_preference_histogram_names.h" | 10 #include "components/user_prefs/tracked/tracked_preference_histogram_names.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 case PrefHashStoreTransaction::CLEARED: | 31 case PrefHashStoreTransaction::CLEARED: |
| 32 // Unfortunate case, but there is nothing we can do. | 32 // Unfortunate case, but there is nothing we can do. |
| 33 return DONT_RESET; | 33 return DONT_RESET; |
| 34 case PrefHashStoreTransaction::TRUSTED_NULL_VALUE: // Falls through. | 34 case PrefHashStoreTransaction::TRUSTED_NULL_VALUE: // Falls through. |
| 35 case PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE: | 35 case PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE: |
| 36 // It is okay to seed the hash in this case. | 36 // It is okay to seed the hash in this case. |
| 37 return DONT_RESET; | 37 return DONT_RESET; |
| 38 case PrefHashStoreTransaction::SECURE_LEGACY: | 38 case PrefHashStoreTransaction::SECURE_LEGACY: |
| 39 // Accept secure legacy device ID based hashes. | 39 // Accept secure legacy device ID based hashes. |
| 40 return DONT_RESET; | 40 return DONT_RESET; |
| 41 case PrefHashStoreTransaction::UNSUPPORTED: |
| 42 NOTREACHED() |
| 43 << "GetAction should not be called with an UNSUPPORTED value state"; |
| 44 return DONT_RESET; |
| 41 case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE: // Falls through. | 45 case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE: // Falls through. |
| 42 case PrefHashStoreTransaction::CHANGED: | 46 case PrefHashStoreTransaction::CHANGED: |
| 43 return enforce_ ? DO_RESET : WANTED_RESET; | 47 return enforce_ ? DO_RESET : WANTED_RESET; |
| 44 } | 48 } |
| 45 NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: " | 49 NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: " |
| 46 << value_state; | 50 << value_state; |
| 47 return DONT_RESET; | 51 return DONT_RESET; |
| 48 } | 52 } |
| 49 | 53 |
| 50 bool TrackedPreferenceHelper::IsPersonal() const { | 54 bool TrackedPreferenceHelper::IsPersonal() const { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 73 histogram_name = user_prefs::tracked::kTrackedPrefHistogramInitialized; | 77 histogram_name = user_prefs::tracked::kTrackedPrefHistogramInitialized; |
| 74 break; | 78 break; |
| 75 case PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE: | 79 case PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE: |
| 76 histogram_name = | 80 histogram_name = |
| 77 user_prefs::tracked::kTrackedPrefHistogramTrustedInitialized; | 81 user_prefs::tracked::kTrackedPrefHistogramTrustedInitialized; |
| 78 break; | 82 break; |
| 79 case PrefHashStoreTransaction::TRUSTED_NULL_VALUE: | 83 case PrefHashStoreTransaction::TRUSTED_NULL_VALUE: |
| 80 histogram_name = | 84 histogram_name = |
| 81 user_prefs::tracked::kTrackedPrefHistogramNullInitialized; | 85 user_prefs::tracked::kTrackedPrefHistogramNullInitialized; |
| 82 break; | 86 break; |
| 87 case PrefHashStoreTransaction::UNSUPPORTED: |
| 88 NOTREACHED() << "ReportValidationResult should not be called with an " |
| 89 "UNSUPPORTED value state"; |
| 90 return; |
| 83 default: | 91 default: |
| 84 NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: " | 92 NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: " |
| 85 << value_state; | 93 << value_state; |
| 86 return; | 94 return; |
| 87 } | 95 } |
| 88 | 96 |
| 89 std::string full_histogram_name(histogram_name); | 97 std::string full_histogram_name(histogram_name); |
| 90 if (!validation_type_suffix.empty()) { | 98 if (!validation_type_suffix.empty()) { |
| 91 full_histogram_name.push_back('.'); | 99 full_histogram_name.push_back('.'); |
| 92 validation_type_suffix.AppendToString(&full_histogram_name); | 100 validation_type_suffix.AppendToString(&full_histogram_name); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 121 size_t count) const { | 129 size_t count) const { |
| 122 // The histogram below is an expansion of the UMA_HISTOGRAM_COUNTS_100 macro | 130 // The histogram below is an expansion of the UMA_HISTOGRAM_COUNTS_100 macro |
| 123 // adapted to allow for a dynamically suffixed histogram name. | 131 // adapted to allow for a dynamically suffixed histogram name. |
| 124 // Note: The factory creates and owns the histogram. | 132 // Note: The factory creates and owns the histogram. |
| 125 base::HistogramBase* histogram = base::LinearHistogram::FactoryGet( | 133 base::HistogramBase* histogram = base::LinearHistogram::FactoryGet( |
| 126 user_prefs::tracked::kTrackedSplitPrefHistogramChanged + pref_path_, 1, | 134 user_prefs::tracked::kTrackedSplitPrefHistogramChanged + pref_path_, 1, |
| 127 100, // Allow counts up to 100. | 135 100, // Allow counts up to 100. |
| 128 101, base::HistogramBase::kUmaTargetedHistogramFlag); | 136 101, base::HistogramBase::kUmaTargetedHistogramFlag); |
| 129 histogram->Add(count); | 137 histogram->Add(count); |
| 130 } | 138 } |
| OLD | NEW |