OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 BASE_PREFS_VALUE_MAP_PREF_STORE_H_ | 5 #ifndef BASE_PREFS_VALUE_MAP_PREF_STORE_H_ |
6 #define BASE_PREFS_VALUE_MAP_PREF_STORE_H_ | 6 #define BASE_PREFS_VALUE_MAP_PREF_STORE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "base/prefs/base_prefs_export.h" | 13 #include "base/prefs/base_prefs_export.h" |
14 #include "base/prefs/pref_store.h" | 14 #include "base/prefs/pref_store.h" |
15 #include "base/prefs/pref_value_map.h" | 15 #include "base/prefs/pref_value_map.h" |
16 | 16 |
17 // A basic PrefStore implementation that uses a simple name-value map for | 17 // A basic PrefStore implementation that uses a simple name-value map for |
18 // storing the preference values. | 18 // storing the preference values. |
19 class BASE_PREFS_EXPORT ValueMapPrefStore : public PrefStore { | 19 class BASE_PREFS_EXPORT ValueMapPrefStore : public PrefStore { |
20 public: | 20 public: |
21 typedef std::map<std::string, base::Value*>::iterator iterator; | 21 typedef std::map<std::string, base::Value*>::iterator iterator; |
22 typedef std::map<std::string, base::Value*>::const_iterator const_iterator; | 22 typedef std::map<std::string, base::Value*>::const_iterator const_iterator; |
23 | 23 |
24 ValueMapPrefStore(); | 24 ValueMapPrefStore(); |
25 | 25 |
26 // PrefStore overrides: | 26 // PrefStore overrides: |
27 virtual ReadResult GetValue(const std::string& key, | 27 virtual bool GetValue(const std::string& key, |
28 const base::Value** value) const OVERRIDE; | 28 const base::Value** value) const OVERRIDE; |
29 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; | 29 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; |
30 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE; | 30 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE; |
31 virtual size_t NumberOfObservers() const OVERRIDE; | 31 virtual size_t NumberOfObservers() const OVERRIDE; |
32 | 32 |
33 iterator begin(); | 33 iterator begin(); |
34 iterator end(); | 34 iterator end(); |
35 const_iterator begin() const; | 35 const_iterator begin() const; |
36 const_iterator end() const; | 36 const_iterator end() const; |
37 | 37 |
38 protected: | 38 protected: |
(...skipping 12 matching lines...) Expand all Loading... |
51 | 51 |
52 private: | 52 private: |
53 PrefValueMap prefs_; | 53 PrefValueMap prefs_; |
54 | 54 |
55 ObserverList<PrefStore::Observer, true> observers_; | 55 ObserverList<PrefStore::Observer, true> observers_; |
56 | 56 |
57 DISALLOW_COPY_AND_ASSIGN(ValueMapPrefStore); | 57 DISALLOW_COPY_AND_ASSIGN(ValueMapPrefStore); |
58 }; | 58 }; |
59 | 59 |
60 #endif // BASE_PREFS_VALUE_MAP_PREF_STORE_H_ | 60 #endif // BASE_PREFS_VALUE_MAP_PREF_STORE_H_ |
OLD | NEW |