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 COMPONENTS_PREFS_PREF_STORE_H_ | 5 #ifndef COMPONENTS_PREFS_PREF_STORE_H_ |
6 #define COMPONENTS_PREFS_PREF_STORE_H_ | 6 #define COMPONENTS_PREFS_PREF_STORE_H_ |
7 | 7 |
8 #include <memory> | |
9 #include <string> | 8 #include <string> |
10 | 9 |
11 #include "base/macros.h" | 10 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
13 #include "components/prefs/base_prefs_export.h" | 12 #include "components/prefs/base_prefs_export.h" |
14 | 13 |
15 namespace base { | 14 namespace base { |
16 class DictionaryValue; | |
17 class Value; | 15 class Value; |
18 } | 16 } |
19 | 17 |
20 // This is an abstract interface for reading and writing from/to a persistent | 18 // This is an abstract interface for reading and writing from/to a persistent |
21 // preference store, used by PrefService. An implementation using a JSON file | 19 // preference store, used by PrefService. An implementation using a JSON file |
22 // can be found in JsonPrefStore, while an implementation without any backing | 20 // can be found in JsonPrefStore, while an implementation without any backing |
23 // store for testing can be found in TestingPrefStore. Furthermore, there is | 21 // store for testing can be found in TestingPrefStore. Furthermore, there is |
24 // CommandLinePrefStore, which bridges command line options to preferences and | 22 // CommandLinePrefStore, which bridges command line options to preferences and |
25 // ConfigurationPolicyPrefStore, which is used for hooking up configuration | 23 // ConfigurationPolicyPrefStore, which is used for hooking up configuration |
26 // policy with the preference subsystem. | 24 // policy with the preference subsystem. |
(...skipping 20 matching lines...) Expand all Loading... |
47 | 45 |
48 // Whether the store has completed all asynchronous initialization. | 46 // Whether the store has completed all asynchronous initialization. |
49 virtual bool IsInitializationComplete() const; | 47 virtual bool IsInitializationComplete() const; |
50 | 48 |
51 // Get the value for a given preference |key| and stores it in |*result|. | 49 // Get the value for a given preference |key| and stores it in |*result|. |
52 // |*result| is only modified if the return value is true and if |result| | 50 // |*result| is only modified if the return value is true and if |result| |
53 // is not NULL. Ownership of the |*result| value remains with the PrefStore. | 51 // is not NULL. Ownership of the |*result| value remains with the PrefStore. |
54 virtual bool GetValue(const std::string& key, | 52 virtual bool GetValue(const std::string& key, |
55 const base::Value** result) const = 0; | 53 const base::Value** result) const = 0; |
56 | 54 |
57 // Get all the values. Never returns a null pointer. | |
58 virtual std::unique_ptr<base::DictionaryValue> GetValues() const = 0; | |
59 | |
60 protected: | 55 protected: |
61 friend class base::RefCounted<PrefStore>; | 56 friend class base::RefCounted<PrefStore>; |
62 virtual ~PrefStore() {} | 57 virtual ~PrefStore() {} |
63 | 58 |
64 private: | 59 private: |
65 DISALLOW_COPY_AND_ASSIGN(PrefStore); | 60 DISALLOW_COPY_AND_ASSIGN(PrefStore); |
66 }; | 61 }; |
67 | 62 |
68 #endif // COMPONENTS_PREFS_PREF_STORE_H_ | 63 #endif // COMPONENTS_PREFS_PREF_STORE_H_ |
OLD | NEW |