OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ | |
6 #define CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "chrome/browser/prefs/pref_hash_filter.h" | |
10 #include "chrome/browser/prefs/pref_hash_store.h" | |
11 | |
12 // A TrackedPreferenceHelper is a helper class for TrackedPreference which | |
13 // handles decision making and reporting for TrackedPreference's | |
14 // implementations. | |
15 class TrackedPreferenceHelper { | |
16 public: | |
17 enum ResetAction { | |
18 DONT_RESET, | |
19 // WANTED_RESET is reported when DO_RESET would have been reported but the | |
20 // current |enforcement_level| doesn't allow a reset for the detected state. | |
21 WANTED_RESET, | |
22 DO_RESET, | |
23 }; | |
24 | |
25 TrackedPreferenceHelper(const std::string& pref_path, | |
erikwright (departed)
2014/01/21 18:44:45
<string>
gab
2014/01/21 20:51:42
Done.
| |
26 size_t reporting_id, | |
27 size_t reporting_ids_count, | |
28 PrefHashFilter::EnforcementLevel enforcement_level); | |
29 | |
30 // Returns a ResetAction stating whether a reset is desired (DO_RESET) based | |
31 // on observing |value_state| or not (DONT_RESET). |allow_changes_|, | |
32 // |allow_seeding_|, and |allow_migration_| make the decision softer in favor | |
33 // of WANTED_RESET over DO_RESET in various scenarios. | |
34 ResetAction GetAction(PrefHashStore::ValueState value_state) const; | |
35 | |
36 // Reports |value_state| via UMA under |reporting_id_|. | |
37 void ReportValidationResult(PrefHashStore::ValueState value_state) const; | |
38 | |
39 // Reports |reset_action| via UMA under |reporting_id_|. | |
40 void ReportAction(ResetAction reset_action) const; | |
41 | |
42 // Reports, via UMA, the |count| of split preference entries that were | |
43 // considered invalid in a CHANGED event. | |
44 void ReportSplitPreferenceChangedCount(size_t count) const; | |
45 | |
46 private: | |
47 const std::string pref_path_; | |
48 | |
49 const size_t reporting_id_; | |
50 const size_t reporting_ids_count_; | |
51 | |
52 // Allow setting changes. | |
53 const bool allow_changes_; | |
54 // Allow seeding unknown values for atomic preferences. | |
55 const bool allow_seeding_; | |
56 // Allow migration of values validated by the old MAC algorithm. | |
57 const bool allow_migration_; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(TrackedPreferenceHelper); | |
60 }; | |
61 | |
62 #endif // CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ | |
OLD | NEW |