OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_BROWSER_PREFS_PREF_NOTIFIER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_PREFS_PREF_NOTIFIER_IMPL_H_ |
6 #define CHROME_BROWSER_PREFS_PREF_NOTIFIER_IMPL_H_ | 6 #define CHROME_BROWSER_PREFS_PREF_NOTIFIER_IMPL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 // If the pref at the given path changes, we call the observer's Observe | 26 // If the pref at the given path changes, we call the observer's Observe |
27 // method with PREF_CHANGED. | 27 // method with PREF_CHANGED. |
28 void AddPrefObserver(const char* path, NotificationObserver* obs); | 28 void AddPrefObserver(const char* path, NotificationObserver* obs); |
29 void RemovePrefObserver(const char* path, NotificationObserver* obs); | 29 void RemovePrefObserver(const char* path, NotificationObserver* obs); |
30 | 30 |
31 // PrefNotifier overrides. | 31 // PrefNotifier overrides. |
32 virtual void OnPreferenceChanged(const std::string& pref_name); | 32 virtual void OnPreferenceChanged(const std::string& pref_name); |
33 virtual void OnInitializationCompleted(); | 33 virtual void OnInitializationCompleted(); |
34 | 34 |
| 35 void OnPersistentPrefsRead(bool success); |
| 36 |
35 protected: | 37 protected: |
| 38 void NotifyInitializationCompleted(); |
| 39 void NotifyInitializationFailed(); |
| 40 |
36 // A map from pref names to a list of observers. Observers get fired in the | 41 // A map from pref names to a list of observers. Observers get fired in the |
37 // order they are added. These should only be accessed externally for unit | 42 // order they are added. These should only be accessed externally for unit |
38 // testing. | 43 // testing. |
39 typedef ObserverList<NotificationObserver> NotificationObserverList; | 44 typedef ObserverList<NotificationObserver> NotificationObserverList; |
40 typedef base::hash_map<std::string, NotificationObserverList*> | 45 typedef base::hash_map<std::string, NotificationObserverList*> |
41 PrefObserverMap; | 46 PrefObserverMap; |
42 | 47 |
43 const PrefObserverMap* pref_observers() const { return &pref_observers_; } | 48 const PrefObserverMap* pref_observers() const { return &pref_observers_; } |
44 | 49 |
45 private: | 50 private: |
46 // For the given pref_name, fire any observer of the pref. Virtual so it can | 51 // For the given pref_name, fire any observer of the pref. Virtual so it can |
47 // be mocked for unit testing. | 52 // be mocked for unit testing. |
48 virtual void FireObservers(const std::string& path); | 53 virtual void FireObservers(const std::string& path); |
49 | 54 |
50 // Weak reference; the notifier is owned by the PrefService. | 55 // Weak reference; the notifier is owned by the PrefService. |
51 PrefService* pref_service_; | 56 PrefService* pref_service_; |
52 | 57 |
53 PrefObserverMap pref_observers_; | 58 PrefObserverMap pref_observers_; |
54 | 59 |
| 60 bool pref_notifier_ready_; |
| 61 bool persistent_prefs_ready_; |
| 62 |
55 DISALLOW_COPY_AND_ASSIGN(PrefNotifierImpl); | 63 DISALLOW_COPY_AND_ASSIGN(PrefNotifierImpl); |
56 }; | 64 }; |
57 | 65 |
58 #endif // CHROME_BROWSER_PREFS_PREF_NOTIFIER_IMPL_H_ | 66 #endif // CHROME_BROWSER_PREFS_PREF_NOTIFIER_IMPL_H_ |
OLD | NEW |