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_ATOMIC_PREFERENCE_H_ | 5 #ifndef SERVICES_PREFERENCES_TRACKED_TRACKED_ATOMIC_PREFERENCE_H_ |
6 #define COMPONENTS_USER_PREFS_TRACKED_ATOMIC_PREFERENCE_H_ | 6 #define SERVICES_PREFERENCES_TRACKED_TRACKED_ATOMIC_PREFERENCE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "components/user_prefs/tracked/pref_hash_filter.h" | 14 #include "services/preferences/tracked/pref_hash_filter.h" |
15 #include "components/user_prefs/tracked/tracked_preference.h" | 15 #include "services/preferences/tracked/tracked_preference.h" |
16 #include "components/user_prefs/tracked/tracked_preference_helper.h" | 16 #include "services/preferences/tracked/tracked_preference_helper.h" |
17 | 17 |
18 namespace prefs { | 18 namespace prefs { |
19 namespace mojom { | 19 namespace mojom { |
20 class TrackedPreferenceValidationDelegate; | 20 class TrackedPreferenceValidationDelegate; |
21 } | 21 } |
22 } | 22 } |
23 | 23 |
24 // A TrackedAtomicPreference is tracked as a whole. A hash is stored for its | 24 // A TrackedAtomicPreference is tracked as a whole. A hash is stored for its |
25 // entire value and it is entirely reset on mismatch. An optional delegate is | 25 // entire value and it is entirely reset on mismatch. An optional delegate is |
26 // notified of the status of the preference during enforcement. | 26 // notified of the status of the preference during enforcement. |
27 class TrackedAtomicPreference : public TrackedPreference { | 27 class TrackedAtomicPreference : public TrackedPreference { |
28 public: | 28 public: |
29 TrackedAtomicPreference( | 29 TrackedAtomicPreference( |
30 const std::string& pref_path, | 30 const std::string& pref_path, |
31 size_t reporting_id, | 31 size_t reporting_id, |
32 size_t reporting_ids_count, | 32 size_t reporting_ids_count, |
33 PrefHashFilter::EnforcementLevel enforcement_level, | 33 prefs::mojom::TrackedPreferenceMetadata::EnforcementLevel |
34 PrefHashFilter::ValueType value_type, | 34 enforcement_level, |
| 35 prefs::mojom::TrackedPreferenceMetadata::ValueType value_type, |
35 prefs::mojom::TrackedPreferenceValidationDelegate* delegate); | 36 prefs::mojom::TrackedPreferenceValidationDelegate* delegate); |
36 | 37 |
37 // TrackedPreference implementation. | 38 // TrackedPreference implementation. |
38 TrackedPreferenceType GetType() const override; | 39 TrackedPreferenceType GetType() const override; |
39 void OnNewValue(const base::Value* value, | 40 void OnNewValue(const base::Value* value, |
40 PrefHashStoreTransaction* transaction) const override; | 41 PrefHashStoreTransaction* transaction) const override; |
41 bool EnforceAndReport( | 42 bool EnforceAndReport( |
42 base::DictionaryValue* pref_store_contents, | 43 base::DictionaryValue* pref_store_contents, |
43 PrefHashStoreTransaction* transaction, | 44 PrefHashStoreTransaction* transaction, |
44 PrefHashStoreTransaction* external_validation_transaction) const override; | 45 PrefHashStoreTransaction* external_validation_transaction) const override; |
45 | 46 |
46 private: | 47 private: |
47 const std::string pref_path_; | 48 const std::string pref_path_; |
48 const TrackedPreferenceHelper helper_; | 49 const TrackedPreferenceHelper helper_; |
49 prefs::mojom::TrackedPreferenceValidationDelegate* delegate_; | 50 prefs::mojom::TrackedPreferenceValidationDelegate* delegate_; |
50 | 51 |
51 DISALLOW_COPY_AND_ASSIGN(TrackedAtomicPreference); | 52 DISALLOW_COPY_AND_ASSIGN(TrackedAtomicPreference); |
52 }; | 53 }; |
53 | 54 |
54 #endif // COMPONENTS_USER_PREFS_TRACKED_ATOMIC_PREFERENCE_H_ | 55 #endif // SERVICES_PREFERENCES_TRACKED_TRACKED_ATOMIC_PREFERENCE_H_ |
OLD | NEW |