Temporarily re-enabling SizeAfterPrefChange test with traces (this time for Linux...
[chromium-blink-merge.git] / chrome / browser / prefs / tracked / pref_service_hash_store_contents.h
blob29abff67e96dbb0b3faa858e3e92e78c68271e89
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 CHROME_BROWSER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_
6 #define CHROME_BROWSER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
12 #include "chrome/browser/prefs/tracked/hash_store_contents.h"
14 class PrefRegistrySimple;
15 class PrefService;
17 // Implements HashStoreContents by storing hashes in a PrefService. Multiple
18 // separate hash stores may coexist in the PrefService by using distinct hash
19 // store IDs.
20 class PrefServiceHashStoreContents : public HashStoreContents {
21 public:
22 // Constructs a HashStoreContents that stores hashes in |pref_service|.
23 // Multiple hash stores can use the same |pref_service| with distinct
24 // |hash_store_id|s.
26 // |pref_service| must have previously been configured using |RegisterPrefs|.
27 PrefServiceHashStoreContents(const std::string& hash_store_id,
28 PrefService* pref_service);
30 // The name of a dict that is stored as a child of
31 // |prefs::kProfilePreferenceHashes|. Each child node is a string whose name
32 // is a hash store ID and whose value is the super MAC for the corresponding
33 // hash store.
34 static const char kHashOfHashesDict[];
36 // The name of a dict that is stored as a child of
37 // |prefs::kProfilePreferenceHashes|. Each child node is a number whose name
38 // is a hash store ID and whose value is the version of the corresponding
39 // hash store.
40 static const char kStoreVersionsDict[];
42 // Registers required preferences.
43 static void RegisterPrefs(PrefRegistrySimple* registry);
45 // Deletes stored hashes for all profiles from |pref_service|.
46 static void ResetAllPrefHashStores(PrefService* pref_service);
48 // HashStoreContents implementation
49 virtual std::string hash_store_id() const OVERRIDE;
50 virtual void Reset() OVERRIDE;
51 virtual bool IsInitialized() const OVERRIDE;
52 virtual bool GetVersion(int* version) const OVERRIDE;
53 virtual void SetVersion(int version) OVERRIDE;
54 virtual const base::DictionaryValue* GetContents() const OVERRIDE;
55 virtual scoped_ptr<MutableDictionary> GetMutableContents() OVERRIDE;
56 virtual std::string GetSuperMac() const OVERRIDE;
57 virtual void SetSuperMac(const std::string& super_mac) OVERRIDE;
58 virtual void CommitPendingWrite() OVERRIDE;
60 private:
61 const std::string hash_store_id_;
62 PrefService* pref_service_;
64 DISALLOW_COPY_AND_ASSIGN(PrefServiceHashStoreContents);
67 #endif // CHROME_BROWSER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_