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_COMMON_PREF_STORE_H_ | 5 #ifndef CHROME_COMMON_PREF_STORE_H_ |
6 #define CHROME_COMMON_PREF_STORE_H_ | 6 #define CHROME_COMMON_PREF_STORE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 | 13 |
| 14 namespace base { |
14 class Value; | 15 class Value; |
| 16 } |
15 | 17 |
16 // 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 |
17 // preference store, used by PrefService. An implementation using a JSON file | 19 // preference store, used by PrefService. An implementation using a JSON file |
18 // can be found in JsonPrefStore, while an implementation without any backing | 20 // can be found in JsonPrefStore, while an implementation without any backing |
19 // store for testing can be found in TestingPrefStore. Furthermore, there is | 21 // store for testing can be found in TestingPrefStore. Furthermore, there is |
20 // CommandLinePrefStore, which bridges command line options to preferences and | 22 // CommandLinePrefStore, which bridges command line options to preferences and |
21 // ConfigurationPolicyPrefStore, which is used for hooking up configuration | 23 // ConfigurationPolicyPrefStore, which is used for hooking up configuration |
22 // policy with the preference subsystem. | 24 // policy with the preference subsystem. |
23 class PrefStore : public base::RefCounted<PrefStore> { | 25 class PrefStore : public base::RefCounted<PrefStore> { |
24 public: | 26 public: |
(...skipping 24 matching lines...) Expand all Loading... |
49 virtual void AddObserver(Observer* observer) {} | 51 virtual void AddObserver(Observer* observer) {} |
50 virtual void RemoveObserver(Observer* observer) {} | 52 virtual void RemoveObserver(Observer* observer) {} |
51 | 53 |
52 // Whether the store has completed all asynchronous initialization. | 54 // Whether the store has completed all asynchronous initialization. |
53 virtual bool IsInitializationComplete() const; | 55 virtual bool IsInitializationComplete() const; |
54 | 56 |
55 // Get the value for a given preference |key| and stores it in |result|. | 57 // Get the value for a given preference |key| and stores it in |result|. |
56 // |result| is only modified if the return value is READ_OK. Ownership of the | 58 // |result| is only modified if the return value is READ_OK. Ownership of the |
57 // |result| value remains with the PrefStore. | 59 // |result| value remains with the PrefStore. |
58 virtual ReadResult GetValue(const std::string& key, | 60 virtual ReadResult GetValue(const std::string& key, |
59 const Value** result) const = 0; | 61 const base::Value** result) const = 0; |
60 | 62 |
61 protected: | 63 protected: |
62 friend class base::RefCounted<PrefStore>; | 64 friend class base::RefCounted<PrefStore>; |
63 virtual ~PrefStore() {} | 65 virtual ~PrefStore() {} |
64 | 66 |
65 private: | 67 private: |
66 DISALLOW_COPY_AND_ASSIGN(PrefStore); | 68 DISALLOW_COPY_AND_ASSIGN(PrefStore); |
67 }; | 69 }; |
68 | 70 |
69 #endif // CHROME_COMMON_PREF_STORE_H_ | 71 #endif // CHROME_COMMON_PREF_STORE_H_ |
OLD | NEW |