OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_PREFS_TRACKED_PREFERENCE_HELPER_H_ | |
6 #define CHROME_BROWSER_PREFS_TRACKED_PREFERENCE_HELPER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "chrome/browser/prefs/pref_hash_store.h" | |
10 | |
11 // A TrackedPreferenceHelper is a helper class for TrackedPreference which | |
12 // handles decision making and reporting for TrackedPreference's | |
13 // implementations. | |
14 class TrackedPreferenceHelper { | |
15 public: | |
16 // Enforcement levels are defined in order of intensity; the next level always | |
17 // implies the previous one and more. | |
18 enum EnforcementLevel { | |
erikwright (departed)
2014/01/17 20:23:01
I would probably put this in its own file. It does
gab
2014/01/17 21:32:01
Put it back in PrefHashFilter.
| |
19 NO_ENFORCEMENT, | |
20 ENFORCE, | |
21 ENFORCE_NO_SEEDING, | |
22 ENFORCE_NO_SEEDING_NO_MIGRATION, | |
23 // ENFORCE_ALL must always remain last; it is meant to be used when the | |
24 // desired level is underdetermined and the caller wants to enforce the | |
25 // strongest level to be safe. | |
26 ENFORCE_ALL | |
27 }; | |
28 | |
29 enum ResetAction { | |
30 DONT_RESET, | |
31 // WANTED_RESET is reported when DO_RESET would have been reported but the | |
32 // current |enforcement_level| doesn't allow a reset for the detected state. | |
33 WANTED_RESET, | |
34 DO_RESET, | |
35 }; | |
36 | |
37 TrackedPreferenceHelper(const std::string& pref_path, | |
38 size_t reporting_id, | |
39 size_t reporting_ids_count, | |
40 EnforcementLevel enforcement_level); | |
41 | |
42 // Returns a ResetAction stating whether a reset is desired (DO_RESET) based | |
43 // on observing |value_state| or not (DONT_RESET). |allow_changes_|, | |
44 // |allow_seeding_|, and |allow_migration_| make the decision softer in favor | |
45 // of WANTED_RESET over DO_RESET in various scenarios. | |
46 ResetAction GetAction(PrefHashStore::ValueState value_state) const; | |
47 | |
48 // Reports |value_state| via UMA under |reporting_id_|. | |
49 void ReportValidationResult(PrefHashStore::ValueState value_state) const; | |
50 | |
51 // Reports |reset_action| via UMA under |reporting_id_|. | |
52 void ReportAction(ResetAction reset_action) const; | |
53 | |
54 // Reports, via UMA, the |count| of split preference entries that were | |
55 // considered invalid in a CHANGED event. | |
56 void ReportSplitPreferenceChangedCount(size_t count) const; | |
57 | |
58 private: | |
59 const std::string pref_path_; | |
60 | |
61 const size_t reporting_id_; | |
62 const size_t reporting_ids_count_; | |
63 | |
64 // Allow setting changes. | |
65 const bool allow_changes_; | |
66 // Allow seeding unknown values for atomic preferences. | |
67 const bool allow_seeding_; | |
68 // Allow migration of values validated by the old MAC algorithm. | |
69 const bool allow_migration_; | |
70 | |
71 DISALLOW_COPY_AND_ASSIGN(TrackedPreferenceHelper); | |
72 }; | |
73 | |
74 #endif // CHROME_BROWSER_PREFS_TRACKED_PREFERENCE_HELPER_H_ | |
OLD | NEW |