Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: services/preferences/tracked/pref_hash_filter.h

Issue 2745563005: Pref service: add support for tracked prefs. (Closed)
Patch Set: deflake tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 SERVICES_PREFERENCES_TRACKED_PREF_HASH_FILTER_H_ 5 #ifndef SERVICES_PREFERENCES_TRACKED_PREF_HASH_FILTER_H_
6 #define SERVICES_PREFERENCES_TRACKED_PREF_HASH_FILTER_H_ 6 #define SERVICES_PREFERENCES_TRACKED_PREF_HASH_FILTER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // using a PrefHashStore. Keeps the PrefHashStore contents up to date as values 45 // using a PrefHashStore. Keeps the PrefHashStore contents up to date as values
46 // are changed. 46 // are changed.
47 class PrefHashFilter : public InterceptablePrefFilter { 47 class PrefHashFilter : public InterceptablePrefFilter {
48 public: 48 public:
49 using StoreContentsPair = std::pair<std::unique_ptr<PrefHashStore>, 49 using StoreContentsPair = std::pair<std::unique_ptr<PrefHashStore>,
50 std::unique_ptr<HashStoreContents>>; 50 std::unique_ptr<HashStoreContents>>;
51 51
52 // Constructs a PrefHashFilter tracking the specified |tracked_preferences| 52 // Constructs a PrefHashFilter tracking the specified |tracked_preferences|
53 // using |pref_hash_store| to check/store hashes. An optional |delegate| is 53 // using |pref_hash_store| to check/store hashes. An optional |delegate| is
54 // notified of the status of each preference as it is checked. 54 // notified of the status of each preference as it is checked.
55 // If |on_reset_on_load| is provided, it will be invoked if a reset occurs in 55 // If |reset_on_load_observer| is provided, it will be notified if a reset
56 // FilterOnLoad. 56 // occurs in FilterOnLoad.
57 // |reporting_ids_count| is the count of all possible IDs (possibly greater 57 // |reporting_ids_count| is the count of all possible IDs (possibly greater
58 // than |tracked_preferences.size()|). If |report_super_mac_validity| is true, 58 // than |tracked_preferences.size()|). If |report_super_mac_validity| is true,
59 // the state of the super MAC will be reported via UMA during 59 // the state of the super MAC will be reported via UMA during
60 // FinalizeFilterOnLoad. 60 // FinalizeFilterOnLoad.
61 // |external_validation_hash_store_pair_| will be used (if non-null) to 61 // |external_validation_hash_store_pair_| will be used (if non-null) to
62 // perform extra validations without triggering resets. 62 // perform extra validations without triggering resets.
63 PrefHashFilter(std::unique_ptr<PrefHashStore> pref_hash_store, 63 PrefHashFilter(std::unique_ptr<PrefHashStore> pref_hash_store,
64 StoreContentsPair external_validation_hash_store_pair_, 64 StoreContentsPair external_validation_hash_store_pair_,
65 const std::vector<prefs::mojom::TrackedPreferenceMetadataPtr>& 65 const std::vector<prefs::mojom::TrackedPreferenceMetadataPtr>&
66 tracked_preferences, 66 tracked_preferences,
67 const base::Closure& on_reset_on_load, 67 prefs::mojom::ResetOnLoadObserverPtr reset_on_load_observer,
68 prefs::mojom::TrackedPreferenceValidationDelegate* delegate, 68 prefs::mojom::TrackedPreferenceValidationDelegate* delegate,
69 size_t reporting_ids_count, 69 size_t reporting_ids_count,
70 bool report_super_mac_validity); 70 bool report_super_mac_validity);
71 71
72 ~PrefHashFilter() override; 72 ~PrefHashFilter() override;
73 73
74 // Registers required user preferences. 74 // Registers required user preferences.
75 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 75 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
76 76
77 // Retrieves the time of the last reset event, if any, for the provided user 77 // Retrieves the time of the last reset event, if any, for the provided user
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // aren't owned by this map). 132 // aren't owned by this map).
133 using ChangedPathsMap = std::map<std::string, const TrackedPreference*>; 133 using ChangedPathsMap = std::map<std::string, const TrackedPreference*>;
134 134
135 std::unique_ptr<PrefHashStore> pref_hash_store_; 135 std::unique_ptr<PrefHashStore> pref_hash_store_;
136 136
137 // A store and contents on which to perform extra validations without 137 // A store and contents on which to perform extra validations without
138 // triggering resets. 138 // triggering resets.
139 // Will be null if the platform does not support external validation. 139 // Will be null if the platform does not support external validation.
140 const base::Optional<StoreContentsPair> external_validation_hash_store_pair_; 140 const base::Optional<StoreContentsPair> external_validation_hash_store_pair_;
141 141
142 // Invoked if a reset occurs in a call to FilterOnLoad. 142 // Notified if a reset occurs in a call to FilterOnLoad.
143 base::Closure on_reset_on_load_; 143 prefs::mojom::ResetOnLoadObserverPtr reset_on_load_observer_;
144 144
145 TrackedPreferencesMap tracked_paths_; 145 TrackedPreferencesMap tracked_paths_;
146 146
147 // The set of all paths whose value has changed since the last call to 147 // The set of all paths whose value has changed since the last call to
148 // FilterSerializeData. 148 // FilterSerializeData.
149 ChangedPathsMap changed_paths_; 149 ChangedPathsMap changed_paths_;
150 150
151 // Whether to report the validity of the super MAC at load time (via UMA). 151 // Whether to report the validity of the super MAC at load time (via UMA).
152 bool report_super_mac_validity_; 152 bool report_super_mac_validity_;
153 153
154 DISALLOW_COPY_AND_ASSIGN(PrefHashFilter); 154 DISALLOW_COPY_AND_ASSIGN(PrefHashFilter);
155 }; 155 };
156 156
157 #endif // SERVICES_PREFERENCES_TRACKED_PREF_HASH_FILTER_H_ 157 #endif // SERVICES_PREFERENCES_TRACKED_PREF_HASH_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698