OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_PREFS_OVERLAY_USER_PREF_STORE_H_ | 5 #ifndef CHROME_BROWSER_PREFS_OVERLAY_USER_PREF_STORE_H_ |
6 #define CHROME_BROWSER_PREFS_OVERLAY_USER_PREF_STORE_H_ | 6 #define CHROME_BROWSER_PREFS_OVERLAY_USER_PREF_STORE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 13 matching lines...) Expand all Loading... |
24 public: | 24 public: |
25 explicit OverlayUserPrefStore(PersistentPrefStore* underlay); | 25 explicit OverlayUserPrefStore(PersistentPrefStore* underlay); |
26 virtual ~OverlayUserPrefStore(); | 26 virtual ~OverlayUserPrefStore(); |
27 | 27 |
28 // Returns true if a value has been set for the |key| in this | 28 // Returns true if a value has been set for the |key| in this |
29 // OverlayUserPrefStore, i.e. if it potentially overrides a value | 29 // OverlayUserPrefStore, i.e. if it potentially overrides a value |
30 // from the |underlay_|. | 30 // from the |underlay_|. |
31 virtual bool IsSetInOverlay(const std::string& key) const; | 31 virtual bool IsSetInOverlay(const std::string& key) const; |
32 | 32 |
33 // Methods of PrefStore. | 33 // Methods of PrefStore. |
34 virtual void AddObserver(PrefStore::Observer* observer); | 34 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; |
35 virtual void RemoveObserver(PrefStore::Observer* observer); | 35 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE; |
36 virtual bool IsInitializationComplete() const; | 36 virtual bool IsInitializationComplete() const OVERRIDE; |
37 virtual ReadResult GetValue(const std::string& key, | 37 virtual ReadResult GetValue(const std::string& key, |
38 const base::Value** result) const; | 38 const base::Value** result) const OVERRIDE; |
39 | 39 |
40 // Methods of PersistentPrefStore. | 40 // Methods of PersistentPrefStore. |
41 virtual ReadResult GetMutableValue(const std::string& key, | 41 virtual ReadResult GetMutableValue(const std::string& key, |
42 base::Value** result); | 42 base::Value** result) OVERRIDE; |
43 virtual void SetValue(const std::string& key, base::Value* value); | 43 virtual void SetValue(const std::string& key, base::Value* value) OVERRIDE; |
44 virtual void SetValueSilently(const std::string& key, base::Value* value); | 44 virtual void SetValueSilently(const std::string& key, |
45 virtual void RemoveValue(const std::string& key); | 45 base::Value* value) OVERRIDE; |
46 virtual bool ReadOnly() const; | 46 virtual void RemoveValue(const std::string& key) OVERRIDE; |
47 virtual PrefReadError ReadPrefs(); | 47 virtual bool ReadOnly() const OVERRIDE; |
48 virtual void ReadPrefsAsync(ReadErrorDelegate* delegate); | 48 virtual PrefReadError ReadPrefs() OVERRIDE; |
49 virtual bool WritePrefs(); | 49 virtual void ReadPrefsAsync(ReadErrorDelegate* delegate) OVERRIDE; |
50 virtual void ScheduleWritePrefs(); | 50 virtual bool WritePrefs() OVERRIDE; |
51 virtual void CommitPendingWrite(); | 51 virtual void ScheduleWritePrefs() OVERRIDE; |
52 virtual void ReportValueChanged(const std::string& key); | 52 virtual void CommitPendingWrite() OVERRIDE; |
| 53 virtual void ReportValueChanged(const std::string& key) OVERRIDE; |
53 | 54 |
54 protected: | 55 protected: |
55 void RegisterOverlayProperty(const std::string& key); | 56 void RegisterOverlayProperty(const std::string& key); |
56 void RegisterOverlayProperty(const std::string& overlay_key, | 57 void RegisterOverlayProperty(const std::string& overlay_key, |
57 const std::string& underlay_key); | 58 const std::string& underlay_key); |
58 | 59 |
59 private: | 60 private: |
60 friend class OverlayUserPrefStoreTest; | 61 friend class OverlayUserPrefStoreTest; |
61 | 62 |
62 typedef std::map<std::string, std::string> NamesMap; | 63 typedef std::map<std::string, std::string> NamesMap; |
63 | 64 |
64 // Methods of PrefStore::Observer. | 65 // Methods of PrefStore::Observer. |
65 virtual void OnPrefValueChanged(const std::string& key); | 66 virtual void OnPrefValueChanged(const std::string& key) OVERRIDE; |
66 virtual void OnInitializationCompleted(bool succeeded); | 67 virtual void OnInitializationCompleted(bool succeeded) OVERRIDE; |
67 | 68 |
68 const std::string& GetOverlayKey(const std::string& underlay_key) const; | 69 const std::string& GetOverlayKey(const std::string& underlay_key) const; |
69 const std::string& GetUnderlayKey(const std::string& overlay_key) const; | 70 const std::string& GetUnderlayKey(const std::string& overlay_key) const; |
70 | 71 |
71 // Returns true if |key| corresponds to a preference that shall be stored in | 72 // Returns true if |key| corresponds to a preference that shall be stored in |
72 // an in-memory PrefStore that is not persisted to disk. | 73 // an in-memory PrefStore that is not persisted to disk. |
73 bool ShallBeStoredInOverlay(const std::string& key) const; | 74 bool ShallBeStoredInOverlay(const std::string& key) const; |
74 | 75 |
75 ObserverList<PrefStore::Observer, true> observers_; | 76 ObserverList<PrefStore::Observer, true> observers_; |
76 PrefValueMap overlay_; | 77 PrefValueMap overlay_; |
77 scoped_refptr<PersistentPrefStore> underlay_; | 78 scoped_refptr<PersistentPrefStore> underlay_; |
78 NamesMap overlay_to_underlay_names_map_; | 79 NamesMap overlay_to_underlay_names_map_; |
79 NamesMap underlay_to_overlay_names_map_; | 80 NamesMap underlay_to_overlay_names_map_; |
80 | 81 |
81 DISALLOW_COPY_AND_ASSIGN(OverlayUserPrefStore); | 82 DISALLOW_COPY_AND_ASSIGN(OverlayUserPrefStore); |
82 }; | 83 }; |
83 | 84 |
84 #endif // CHROME_BROWSER_PREFS_OVERLAY_USER_PREF_STORE_H_ | 85 #endif // CHROME_BROWSER_PREFS_OVERLAY_USER_PREF_STORE_H_ |
OLD | NEW |