Roll src/third_party/WebKit 9f7fb92:f103b33 (svn 202621:202622)
[chromium-blink-merge.git] / components / user_prefs / tracked / tracked_atomic_preference.h
blob3e183cf3dbd08cd2e1757c9d529d355856326874
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_USER_PREFS_TRACKED_ATOMIC_PREFERENCE_H_
6 #define COMPONENTS_USER_PREFS_TRACKED_ATOMIC_PREFERENCE_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
12 #include "components/user_prefs/tracked/pref_hash_filter.h"
13 #include "components/user_prefs/tracked/tracked_preference.h"
14 #include "components/user_prefs/tracked/tracked_preference_helper.h"
16 class TrackedPreferenceValidationDelegate;
18 // A TrackedAtomicPreference is tracked as a whole. A hash is stored for its
19 // entire value and it is entirely reset on mismatch. An optional delegate is
20 // notified of the status of the preference during enforcement.
21 class TrackedAtomicPreference : public TrackedPreference {
22 public:
23 TrackedAtomicPreference(const std::string& pref_path,
24 size_t reporting_id,
25 size_t reporting_ids_count,
26 PrefHashFilter::EnforcementLevel enforcement_level,
27 PrefHashFilter::ValueType value_type,
28 TrackedPreferenceValidationDelegate* delegate);
30 // TrackedPreference implementation.
31 void OnNewValue(const base::Value* value,
32 PrefHashStoreTransaction* transaction) const override;
33 bool EnforceAndReport(base::DictionaryValue* pref_store_contents,
34 PrefHashStoreTransaction* transaction) const override;
36 private:
37 const std::string pref_path_;
38 const TrackedPreferenceHelper helper_;
39 TrackedPreferenceValidationDelegate* delegate_;
41 DISALLOW_COPY_AND_ASSIGN(TrackedAtomicPreference);
44 #endif // COMPONENTS_USER_PREFS_TRACKED_ATOMIC_PREFERENCE_H_