Home | History | Annotate | Download | only in tracked
      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.
      4 
      5 #ifndef CHROME_BROWSER_PREFS_TRACKED_TRACKED_ATOMIC_PREFERENCE_H_
      6 #define CHROME_BROWSER_PREFS_TRACKED_TRACKED_ATOMIC_PREFERENCE_H_
      7 
      8 #include <string>
      9 
     10 #include "base/compiler_specific.h"
     11 #include "base/macros.h"
     12 #include "chrome/browser/prefs/pref_hash_filter.h"
     13 #include "chrome/browser/prefs/tracked/tracked_preference.h"
     14 #include "chrome/browser/prefs/tracked/tracked_preference_helper.h"
     15 
     16 class TrackedPreferenceValidationDelegate;
     17 
     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                           TrackedPreferenceValidationDelegate* delegate);
     28 
     29   // TrackedPreference implementation.
     30   virtual void OnNewValue(const base::Value* value,
     31                           PrefHashStoreTransaction* transaction) const OVERRIDE;
     32   virtual bool EnforceAndReport(
     33       base::DictionaryValue* pref_store_contents,
     34       PrefHashStoreTransaction* transaction) const OVERRIDE;
     35 
     36  private:
     37   const std::string pref_path_;
     38   const TrackedPreferenceHelper helper_;
     39   TrackedPreferenceValidationDelegate* delegate_;
     40 
     41   DISALLOW_COPY_AND_ASSIGN(TrackedAtomicPreference);
     42 };
     43 
     44 #endif  // CHROME_BROWSER_PREFS_TRACKED_TRACKED_ATOMIC_PREFERENCE_H_
     45