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

Side by Side Diff: components/user_prefs/tracked/pref_hash_filter.h

Issue 2745563005: Pref service: add support for tracked prefs. (Closed)
Patch Set: Created 3 years, 9 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 COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_FILTER_H_ 5 #ifndef COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_FILTER_H_
6 #define COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_FILTER_H_ 6 #define COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_FILTER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <unordered_map> 13 #include <unordered_map>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
18 #include "base/files/file_path.h" 18 #include "base/files/file_path.h"
19 #include "base/macros.h" 19 #include "base/macros.h"
20 #include "base/optional.h" 20 #include "base/optional.h"
21 #include "components/user_prefs/tracked/hash_store_contents.h" 21 #include "components/user_prefs/tracked/hash_store_contents.h"
22 #include "components/user_prefs/tracked/interceptable_pref_filter.h" 22 #include "components/user_prefs/tracked/interceptable_pref_filter.h"
23 #include "components/user_prefs/tracked/tracked_preference.h" 23 #include "components/user_prefs/tracked/tracked_preference.h"
24 #include "services/preferences/public/interfaces/preferences_configuration.mojom -shared.h"
24 25
25 class PrefHashStore; 26 class PrefHashStore;
26 class PrefService; 27 class PrefService;
27 28
28 namespace base { 29 namespace base {
29 class DictionaryValue; 30 class DictionaryValue;
30 class Time; 31 class Time;
31 } // namespace base 32 } // namespace base
32 33
33 namespace prefs { 34 namespace prefs {
34 namespace mojom { 35 namespace mojom {
35 class TrackedPreferenceValidationDelegate; 36 class TrackedPreferenceValidationDelegate;
36 } 37 }
37 } 38 }
38 39
39 namespace user_prefs { 40 namespace user_prefs {
40 class PrefRegistrySyncable; 41 class PrefRegistrySyncable;
41 } // namespace user_prefs 42 } // namespace user_prefs
42 43
43 // Intercepts preference values as they are loaded from disk and verifies them 44 // Intercepts preference values as they are loaded from disk and verifies them
44 // 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
45 // are changed. 46 // are changed.
46 class PrefHashFilter : public InterceptablePrefFilter { 47 class PrefHashFilter : public InterceptablePrefFilter {
47 public: 48 public:
48 enum class EnforcementLevel { NO_ENFORCEMENT, ENFORCE_ON_LOAD }; 49 using EnforcementLevel =
49 50 prefs::mojom::TrackedPreferenceMetadata_EnforcementLevel;
50 enum class PrefTrackingStrategy { 51 using PrefTrackingStrategy =
51 // Atomic preferences are tracked as a whole. 52 prefs::mojom::TrackedPreferenceMetadata_PrefTrackingStrategy;
52 ATOMIC, 53 using ValueType = prefs::mojom::TrackedPreferenceMetadata_ValueType;
53 // Split preferences are dictionaries for which each top-level entry is
54 // tracked independently. Note: preferences using this strategy must be kept
55 // in sync with TrackedSplitPreferences in histograms.xml.
56 SPLIT,
57 };
58
59 enum class ValueType {
60 IMPERSONAL,
61 // The preference value may contain personal information.
62 PERSONAL,
63 };
64 54
65 struct TrackedPreferenceMetadata { 55 struct TrackedPreferenceMetadata {
66 size_t reporting_id; 56 size_t reporting_id;
67 const char* name; 57 const char* name;
68 EnforcementLevel enforcement_level; 58 EnforcementLevel enforcement_level;
69 PrefTrackingStrategy strategy; 59 PrefTrackingStrategy strategy;
70 ValueType value_type; 60 ValueType value_type;
71 }; 61 };
72 62
73 using StoreContentsPair = std::pair<std::unique_ptr<PrefHashStore>, 63 using StoreContentsPair = std::pair<std::unique_ptr<PrefHashStore>,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // FilterSerializeData. 162 // FilterSerializeData.
173 ChangedPathsMap changed_paths_; 163 ChangedPathsMap changed_paths_;
174 164
175 // Whether to report the validity of the super MAC at load time (via UMA). 165 // Whether to report the validity of the super MAC at load time (via UMA).
176 bool report_super_mac_validity_; 166 bool report_super_mac_validity_;
177 167
178 DISALLOW_COPY_AND_ASSIGN(PrefHashFilter); 168 DISALLOW_COPY_AND_ASSIGN(PrefHashFilter);
179 }; 169 };
180 170
181 #endif // COMPONENTS_PREFS_TRACKED_PREF_HASH_FILTER_H_ 171 #endif // COMPONENTS_PREFS_TRACKED_PREF_HASH_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698