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 COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ | |
6 #define COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ | |
7 | |
8 #include <stddef.h> | |
9 | |
10 #include <string> | |
11 | |
12 #include "base/macros.h" | |
13 #include "components/user_prefs/tracked/pref_hash_filter.h" | |
14 #include "components/user_prefs/tracked/pref_hash_store_transaction.h" | |
15 | |
16 // A TrackedPreferenceHelper is a helper class for TrackedPreference which | |
17 // handles decision making and reporting for TrackedPreference's | |
18 // implementations. | |
19 class TrackedPreferenceHelper { | |
20 public: | |
21 enum ResetAction { | |
22 DONT_RESET, | |
23 // WANTED_RESET is reported when DO_RESET would have been reported but the | |
24 // current |enforcement_level| doesn't allow a reset for the detected state. | |
25 WANTED_RESET, | |
26 DO_RESET, | |
27 }; | |
28 | |
29 TrackedPreferenceHelper(const std::string& pref_path, | |
30 size_t reporting_id, | |
31 size_t reporting_ids_count, | |
32 PrefHashFilter::EnforcementLevel enforcement_level, | |
33 PrefHashFilter::ValueType value_type); | |
34 | |
35 // Returns a ResetAction stating whether a reset is desired (DO_RESET) or not | |
36 // (DONT_RESET) based on observing |value_state|. Can also return WANTED_RESET | |
37 // if a reset would have been desired but the current |enforcement_level| | |
38 // doesn't allow it. | |
39 ResetAction GetAction(PrefHashStoreTransaction::ValueState value_state) const; | |
40 | |
41 // Returns true if the preference value may contain personal information. | |
42 bool IsPersonal() const; | |
43 | |
44 // Reports |value_state| via UMA under |reporting_id_|. | |
45 // |validation_type_suffix| is appended to the reported histogram's name. | |
46 void ReportValidationResult(PrefHashStoreTransaction::ValueState value_state, | |
47 base::StringPiece validation_type_suffix) const; | |
48 | |
49 // Reports |reset_action| via UMA under |reporting_id_|. | |
50 void ReportAction(ResetAction reset_action) const; | |
51 | |
52 // Reports, via UMA, the |count| of split preference entries that were | |
53 // considered invalid in a CHANGED event. | |
54 void ReportSplitPreferenceChangedCount(size_t count) const; | |
55 | |
56 private: | |
57 const std::string pref_path_; | |
58 | |
59 const size_t reporting_id_; | |
60 const size_t reporting_ids_count_; | |
61 | |
62 // Deny setting changes and hash seeding/migration. | |
63 const bool enforce_; | |
64 | |
65 const bool personal_; | |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(TrackedPreferenceHelper); | |
68 }; | |
69 | |
70 #endif // COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ | |
OLD | NEW |