OLD | NEW |
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 #ifndef COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ | 5 #ifndef COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ |
6 #define COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ | 6 #define COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "components/user_prefs/tracked/hash_store_contents.h" |
13 #include "components/user_prefs/tracked/pref_hash_filter.h" | 14 #include "components/user_prefs/tracked/pref_hash_filter.h" |
14 #include "components/user_prefs/tracked/pref_hash_store_transaction.h" | 15 #include "components/user_prefs/tracked/pref_hash_store_transaction.h" |
15 | 16 |
16 // A TrackedPreferenceHelper is a helper class for TrackedPreference which | 17 // A TrackedPreferenceHelper is a helper class for TrackedPreference which |
17 // handles decision making and reporting for TrackedPreference's | 18 // handles decision making and reporting for TrackedPreference's |
18 // implementations. | 19 // implementations. |
19 class TrackedPreferenceHelper { | 20 class TrackedPreferenceHelper { |
20 public: | 21 public: |
21 enum ResetAction { | 22 enum ResetAction { |
22 DONT_RESET, | 23 DONT_RESET, |
(...skipping 11 matching lines...) Expand all Loading... |
34 | 35 |
35 // Returns a ResetAction stating whether a reset is desired (DO_RESET) or not | 36 // 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 // (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 // if a reset would have been desired but the current |enforcement_level| |
38 // doesn't allow it. | 39 // doesn't allow it. |
39 ResetAction GetAction(PrefHashStoreTransaction::ValueState value_state) const; | 40 ResetAction GetAction(PrefHashStoreTransaction::ValueState value_state) const; |
40 | 41 |
41 // Returns true if the preference value may contain personal information. | 42 // Returns true if the preference value may contain personal information. |
42 bool IsPersonal() const; | 43 bool IsPersonal() const; |
43 | 44 |
44 // Reports |value_state| via UMA under |reporting_id_|. | 45 // Reports |value_state| via UMA under |reporting_id_|. |validation_type| will |
45 void ReportValidationResult( | 46 // be used to choose the correct histogram name. |
46 PrefHashStoreTransaction::ValueState value_state) const; | 47 void ReportValidationResult(PrefHashStoreTransaction::ValueState value_state, |
| 48 const std::string& validation_type_suffix) const; |
47 | 49 |
48 // Reports |reset_action| via UMA under |reporting_id_|. | 50 // Reports |reset_action| via UMA under |reporting_id_|. |
49 void ReportAction(ResetAction reset_action) const; | 51 void ReportAction(ResetAction reset_action) const; |
50 | 52 |
51 // Reports, via UMA, the |count| of split preference entries that were | 53 // Reports, via UMA, the |count| of split preference entries that were |
52 // considered invalid in a CHANGED event. | 54 // considered invalid in a CHANGED event. |
53 void ReportSplitPreferenceChangedCount(size_t count) const; | 55 void ReportSplitPreferenceChangedCount(size_t count) const; |
54 | 56 |
55 private: | 57 private: |
56 const std::string pref_path_; | 58 const std::string pref_path_; |
57 | 59 |
58 const size_t reporting_id_; | 60 const size_t reporting_id_; |
59 const size_t reporting_ids_count_; | 61 const size_t reporting_ids_count_; |
60 | 62 |
61 // Deny setting changes and hash seeding/migration. | 63 // Deny setting changes and hash seeding/migration. |
62 const bool enforce_; | 64 const bool enforce_; |
63 | 65 |
64 const bool personal_; | 66 const bool personal_; |
65 | 67 |
66 DISALLOW_COPY_AND_ASSIGN(TrackedPreferenceHelper); | 68 DISALLOW_COPY_AND_ASSIGN(TrackedPreferenceHelper); |
67 }; | 69 }; |
68 | 70 |
69 #endif // COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ | 71 #endif // COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ |
OLD | NEW |