OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_PREFS_PREF_HASH_FILTER_H_ | 5 #ifndef CHROME_BROWSER_PREFS_PREF_HASH_FILTER_H_ |
6 #define CHROME_BROWSER_PREFS_PREF_HASH_FILTER_H_ | 6 #define CHROME_BROWSER_PREFS_PREF_HASH_FILTER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback.h" | |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "base/containers/scoped_ptr_hash_map.h" | 15 #include "base/containers/scoped_ptr_hash_map.h" |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "chrome/browser/prefs/interceptable_pref_filter.h" | 17 #include "chrome/browser/prefs/interceptable_pref_filter.h" |
17 #include "chrome/browser/prefs/tracked/tracked_preference.h" | 18 #include "chrome/browser/prefs/tracked/tracked_preference.h" |
18 | 19 |
19 class PrefHashStore; | 20 class PrefHashStore; |
20 class PrefService; | 21 class PrefService; |
21 class PrefStore; | 22 class PrefStore; |
22 class TrackedPreferenceValidationDelegate; | 23 class TrackedPreferenceValidationDelegate; |
(...skipping 30 matching lines...) Expand all Loading... | |
53 struct TrackedPreferenceMetadata { | 54 struct TrackedPreferenceMetadata { |
54 size_t reporting_id; | 55 size_t reporting_id; |
55 const char* name; | 56 const char* name; |
56 EnforcementLevel enforcement_level; | 57 EnforcementLevel enforcement_level; |
57 PrefTrackingStrategy strategy; | 58 PrefTrackingStrategy strategy; |
58 }; | 59 }; |
59 | 60 |
60 // Constructs a PrefHashFilter tracking the specified |tracked_preferences| | 61 // Constructs a PrefHashFilter tracking the specified |tracked_preferences| |
61 // using |pref_hash_store| to check/store hashes. An optional |delegate| is | 62 // using |pref_hash_store| to check/store hashes. An optional |delegate| is |
62 // notified of the status of each preference as it is checked. | 63 // notified of the status of each preference as it is checked. |
64 // If |on_reset| is provided, it will be invoked if a reset occurs in | |
Nicolas Zea
2014/07/18 21:11:16
nit: might be better to call it something like res
gab
2014/07/21 16:22:04
Renamed to |on_reset_on_load|
| |
65 // FilterOnLoad. | |
63 // |reporting_ids_count| is the count of all possible IDs (possibly greater | 66 // |reporting_ids_count| is the count of all possible IDs (possibly greater |
64 // than |tracked_preferences.size()|). If |report_super_mac_validity| is true, | 67 // than |tracked_preferences.size()|). If |report_super_mac_validity| is true, |
65 // the state of the super MAC will be reported via UMA during | 68 // the state of the super MAC will be reported via UMA during |
66 // FinalizeFilterOnLoad. | 69 // FinalizeFilterOnLoad. |
67 PrefHashFilter( | 70 PrefHashFilter( |
68 scoped_ptr<PrefHashStore> pref_hash_store, | 71 scoped_ptr<PrefHashStore> pref_hash_store, |
69 const std::vector<TrackedPreferenceMetadata>& tracked_preferences, | 72 const std::vector<TrackedPreferenceMetadata>& tracked_preferences, |
73 const base::Closure& on_reset, | |
70 TrackedPreferenceValidationDelegate* delegate, | 74 TrackedPreferenceValidationDelegate* delegate, |
71 size_t reporting_ids_count, | 75 size_t reporting_ids_count, |
72 bool report_super_mac_validity); | 76 bool report_super_mac_validity); |
73 | 77 |
74 virtual ~PrefHashFilter(); | 78 virtual ~PrefHashFilter(); |
75 | 79 |
76 // Registers required user preferences. | 80 // Registers required user preferences. |
77 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 81 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
78 | 82 |
79 // Retrieves the time of the last reset event, if any, for the provided user | 83 // Retrieves the time of the last reset event, if any, for the provided user |
(...skipping 29 matching lines...) Expand all Loading... | |
109 // A map of paths to TrackedPreferences; this map owns this individual | 113 // A map of paths to TrackedPreferences; this map owns this individual |
110 // TrackedPreference objects. | 114 // TrackedPreference objects. |
111 typedef base::ScopedPtrHashMap<std::string, TrackedPreference> | 115 typedef base::ScopedPtrHashMap<std::string, TrackedPreference> |
112 TrackedPreferencesMap; | 116 TrackedPreferencesMap; |
113 // A map from changed paths to their corresponding TrackedPreferences (which | 117 // A map from changed paths to their corresponding TrackedPreferences (which |
114 // aren't owned by this map). | 118 // aren't owned by this map). |
115 typedef std::map<std::string, const TrackedPreference*> ChangedPathsMap; | 119 typedef std::map<std::string, const TrackedPreference*> ChangedPathsMap; |
116 | 120 |
117 scoped_ptr<PrefHashStore> pref_hash_store_; | 121 scoped_ptr<PrefHashStore> pref_hash_store_; |
118 | 122 |
123 // Invoked if a reset occurs in a call to FilterOnLoad. | |
124 const base::Closure on_reset_; | |
125 | |
119 TrackedPreferencesMap tracked_paths_; | 126 TrackedPreferencesMap tracked_paths_; |
120 | 127 |
121 // The set of all paths whose value has changed since the last call to | 128 // The set of all paths whose value has changed since the last call to |
122 // FilterSerializeData. | 129 // FilterSerializeData. |
123 ChangedPathsMap changed_paths_; | 130 ChangedPathsMap changed_paths_; |
124 | 131 |
125 // Whether to report the validity of the super MAC at load time (via UMA). | 132 // Whether to report the validity of the super MAC at load time (via UMA). |
126 bool report_super_mac_validity_; | 133 bool report_super_mac_validity_; |
127 | 134 |
128 DISALLOW_COPY_AND_ASSIGN(PrefHashFilter); | 135 DISALLOW_COPY_AND_ASSIGN(PrefHashFilter); |
129 }; | 136 }; |
130 | 137 |
131 #endif // CHROME_BROWSER_PREFS_PREF_HASH_FILTER_H_ | 138 #endif // CHROME_BROWSER_PREFS_PREF_HASH_FILTER_H_ |
OLD | NEW |