#ifndef CHROME_BROWSER_PREFS_PREF_HASH_FILTER_H_
#define CHROME_BROWSER_PREFS_PREF_HASH_FILTER_H_
#include <map>
#include <set>
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_filter.h"
#include "chrome/browser/prefs/pref_hash_store.h"
#include "chrome/browser/prefs/tracked/tracked_preference.h"
class PersistentPrefStore;
class PrefService;
class PrefStore;
namespace base {
class DictionaryValue;
class Time;
class Value;
}
namespace user_prefs {
class PrefRegistrySyncable;
}
class PrefHashFilter : public PrefFilter {
public:
enum EnforcementLevel {
NO_ENFORCEMENT,
ENFORCE_ON_LOAD
};
enum PrefTrackingStrategy {
TRACKING_STRATEGY_ATOMIC,
TRACKING_STRATEGY_SPLIT,
};
struct TrackedPreferenceMetadata {
size_t reporting_id;
const char* name;
EnforcementLevel enforcement_level;
PrefTrackingStrategy strategy;
};
PrefHashFilter(
scoped_ptr<PrefHashStore> pref_hash_store,
const std::vector<TrackedPreferenceMetadata>& tracked_preferences,
size_t reporting_ids_count);
virtual ~PrefHashFilter();
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
static base::Time GetResetTime(PrefService* user_prefs);
static void ClearResetTime(PrefService* user_prefs);
void Initialize(const PrefStore& pref_store);
void MigrateValues(PersistentPrefStore* source,
PersistentPrefStore* destination);
virtual void FilterOnLoad(base::DictionaryValue* pref_store_contents)
OVERRIDE;
virtual void FilterUpdate(const std::string& path) OVERRIDE;
virtual void FilterSerializeData(
const base::DictionaryValue* pref_store_contents) OVERRIDE;
private:
typedef base::ScopedPtrHashMap<std::string, TrackedPreference>
TrackedPreferencesMap;
typedef std::map<std::string, const TrackedPreference*> ChangedPathsMap;
scoped_ptr<PrefHashStore> pref_hash_store_;
TrackedPreferencesMap tracked_paths_;
ChangedPathsMap changed_paths_;
DISALLOW_COPY_AND_ASSIGN(PrefHashFilter);
};
#endif