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

Side by Side Diff: chrome/browser/prefs/tracked/tracked_preference_helper.cc

Issue 147053005: Coarser levels for the SettingsEnforcement field trial. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: constantify trial/group names Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/prefs/tracked/tracked_preference_helper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 allow_changes_(enforcement_level < PrefHashFilter::ENFORCE), 17 enforce_(enforcement_level == PrefHashFilter::ENFORCE_ON_LOAD) {
18 allow_seeding_(enforcement_level < PrefHashFilter::ENFORCE_NO_SEEDING),
19 allow_migration_(enforcement_level <
20 PrefHashFilter::ENFORCE_NO_SEEDING_NO_MIGRATION) {
21 } 18 }
22 19
23 TrackedPreferenceHelper::ResetAction TrackedPreferenceHelper::GetAction( 20 TrackedPreferenceHelper::ResetAction TrackedPreferenceHelper::GetAction(
24 PrefHashStoreTransaction::ValueState value_state) const { 21 PrefHashStoreTransaction::ValueState value_state) const {
25 switch (value_state) { 22 switch (value_state) {
26 case PrefHashStoreTransaction::UNCHANGED: 23 case PrefHashStoreTransaction::UNCHANGED:
27 // Desired case, nothing to do. 24 // Desired case, nothing to do.
28 return DONT_RESET; 25 return DONT_RESET;
29 case PrefHashStoreTransaction::CLEARED: 26 case PrefHashStoreTransaction::CLEARED:
30 // Unfortunate case, but there is nothing we can do. 27 // Unfortunate case, but there is nothing we can do.
31 return DONT_RESET; 28 return DONT_RESET;
32 case PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE: 29 case PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE:
33 // It is okay to seed the hash in this case. 30 // It is okay to seed the hash in this case.
34 return DONT_RESET; 31 return DONT_RESET;
35 case PrefHashStoreTransaction::MIGRATED: 32 case PrefHashStoreTransaction::MIGRATED: // Falls through.
36 return allow_migration_ ? WANTED_RESET : DO_RESET; 33 case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE: // Falls through.
37 case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE:
38 return allow_seeding_ ? WANTED_RESET : DO_RESET;
39 case PrefHashStoreTransaction::CHANGED: 34 case PrefHashStoreTransaction::CHANGED:
40 return allow_changes_ ? WANTED_RESET : DO_RESET; 35 return enforce_ ? DO_RESET : WANTED_RESET;
41 } 36 }
42 NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: " 37 NOTREACHED() << "Unexpected PrefHashStoreTransaction::ValueState: "
43 << value_state; 38 << value_state;
44 return DONT_RESET; 39 return DONT_RESET;
45 } 40 }
46 41
47 void TrackedPreferenceHelper::ReportValidationResult( 42 void TrackedPreferenceHelper::ReportValidationResult(
48 PrefHashStoreTransaction::ValueState value_state) const { 43 PrefHashStoreTransaction::ValueState value_state) const {
49 switch (value_state) { 44 switch (value_state) {
50 case PrefHashStoreTransaction::UNCHANGED: 45 case PrefHashStoreTransaction::UNCHANGED:
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // Note: The factory creates and owns the histogram. 94 // Note: The factory creates and owns the histogram.
100 base::HistogramBase* histogram = 95 base::HistogramBase* histogram =
101 base::LinearHistogram::FactoryGet( 96 base::LinearHistogram::FactoryGet(
102 "Settings.TrackedSplitPreferenceChanged." + pref_path_, 97 "Settings.TrackedSplitPreferenceChanged." + pref_path_,
103 1, 98 1,
104 100, // Allow counts up to 100. 99 100, // Allow counts up to 100.
105 101, 100 101,
106 base::HistogramBase::kUmaTargetedHistogramFlag); 101 base::HistogramBase::kUmaTargetedHistogramFlag);
107 histogram->Add(count); 102 histogram->Add(count);
108 } 103 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/tracked/tracked_preference_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698