root/chrome/browser/prefs/tracked/pref_service_hash_store_contents.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_
#define CHROME_BROWSER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_

#include <string>

#include "base/compiler_specific.h"
#include "base/macros.h"
#include "chrome/browser/prefs/tracked/hash_store_contents.h"

class PrefRegistrySimple;
class PrefService;

// Implements HashStoreContents by storing hashes in a PrefService. Multiple
// separate hash stores may coexist in the PrefService by using distinct hash
// store IDs.
class PrefServiceHashStoreContents : public HashStoreContents {
 public:
  // Constructs a HashStoreContents that stores hashes in |pref_service|.
  // Multiple hash stores can use the same |pref_service| with distinct
  // |hash_store_id|s.
  //
  // |pref_service| must have previously been configured using |RegisterPrefs|.
  PrefServiceHashStoreContents(const std::string& hash_store_id,
                               PrefService* pref_service);

  // The name of a dict that is stored as a child of
  // |prefs::kProfilePreferenceHashes|. Each child node is a string whose name
  // is a hash store ID and whose value is the super MAC for the corresponding
  // hash store.
  static const char kHashOfHashesDict[];

  // The name of a dict that is stored as a child of
  // |prefs::kProfilePreferenceHashes|. Each child node is a number whose name
  // is a hash store ID and whose value is the version of the corresponding
  // hash store.
  static const char kStoreVersionsDict[];

  // Registers required preferences.
  static void RegisterPrefs(PrefRegistrySimple* registry);

  // Deletes stored hashes for all profiles from |pref_service|.
  static void ResetAllPrefHashStores(PrefService* pref_service);

  // HashStoreContents implementation
  virtual std::string hash_store_id() const OVERRIDE;
  virtual void Reset() OVERRIDE;
  virtual bool IsInitialized() const OVERRIDE;
  virtual bool GetVersion(int* version) const OVERRIDE;
  virtual void SetVersion(int version) OVERRIDE;
  virtual const base::DictionaryValue* GetContents() const OVERRIDE;
  virtual scoped_ptr<MutableDictionary> GetMutableContents() OVERRIDE;
  virtual std::string GetSuperMac() const OVERRIDE;
  virtual void SetSuperMac(const std::string& super_mac) OVERRIDE;
  virtual void CommitPendingWrite() OVERRIDE;

 private:
  const std::string hash_store_id_;
  PrefService* pref_service_;

  DISALLOW_COPY_AND_ASSIGN(PrefServiceHashStoreContents);
};

#endif  // CHROME_BROWSER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_

/* [<][>][^][v][top][bottom][index][help] */