Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: chrome/browser/prefs/pref_value_store.h

Issue 5441002: Clean up pref change notification handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_VALUE_STORE_H_ 5 #ifndef CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_
6 #define CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ 6 #define CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/ref_counted.h" 16 #include "base/ref_counted.h"
17 #include "base/scoped_ptr.h" 17 #include "base/scoped_ptr.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/browser_thread.h" 19 #include "chrome/browser/browser_thread.h"
20 #include "chrome/browser/prefs/pref_notifier.h" 20 #include "chrome/common/notification_observer.h"
21 #include "chrome/common/notification_registrar.h"
21 #include "chrome/common/pref_store.h" 22 #include "chrome/common/pref_store.h"
22 23
23 class FilePath; 24 class FilePath;
25 class PrefNotifier;
24 class PrefStore; 26 class PrefStore;
25 class Profile; 27 class Profile;
26 28
27 // The PrefValueStore manages various sources of values for Preferences 29 // The PrefValueStore manages various sources of values for Preferences
28 // (e.g., configuration policies, extensions, and user settings). It returns 30 // (e.g., configuration policies, extensions, and user settings). It returns
29 // the value of a Preference from the source with the highest priority, and 31 // the value of a Preference from the source with the highest priority, and
30 // allows setting user-defined values for preferences that are not managed. 32 // allows setting user-defined values for preferences that are not managed.
31 // See PrefNotifier for a list of the available preference sources (PrefStores)
32 // and their descriptions.
33 // 33 //
34 // Unless otherwise explicitly noted, all of the methods of this class must 34 // Unless otherwise explicitly noted, all of the methods of this class must
35 // be called on the UI thread. 35 // be called on the UI thread.
36 class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { 36 class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore>,
37 public NotificationObserver {
37 public: 38 public:
38 // Returns a new PrefValueStore with all applicable PrefStores. The 39 // In decreasing order of precedence:
39 // |pref_filename| points to the user preference file. The |profile| is the 40 // |managed_platform_prefs| contains all managed platform (non-cloud policy)
40 // one to which these preferences apply; it may be NULL if we're dealing 41 // preference values.
41 // with the local state. If |pref_filename| is empty, the user PrefStore will 42 // |device_management_prefs| contains all device management (cloud policy)
42 // not be created. If |user_only| is true, no PrefStores will be created 43 // preference values.
43 // other than the user and default PrefStores. This should not normally be 44 // |extension_prefs| contains preference values set by extensions.
44 // called directly: the usual way to create a PrefValueStore is by creating a 45 // |command_line_prefs| contains preference values set by command-line
45 // PrefService. 46 // switches.
46 static PrefValueStore* CreatePrefValueStore(const FilePath& pref_filename, 47 // |user_prefs| contains all user-set preference values.
47 Profile* profile, 48 // |recommended_prefs| contains all recommended (policy) preference values.
48 bool user_only); 49 // |default_prefs| contains application-default preference values. It must
49 50 // be non-null if any preferences are to be registered.
50 ~PrefValueStore(); 51 //
52 // |pref_notifier| facilitates broadcasting preference change notifications
53 // to the world.
54 //
55 // The |profile| parameter is used to construct a replacement device
56 // management pref store. This is done after policy refresh when we swap out
57 // the policy pref stores for new ones, so the |profile| pointer needs to be
58 // kept around for then. It is safe to pass a NULL pointer for local state
59 // preferences.
60 //
61 // TODO(mnissler, danno): Refactor the pref store interface and refresh logic
62 // so refreshes can be handled by the pref store itself without swapping
63 // stores. This way we can get rid of the profile pointer here.
64 PrefValueStore(PrefStore* managed_platform_prefs,
65 PrefStore* device_management_prefs,
66 PrefStore* extension_prefs,
67 PrefStore* command_line_prefs,
68 PrefStore* user_prefs,
69 PrefStore* recommended_prefs,
70 PrefStore* default_prefs,
71 PrefNotifier* pref_notifier,
72 Profile* profile);
73 virtual ~PrefValueStore();
51 74
52 // Gets the value for the given preference name that has a valid value type; 75 // Gets the value for the given preference name that has a valid value type;
53 // that is, the same type the preference was registered with, or NULL for 76 // that is, the same type the preference was registered with, or NULL for
54 // default values of Dictionaries and Lists. Returns true if a valid value 77 // default values of Dictionaries and Lists. Returns true if a valid value
55 // was found in any of the available PrefStores. Most callers should use 78 // was found in any of the available PrefStores. Most callers should use
56 // Preference::GetValue() instead of calling this method directly. 79 // Preference::GetValue() instead of calling this method directly.
57 bool GetValue(const std::string& name, Value** out_value) const; 80 bool GetValue(const std::string& name, Value** out_value) const;
58 81
59 // Same as GetValue but only searches USER_STORE. 82 // Same as GetValue but only searches the user store.
60 bool GetUserValue(const std::string& name, Value** out_value) const; 83 bool GetUserValue(const std::string& name, Value** out_value) const;
61 84
62 // Adds a preference to the mapping of names to types. 85 // Adds a preference to the mapping of names to types.
63 void RegisterPreferenceType(const std::string& name, Value::ValueType type); 86 void RegisterPreferenceType(const std::string& name, Value::ValueType type);
64 87
65 // Gets the registered value type for the given preference name. Returns 88 // Gets the registered value type for the given preference name. Returns
66 // Value::TYPE_NULL if the preference has never been registered. 89 // Value::TYPE_NULL if the preference has never been registered.
67 Value::ValueType GetRegisteredType(const std::string& name) const; 90 Value::ValueType GetRegisteredType(const std::string& name) const;
68 91
69 // Read preference values into the three PrefStores so that they are available 92 // Read preference values into the three PrefStores so that they are available
(...skipping 10 matching lines...) Expand all
80 // the user prefs are expected to be written out. 103 // the user prefs are expected to be written out.
81 void ScheduleWritePrefs(); 104 void ScheduleWritePrefs();
82 105
83 // Returns true if the PrefValueStore contains the given preference (i.e., 106 // Returns true if the PrefValueStore contains the given preference (i.e.,
84 // it's been registered), and a value with the correct type has been actively 107 // it's been registered), and a value with the correct type has been actively
85 // set in some pref store. The application default specified when the pref was 108 // set in some pref store. The application default specified when the pref was
86 // registered does not count as an "actively set" value, but another pref 109 // registered does not count as an "actively set" value, but another pref
87 // store setting a value that happens to be equal to the default does. 110 // store setting a value that happens to be equal to the default does.
88 bool HasPrefPath(const char* name) const; 111 bool HasPrefPath(const char* name) const;
89 112
90 // Called by the PrefNotifier when the value of the preference at |path| has
91 // changed, been added, or been removed in one of the PrefStores. The
92 // |new_store| is the PrefStoreType of the caller. Returns true if the
93 // effective value of the preference has changed, or if the store controlling
94 // the pref has changed. Virtual so it can be mocked for a unit test.
95 virtual bool PrefHasChanged(const char* path,
96 PrefNotifier::PrefStoreType new_store);
97
98 // Returns true if the PrefValueStore is read-only. Because the managed 113 // Returns true if the PrefValueStore is read-only. Because the managed
99 // platform, device management and recommended PrefStores are always 114 // platform, device management and recommended PrefStores are always
100 // read-only, the PrefValueStore as a whole is read-only if the PrefStore 115 // read-only, the PrefValueStore as a whole is read-only if the PrefStore
101 // containing the user preferences is read-only. 116 // containing the user preferences is read-only.
102 bool ReadOnly(); 117 bool ReadOnly();
battre (please use the other) 2010/12/02 11:51:34 Can we make this const?
Mattias Nissler (ping if slow) 2010/12/02 16:38:24 Done.
103 118
104 // Alters the user-defined value of a preference. Even if the preference is 119 // Alters the user-defined value of a preference. Even if the preference is
105 // managed this method allows the user-defined value of the preference to be 120 // managed this method allows the user-defined value of the preference to be
106 // set. But GetValue calls will not return this value as long as the 121 // set. However, GetValue calls will not return this value as long as the
107 // preference is managed. Instead GetValue will return the managed value 122 // preference is overriden by a store of higher precedence. Note that the
108 // of the preference. Note that the PrefValueStore takes the ownership of 123 // PrefValueStore takes the ownership of the value referenced by |in_value|.
109 // the value referenced by |in_value|. It is an error to call this when no 124 // It is an error to call this when no user PrefStore has been set. Triggers
110 // user PrefStore has been set. Returns true if the user-set value of the 125 // notifications if the user-visible value changes.
111 // preference was newly added or changed. 126 void SetUserPrefValue(const char* name, Value* in_value);
112 bool SetUserPrefValue(const char* name, Value* in_value);
113 127
114 // Removes a value from the user PrefStore. If a preference is managed 128 // Like SetUserPrefValue, but silently puts the value without triggering
115 // this function should have no visible effect. Returns true if there was a 129 // notifications.
116 // user-set value to be removed. 130 void PutUserPrefValue(const char* name, Value* in_value);
battre (please use the other) 2010/12/02 10:41:19 How about SetUserPrefValueSilently? Put and Set so
Mattias Nissler (ping if slow) 2010/12/02 16:38:24 Done.
117 bool RemoveUserPrefValue(const char* name);
118 131
119 // Sets a value in the DefaultPrefStore, which takes ownership of the Value. 132 // Removes a value from the user PrefStore. If a preference is overriden by a
120 void SetDefaultPrefValue(const char* name, Value* in_value); 133 // store of higher precedence, this function will have no immediately visible
134 // effect. Triggers notifications if the user-visible value changes.
135 void RemoveUserPrefValue(const char* name);
121 136
122 // These methods return true if a preference with the given name is in the 137 // These methods return true if a preference with the given name is in the
123 // indicated pref store, even if that value is currently being overridden by 138 // indicated pref store, even if that value is currently being overridden by
124 // a higher-priority source. 139 // a higher-priority source.
125 bool PrefValueInManagedPlatformStore(const char* name) const; 140 bool PrefValueInManagedPlatformStore(const char* name) const;
126 bool PrefValueInDeviceManagementStore(const char* name) const; 141 bool PrefValueInDeviceManagementStore(const char* name) const;
127 bool PrefValueInExtensionStore(const char* name) const; 142 bool PrefValueInExtensionStore(const char* name) const;
128 bool PrefValueInUserStore(const char* name) const; 143 bool PrefValueInUserStore(const char* name) const;
129 144
130 // Returns true if a preference has an explicit value in any of the
131 // stores in the range specified by |first_checked_store| and
132 // |last_checked_store|, even if that value is currently being
133 // overridden by a higher-priority store.
134 bool PrefValueInStoreRange(const char* name,
135 PrefNotifier::PrefStoreType first_checked_store,
136 PrefNotifier::PrefStoreType last_checked_store);
137
138 // These methods return true if a preference with the given name is actually 145 // These methods return true if a preference with the given name is actually
139 // being controlled by the indicated pref store and not being overridden by 146 // being controlled by the indicated pref store and not being overridden by
140 // a higher-priority source. 147 // a higher-priority source.
141 bool PrefValueFromExtensionStore(const char* name) const; 148 bool PrefValueFromExtensionStore(const char* name) const;
142 bool PrefValueFromUserStore(const char* name) const; 149 bool PrefValueFromUserStore(const char* name) const;
143 bool PrefValueFromDefaultStore(const char* name) const; 150 bool PrefValueFromDefaultStore(const char* name) const;
144 151
145 // Check whether a Preference value is modifiable by the user, i.e. whether 152 // Check whether a Preference value is modifiable by the user, i.e. whether
146 // there is no higher-priority source controlling it. 153 // there is no higher-priority source controlling it.
147 bool PrefValueUserModifiable(const char* name) const; 154 bool PrefValueUserModifiable(const char* name) const;
battre (please use the other) 2010/12/02 11:51:34 Can we make this const?
Mattias Nissler (ping if slow) 2010/12/02 16:38:24 Done.
148 155
149 // Returns the pref store type identifying the source that controls the
150 // Preference identified by |name|. If none of the sources has a value,
151 // PrefNotifier::INVALID_STORE is returned. In practice, the default PrefStore
152 // should always have a value for any registered preferencem, so INVALID_STORE
153 // indicates an error.
154 PrefNotifier::PrefStoreType ControllingPrefStoreForPref(
155 const char* name) const;
156
157 // Signature of callback triggered after policy refresh. Parameter is not
158 // passed as reference to prevent passing along a pointer to a set whose
159 // lifecycle is managed in another thread.
160 typedef Callback1<std::vector<std::string> >::Type AfterRefreshCallback;
161
162 // Called as a result of a notification of policy change. Triggers a reload of
163 // managed platform, device management and recommended preferences from policy
164 // from a Task on the FILE thread. The Task will take ownership of the
165 // |callback|. |callback| is called with the set of preferences changed by the
166 // policy refresh. |callback| is called on the caller's thread as a Task
167 // after RefreshPolicyPrefs has returned.
168 void RefreshPolicyPrefs(AfterRefreshCallback* callback);
169
170 // Returns true if there are proxy preferences in user-modifiable 156 // Returns true if there are proxy preferences in user-modifiable
171 // preference stores (e.g. CommandLinePrefStore, ExtensionPrefStore) 157 // preference stores (e.g. CommandLinePrefStore, ExtensionPrefStore)
172 // that conflict with proxy settings specified by proxy policy. 158 // that conflict with proxy settings specified by proxy policy.
173 bool HasPolicyConflictingUserProxySettings(); 159 bool HasPolicyConflictingUserProxySettings();
battre (please use the other) 2010/12/02 11:51:34 Can we make this const?
Mattias Nissler (ping if slow) 2010/12/02 16:38:24 Done.
174 160
175 protected: 161 protected:
176 // In decreasing order of precedence: 162 // PrefStores must be listed here in order from highest to lowest priority.
danno 2010/12/02 10:31:52 Can these be private?
Mattias Nissler (ping if slow) 2010/12/02 16:38:24 Done.
177 // |managed_platform_prefs| contains all managed platform (non-cloud policy) 163 // MANAGED_PLATFORM contains all managed preference values that are
178 // preference values. 164 // provided by a platform-specific policy mechanism (e.g. Windows
179 // |device_management_prefs| contains all device management (cloud policy) 165 // Group Policy).
180 // preference values. 166 // DEVICE_MANAGEMENT contains all managed preference values supplied
181 // |extension_prefs| contains preference values set by extensions. 167 // by the device management server (cloud policy).
182 // |command_line_prefs| contains preference values set by command-line 168 // EXTENSION contains preference values set by extensions.
183 // switches. 169 // COMMAND_LINE contains preference values set by command-line switches.
184 // |user_prefs| contains all user-set preference values. 170 // USER contains all user-set preference values.
185 // |recommended_prefs| contains all recommended (policy) preference values. 171 // RECOMMENDED contains all recommended (policy) preference values.
186 // |default_prefs| contains application-default preference values. It must 172 // DEFAULT contains all application default preference values.
187 // be non-null if any preferences are to be registered. 173 enum PrefStoreType {
188 // 174 // INVALID_STORE is not associated with an actual PrefStore but used as
189 // The |profile| parameter is used to construct a replacement device 175 // an invalid marker, e.g. as a return value.
190 // management pref store. This is done after policy refresh when we swap out 176 INVALID_STORE = -1,
191 // the policy pref stores for new ones, so the |profile| pointer needs to be 177 MANAGED_PLATFORM_STORE = 0,
192 // kept around for then. It is safe to pass a NULL pointer for local state 178 DEVICE_MANAGEMENT_STORE,
193 // preferences. 179 EXTENSION_STORE,
194 // 180 COMMAND_LINE_STORE,
195 // TODO(mnissler, danno): Refactor the pref store interface and refresh logic 181 USER_STORE,
196 // so refreshes can be handled by the pref store itself without swapping 182 RECOMMENDED_STORE,
197 // stores. This way we can get rid of the profile pointer here. 183 DEFAULT_STORE,
198 // 184 PREF_STORE_TYPE_MAX = DEFAULT_STORE
199 // This constructor should only be used internally, or by subclasses in 185 };
200 // testing. The usual way to create a PrefValueStore is by creating a
201 // PrefService.
202 PrefValueStore(PrefStore* managed_platform_prefs,
203 PrefStore* device_management_prefs,
204 PrefStore* extension_prefs,
205 PrefStore* command_line_prefs,
206 PrefStore* user_prefs,
207 PrefStore* recommended_prefs,
208 PrefStore* default_prefs,
209 Profile* profile);
210 186
211 private: 187 private:
188 // Keeps a PrefStore reference on behalf of the PrefValueStore and monitors
189 // the PrefStore for changes, forwarding notifications to PrefValueStore. This
190 // indirection is here for the sake of disambiguating notifications from the
191 // individual PrefStores.
192 class PrefStoreKeeper : public PrefStore::ObserverInterface {
193 public:
194 PrefStoreKeeper();
195 virtual ~PrefStoreKeeper();
196
197 // Takes ownership of |pref_store|.
198 void Initialize(PrefValueStore* store,
199 PrefStore* pref_store,
200 PrefStoreType type);
201
202 PrefStore* store() { return pref_store_.get(); }
203 const PrefStore* store() const { return pref_store_.get(); }
204
205 private:
206 // PrefStore::ObserverInterface implementation.
207 virtual void OnPrefValueChanged(const std::string& key);
208 virtual void OnInitializationCompleted();
209
210 // PrefValueStore this keeper is part of.
211 PrefValueStore* pref_value_store_;
212
213 // The PrefStore managed by this keeper.
214 scoped_ptr<PrefStore> pref_store_;
215
216 // Type of the pref store.
217 PrefStoreType type_;
218
219 DISALLOW_COPY_AND_ASSIGN(PrefStoreKeeper);
220 };
221
212 typedef std::map<std::string, Value::ValueType> PrefTypeMap; 222 typedef std::map<std::string, Value::ValueType> PrefTypeMap;
213 223
214 friend class PrefValueStoreTest; 224 friend class PrefValueStoreTest;
225 FRIEND_TEST_ALL_PREFIXES(PrefValueStoreTest, TestPolicyRefresh);
215 FRIEND_TEST_ALL_PREFIXES(PrefValueStoreTest, 226 FRIEND_TEST_ALL_PREFIXES(PrefValueStoreTest,
216 TestRefreshPolicyPrefsCompletion); 227 TestRefreshPolicyPrefsCompletion);
228 FRIEND_TEST_ALL_PREFIXES(PrefValueStoreTest,
229 TestConcurrentPolicyRefresh);
230
231 // Returns true if the actual value is a valid type for the expected type when
battre (please use the other) 2010/12/02 11:51:34 actual value? This description is not quite clear
Mattias Nissler (ping if slow) 2010/12/02 16:38:24 Changed to "actual type".
232 // found in the given store.
233 static bool IsValidType(Value::ValueType expected,
234 Value::ValueType actual,
235 PrefStoreType store);
217 236
218 // Returns true if the preference with the given name has a value in the 237 // Returns true if the preference with the given name has a value in the
219 // given PrefStoreType, of the same value type as the preference was 238 // given PrefStoreType, of the same value type as the preference was
220 // registered with. 239 // registered with.
221 bool PrefValueInStore(const char* name, 240 bool PrefValueInStore(const char* name, PrefStoreType store) const;
222 PrefNotifier::PrefStoreType store) const; 241
242 // Returns true if a preference has an explicit value in any of the
243 // stores in the range specified by |first_checked_store| and
244 // |last_checked_store|, even if that value is currently being
245 // overridden by a higher-priority store.
246 bool PrefValueInStoreRange(const char* name,
247 PrefStoreType first_checked_store,
248 PrefStoreType last_checked_store);
battre (please use the other) 2010/12/02 11:51:34 can we make this const?
Mattias Nissler (ping if slow) 2010/12/02 16:38:24 Done.
249
250 // Returns the pref store type identifying the source that controls the
251 // Preference identified by |name|. If none of the sources has a value,
252 // INVALID_STORE is returned. In practice, the default PrefStore
253 // should always have a value for any registered preferencem, so INVALID_STORE
254 // indicates an error.
255 PrefStoreType ControllingPrefStoreForPref(const char* name) const;
223 256
224 // Get a value from the specified store type. 257 // Get a value from the specified store type.
225 bool GetValueFromStore(const char* name, 258 bool GetValueFromStore(const char* name,
226 PrefNotifier::PrefStoreType store, 259 PrefStoreType store,
227 Value** out_value) const; 260 Value** out_value) const;
228 261
262 // Called upon changes in individual pref stores in order to determine whether
263 // the user-visible pref value has changed. Triggers the change notification
264 // if the effective value of the preference has changed, or if the store
265 // controlling the pref has changed.
266 void NotifyPrefChanged(const char* path, PrefStoreType new_store);
danno 2010/12/02 10:31:52 OnPrefValueChanged?
battre (please use the other) 2010/12/02 11:51:34 can we make this const?
Mattias Nissler (ping if slow) 2010/12/02 16:38:24 Sending a notification has side effects. So making
Mattias Nissler (ping if slow) 2010/12/02 16:38:24 As discussed, we want to keep this since it hosts
267
268 // Called as a result of a notification of policy change. Triggers a reload of
269 // managed platform, device management and recommended preferences from policy
270 // from a Task on the FILE thread.
271 void RefreshPolicyPrefs();
272
229 // Called during policy refresh after ReadPrefs completes on the thread 273 // Called during policy refresh after ReadPrefs completes on the thread
230 // that initiated the policy refresh. RefreshPolicyPrefsCompletion takes 274 // that initiated the policy refresh. RefreshPolicyPrefsCompletion takes
231 // ownership of the |callback| object. 275 // ownership of the |callback| object.
232 void RefreshPolicyPrefsCompletion( 276 void RefreshPolicyPrefsCompletion(
233 PrefStore* new_managed_platform_pref_store, 277 PrefStore* new_managed_platform_pref_store,
234 PrefStore* new_device_management_pref_store, 278 PrefStore* new_device_management_pref_store,
235 PrefStore* new_recommended_pref_store, 279 PrefStore* new_recommended_pref_store);
236 AfterRefreshCallback* callback);
237 280
238 // Called during policy refresh to do the ReadPrefs on the FILE thread. 281 // Called during policy refresh to do the ReadPrefs on the FILE thread.
239 // RefreshPolicyPrefsOnFileThread takes ownership of the |callback| object. 282 // RefreshPolicyPrefsOnFileThread takes ownership of the |callback| object.
240 void RefreshPolicyPrefsOnFileThread( 283 void RefreshPolicyPrefsOnFileThread(
241 BrowserThread::ID calling_thread_id, 284 BrowserThread::ID calling_thread_id,
242 PrefStore* new_managed_platform_pref_store, 285 PrefStore* new_managed_platform_pref_store,
243 PrefStore* new_device_management_pref_store, 286 PrefStore* new_device_management_pref_store,
244 PrefStore* new_recommended_pref_store, 287 PrefStore* new_recommended_pref_store);
245 AfterRefreshCallback* callback);
246 288
247 scoped_ptr<PrefStore> pref_stores_[PrefNotifier::PREF_STORE_TYPE_MAX + 1]; 289 // NotificationObserver methods:
290 virtual void Observe(NotificationType type,
291 const NotificationSource& source,
292 const NotificationDetails& details);
293
294 // Called from the PrefStoreKeeper implementation when a pref value for |key|
295 // changed in the pref store for |type|.
296 void PrefValueChangedInStore(const std::string& key, PrefStoreType type);
danno 2010/12/02 10:31:52 Is this not the same as NotifyPrefChanged?
Mattias Nissler (ping if slow) 2010/12/02 16:38:24 No, it's the handler for OnPrefValueChanged notifi
297
298 // Handle the event that the store for |type| has completed initialization.
299 void InitializationCompleteForStore(PrefStoreType type);
danno 2010/12/02 10:31:52 OnInitializedCompleted?
Mattias Nissler (ping if slow) 2010/12/02 16:38:24 Done.
300
301 // Initializes a pref store keeper. Sets up a PrefStoreKeeper that will take
302 // ownership of the passed |pref_store|.
303 void InitPrefStore(PrefStoreType type, PrefStore* pref_store);
304
305 // Checks whether initialization is completed and tells the notifier if that
306 // is the case.
307 void CheckInitializationCompleted();
308
309 // Get the PrefStore pointer for the given type. May return NULL if there is
310 // no PrefStore for that type.
311 PrefStore* GetPrefStore(PrefStoreType type);
danno 2010/12/02 10:31:52 inline?
Mattias Nissler (ping if slow) 2010/12/02 16:38:24 Done.
312 const PrefStore* GetPrefStore(PrefStoreType type) const;
danno 2010/12/02 10:31:52 inline?
Mattias Nissler (ping if slow) 2010/12/02 16:38:24 Done.
313
314 // Keeps the PrefStore references in order of precedence.
315 PrefStoreKeeper pref_stores_[PREF_STORE_TYPE_MAX + 1];
316
317 // Used for generation PREF_CHANGED notifications. This is a weak reference,
battre (please use the other) 2010/12/02 11:51:34 nit: "for generating" or "for generation of"
Mattias Nissler (ping if slow) 2010/12/02 16:38:24 Done.
318 // since the notifier is owned by the corresponding PrefService.
danno 2010/12/02 10:31:52 Add initialization completed comment.
Mattias Nissler (ping if slow) 2010/12/02 16:38:24 Done.
319 PrefNotifier* pref_notifier_;
248 320
249 // A mapping of preference names to their registered types. 321 // A mapping of preference names to their registered types.
250 PrefTypeMap pref_types_; 322 PrefTypeMap pref_types_;
251 323
252 // The associated profile, in case this value store is associated with a 324 // The associated profile, in case this value store is associated with a
253 // profile pref service. Used for recreating the device management pref store 325 // profile pref service. Used for recreating the device management pref store
254 // upon policy refresh. 326 // upon policy refresh.
255 Profile* profile_; 327 Profile* profile_;
256 328
329 // TODO(mnissler): Remove this after cleaning up policy refresh handling.
330 NotificationRegistrar registrar_;
331
257 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); 332 DISALLOW_COPY_AND_ASSIGN(PrefValueStore);
258 }; 333 };
259 334
260 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ 335 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698