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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 public: | 26 public: |
27 // Observer interface for monitoring PrefStore. | 27 // Observer interface for monitoring PrefStore. |
28 class COMPONENTS_PREFS_EXPORT Observer { | 28 class COMPONENTS_PREFS_EXPORT Observer { |
29 public: | 29 public: |
30 // Called when the value for the given |key| in the store changes. | 30 // Called when the value for the given |key| in the store changes. |
31 virtual void OnPrefValueChanged(const std::string& key) = 0; | 31 virtual void OnPrefValueChanged(const std::string& key) = 0; |
32 // Notification about the PrefStore being fully initialized. | 32 // Notification about the PrefStore being fully initialized. |
33 virtual void OnInitializationCompleted(bool succeeded) = 0; | 33 virtual void OnInitializationCompleted(bool succeeded) = 0; |
34 | 34 |
35 protected: | 35 protected: |
36 virtual ~Observer() {} | 36 virtual ~Observer(); |
37 }; | 37 }; |
38 | 38 |
39 PrefStore() {} | 39 PrefStore(); |
| 40 |
| 41 #if defined(WIN32) && defined(COMPONENT_BUILD) |
| 42 void AddRef() const; |
| 43 void Release() const; |
| 44 #endif |
40 | 45 |
41 // Add and remove observers. | 46 // Add and remove observers. |
42 virtual void AddObserver(Observer* observer) {} | 47 virtual void AddObserver(Observer* observer); |
43 virtual void RemoveObserver(Observer* observer) {} | 48 virtual void RemoveObserver(Observer* observer); |
44 virtual bool HasObservers() const; | 49 virtual bool HasObservers() const; |
45 | 50 |
46 // Whether the store has completed all asynchronous initialization. | 51 // Whether the store has completed all asynchronous initialization. |
47 virtual bool IsInitializationComplete() const; | 52 virtual bool IsInitializationComplete() const; |
48 | 53 |
49 // Get the value for a given preference |key| and stores it in |*result|. | 54 // Get the value for a given preference |key| and stores it in |*result|. |
50 // |*result| is only modified if the return value is true and if |result| | 55 // |*result| is only modified if the return value is true and if |result| |
51 // is not NULL. Ownership of the |*result| value remains with the PrefStore. | 56 // is not NULL. Ownership of the |*result| value remains with the PrefStore. |
52 virtual bool GetValue(const std::string& key, | 57 virtual bool GetValue(const std::string& key, |
53 const base::Value** result) const = 0; | 58 const base::Value** result) const = 0; |
54 | 59 |
55 protected: | 60 protected: |
56 friend class base::RefCounted<PrefStore>; | 61 friend class base::RefCounted<PrefStore>; |
57 virtual ~PrefStore() {} | 62 virtual ~PrefStore(); |
58 | 63 |
59 private: | 64 private: |
60 DISALLOW_COPY_AND_ASSIGN(PrefStore); | 65 DISALLOW_COPY_AND_ASSIGN(PrefStore); |
61 }; | 66 }; |
62 | 67 |
63 #endif // COMPONENTS_PREFS_PREF_STORE_H_ | 68 #endif // COMPONENTS_PREFS_PREF_STORE_H_ |
OLD | NEW |