Chromium Code Reviews| 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_DEFAULT_PREF_STORE_H_ | 5 #ifndef BASE_PREFS_DEFAULT_PREF_STORE_H_ |
| 6 #define BASE_PREFS_DEFAULT_PREF_STORE_H_ | 6 #define BASE_PREFS_DEFAULT_PREF_STORE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/prefs/base_prefs_export.h" | 10 #include "base/prefs/base_prefs_export.h" |
| 11 #include "base/prefs/value_map_pref_store.h" | 11 #include "base/prefs/value_map_pref_store.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "base/hash_tables.h" | |
| 13 | 14 |
| 14 // This PrefStore keeps track of default preference values set when a | 15 // This PrefStore keeps track of default preference values set when a |
| 15 // preference is registered with the PrefService. | 16 // preference is registered with the PrefService. |
| 16 class BASE_PREFS_EXPORT DefaultPrefStore : public ValueMapPrefStore { | 17 class BASE_PREFS_EXPORT DefaultPrefStore : public PrefStore { |
| 17 public: | 18 public: |
| 19 typedef std::hash_map<std::string, base::Value*>::iterator iterator; | |
| 20 typedef std::hash_map<std::string, base::Value*>::const_iterator | |
| 21 const_iterator; | |
| 22 | |
| 18 DefaultPrefStore(); | 23 DefaultPrefStore(); |
| 19 | 24 |
| 25 virtual ReadResult GetValue(const std::string& key, | |
| 26 const base::Value** result) const OVERRIDE; | |
| 27 | |
| 20 // Stores a new |value| for |key|. Assumes ownership of |value|. | 28 // Stores a new |value| for |key|. Assumes ownership of |value|. |
| 21 void SetDefaultValue(const std::string& key, Value* value); | 29 void SetDefaultValue(const std::string& key, Value* value); |
| 22 | 30 |
| 23 // Removes the value for |key|. | 31 // Removes the value for |key|. |
| 24 void RemoveDefaultValue(const std::string& key); | 32 void RemoveDefaultValue(const std::string& key); |
| 25 | 33 |
| 26 // Returns the registered type for |key| or Value::TYPE_NULL if the |key| | 34 // Returns the registered type for |key| or Value::TYPE_NULL if the |key| |
| 27 // has not been registered. | 35 // has not been registered. |
| 28 base::Value::Type GetType(const std::string& key) const; | 36 base::Value::Type GetType(const std::string& key) const; |
| 29 | 37 |
| 38 const_iterator begin() const; | |
| 39 const_iterator end() const; | |
| 40 | |
| 30 protected: | 41 protected: |
| 31 virtual ~DefaultPrefStore(); | 42 virtual ~DefaultPrefStore(); |
| 32 | 43 |
| 33 private: | 44 private: |
| 45 std::hash_map<std::string, base::Value*> prefs_; | |
|
Mattias Nissler (ping if slow)
2012/11/07 08:24:02
This should be a PrefValueMap.
Anthony Berent
2012/11/07 11:22:54
Done. Will be in next patch.
| |
| 46 | |
| 34 DISALLOW_COPY_AND_ASSIGN(DefaultPrefStore); | 47 DISALLOW_COPY_AND_ASSIGN(DefaultPrefStore); |
| 35 }; | 48 }; |
| 36 | 49 |
| 37 #endif // BASE_PREFS_DEFAULT_PREF_STORE_H_ | 50 #endif // BASE_PREFS_DEFAULT_PREF_STORE_H_ |
| OLD | NEW |