Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: components/user_prefs/tracked/tracked_preference_helper.cc

Issue 2384213002: Send a TrackedPreference incident when registry pref validation fails. (Closed)
Patch Set: Handle UNSUPPORTED in another switch Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 return;
gab 2016/10/03 21:03:58 This should be NOTREACHED() as well
proberge 2016/10/05 15:36:40 Done.
83 default: 89 default:
gab 2016/10/03 21:03:58 And while you're here if you don't mind: remove de
proberge 2016/10/05 15:36:40 I think default:foo is slightly cleaner than addin
gab 2016/10/05 17:23:21 No, the presence of the default prevents clang fro
proberge 2016/10/05 17:53:26 Done, but can't use empty() on a char*. Initialize
84 NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: " 90 NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: "
85 << value_state; 91 << value_state;
86 return; 92 return;
87 } 93 }
88 94
89 std::string full_histogram_name(histogram_name); 95 std::string full_histogram_name(histogram_name);
90 if (!validation_type_suffix.empty()) { 96 if (!validation_type_suffix.empty()) {
91 full_histogram_name.push_back('.'); 97 full_histogram_name.push_back('.');
92 validation_type_suffix.AppendToString(&full_histogram_name); 98 validation_type_suffix.AppendToString(&full_histogram_name);
93 } 99 }
(...skipping 27 matching lines...) Expand all
121 size_t count) const { 127 size_t count) const {
122 // The histogram below is an expansion of the UMA_HISTOGRAM_COUNTS_100 macro 128 // The histogram below is an expansion of the UMA_HISTOGRAM_COUNTS_100 macro
123 // adapted to allow for a dynamically suffixed histogram name. 129 // adapted to allow for a dynamically suffixed histogram name.
124 // Note: The factory creates and owns the histogram. 130 // Note: The factory creates and owns the histogram.
125 base::HistogramBase* histogram = base::LinearHistogram::FactoryGet( 131 base::HistogramBase* histogram = base::LinearHistogram::FactoryGet(
126 user_prefs::tracked::kTrackedSplitPrefHistogramChanged + pref_path_, 1, 132 user_prefs::tracked::kTrackedSplitPrefHistogramChanged + pref_path_, 1,
127 100, // Allow counts up to 100. 133 100, // Allow counts up to 100.
128 101, base::HistogramBase::kUmaTargetedHistogramFlag); 134 101, base::HistogramBase::kUmaTargetedHistogramFlag);
129 histogram->Add(count); 135 histogram->Add(count);
130 } 136 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698