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/prefs/tracked/tracked_preference_helper.h" | 5 #include "chrome/browser/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 | 9 |
10 TrackedPreferenceHelper::TrackedPreferenceHelper( | 10 TrackedPreferenceHelper::TrackedPreferenceHelper( |
11 const std::string& pref_path, | 11 const std::string& pref_path, |
12 size_t reporting_id, | 12 size_t reporting_id, |
13 size_t reporting_ids_count, | 13 size_t reporting_ids_count, |
14 PrefHashFilter::EnforcementLevel enforcement_level) | 14 PrefHashFilter::EnforcementLevel enforcement_level) |
15 : pref_path_(pref_path), | 15 : pref_path_(pref_path), |
16 reporting_id_(reporting_id), reporting_ids_count_(reporting_ids_count), | 16 reporting_id_(reporting_id), reporting_ids_count_(reporting_ids_count), |
17 enforce_(enforcement_level == PrefHashFilter::ENFORCE_ON_LOAD) { | 17 enforce_(enforcement_level == PrefHashFilter::ENFORCE_ON_LOAD) { |
18 } | 18 } |
19 | 19 |
20 TrackedPreferenceHelper::ResetAction TrackedPreferenceHelper::GetAction( | 20 TrackedPreferenceHelper::ResetAction TrackedPreferenceHelper::GetAction( |
21 PrefHashStoreTransaction::ValueState value_state) const { | 21 PrefHashStoreTransaction::ValueState value_state) const { |
22 switch (value_state) { | 22 switch (value_state) { |
23 case PrefHashStoreTransaction::UNCHANGED: | 23 case PrefHashStoreTransaction::UNCHANGED: |
24 // Desired case, nothing to do. | 24 // Desired case, nothing to do. |
25 return DONT_RESET; | 25 return DONT_RESET; |
26 case PrefHashStoreTransaction::CLEARED: | 26 case PrefHashStoreTransaction::CLEARED: |
27 // Unfortunate case, but there is nothing we can do. | 27 // Unfortunate case, but there is nothing we can do. |
28 return DONT_RESET; | 28 return DONT_RESET; |
| 29 case PrefHashStoreTransaction::TRUSTED_NULL_VALUE: // Falls through. |
29 case PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE: | 30 case PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE: |
30 // It is okay to seed the hash in this case. | 31 // It is okay to seed the hash in this case. |
31 return DONT_RESET; | 32 return DONT_RESET; |
32 case PrefHashStoreTransaction::SECURE_LEGACY: | 33 case PrefHashStoreTransaction::SECURE_LEGACY: |
33 // Accept secure legacy device ID based hashes. | 34 // Accept secure legacy device ID based hashes. |
34 return DONT_RESET; | 35 return DONT_RESET; |
35 case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE: // Falls through. | 36 case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE: // Falls through. |
36 case PrefHashStoreTransaction::CHANGED: | 37 case PrefHashStoreTransaction::CHANGED: |
37 return enforce_ ? DO_RESET : WANTED_RESET; | 38 return enforce_ ? DO_RESET : WANTED_RESET; |
38 } | 39 } |
(...skipping 23 matching lines...) Expand all Loading... |
62 reporting_id_, reporting_ids_count_); | 63 reporting_id_, reporting_ids_count_); |
63 return; | 64 return; |
64 case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE: | 65 case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE: |
65 UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceInitialized", | 66 UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceInitialized", |
66 reporting_id_, reporting_ids_count_); | 67 reporting_id_, reporting_ids_count_); |
67 return; | 68 return; |
68 case PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE: | 69 case PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE: |
69 UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceTrustedInitialized", | 70 UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceTrustedInitialized", |
70 reporting_id_, reporting_ids_count_); | 71 reporting_id_, reporting_ids_count_); |
71 return; | 72 return; |
| 73 case PrefHashStoreTransaction::TRUSTED_NULL_VALUE: |
| 74 UMA_HISTOGRAM_ENUMERATION("Settings.TrackedPreferenceNullInitialized", |
| 75 reporting_id_, reporting_ids_count_); |
| 76 return; |
72 } | 77 } |
73 NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: " | 78 NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: " |
74 << value_state; | 79 << value_state; |
75 } | 80 } |
76 | 81 |
77 void TrackedPreferenceHelper::ReportAction(ResetAction reset_action) const { | 82 void TrackedPreferenceHelper::ReportAction(ResetAction reset_action) const { |
78 switch (reset_action) { | 83 switch (reset_action) { |
79 case DONT_RESET: | 84 case DONT_RESET: |
80 // No report for DONT_RESET. | 85 // No report for DONT_RESET. |
81 break; | 86 break; |
(...skipping 15 matching lines...) Expand all Loading... |
97 // Note: The factory creates and owns the histogram. | 102 // Note: The factory creates and owns the histogram. |
98 base::HistogramBase* histogram = | 103 base::HistogramBase* histogram = |
99 base::LinearHistogram::FactoryGet( | 104 base::LinearHistogram::FactoryGet( |
100 "Settings.TrackedSplitPreferenceChanged." + pref_path_, | 105 "Settings.TrackedSplitPreferenceChanged." + pref_path_, |
101 1, | 106 1, |
102 100, // Allow counts up to 100. | 107 100, // Allow counts up to 100. |
103 101, | 108 101, |
104 base::HistogramBase::kUmaTargetedHistogramFlag); | 109 base::HistogramBase::kUmaTargetedHistogramFlag); |
105 histogram->Add(count); | 110 histogram->Add(count); |
106 } | 111 } |
OLD | NEW |