OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_PREFS_OVERLAY_PERSISTENT_PREF_STORE_H_ | |
6 #define CHROME_BROWSER_PREFS_OVERLAY_PERSISTENT_PREF_STORE_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/observer_list.h" | |
13 #include "base/ref_counted.h" | |
14 #include "chrome/browser/prefs/pref_value_map.h" | |
15 #include "chrome/common/persistent_pref_store.h" | |
16 | |
17 // PersistentPrefStore that directs all write operations into a in-memory | |
18 // PrefStore. Read operations are first answered by the in-memory PrefStore. | |
19 // If the in-memory PrefStore does not contain a value for the requested key, | |
20 // the look-up passed on to an underlying PersistentPrefStore |underlay_|. | |
Mattias Nissler (ping if slow)
2011/01/05 12:08:07
This comment is outdated to the effect that the in
battre
2011/01/05 20:23:08
Done.
| |
21 class OverlayPersistentPrefStore : public PersistentPrefStore, | |
22 public PrefStore::Observer { | |
23 public: | |
24 explicit OverlayPersistentPrefStore(PersistentPrefStore* underlay); | |
25 virtual ~OverlayPersistentPrefStore(); | |
26 | |
27 // Methods of PrefStore. | |
28 virtual void AddObserver(PrefStore::Observer* observer); | |
29 virtual void RemoveObserver(PrefStore::Observer* observer); | |
30 virtual bool IsInitializationComplete() const; | |
31 virtual ReadResult GetValue(const std::string& key, Value** result) const; | |
32 | |
33 // Methods of PersistentPrefStore. | |
34 virtual void SetValue(const std::string& key, Value* value); | |
35 virtual void SetValueSilently(const std::string& key, Value* value); | |
36 virtual void RemoveValue(const std::string& key); | |
37 virtual bool ReadOnly() const; | |
38 virtual PrefReadError ReadPrefs(); | |
39 virtual bool WritePrefs(); | |
40 virtual void ScheduleWritePrefs(); | |
41 | |
42 private: | |
43 // Methods of PrefStore::Observer. | |
44 virtual void OnPrefValueChanged(const std::string& key); | |
45 virtual void OnInitializationCompleted(); | |
46 | |
47 ObserverList<PrefStore::Observer, true> observers_; | |
48 PrefValueMap overlay_; | |
49 scoped_refptr<PersistentPrefStore> underlay_; | |
50 | |
51 DISALLOW_COPY_AND_ASSIGN(OverlayPersistentPrefStore); | |
52 }; | |
53 | |
54 #endif // CHROME_BROWSER_PREFS_OVERLAY_PERSISTENT_PREF_STORE_H_ | |
OLD | NEW |