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 // This is the base interface for a preference services that provides | 5 // This is the base interface for a preference services that provides |
6 // a way to access the application's current preferences. | 6 // a way to access the application's current preferences. |
7 // | 7 // |
8 // This base interface assumes all preferences are local. See | 8 // This base interface assumes all preferences are local. See |
9 // SyncablePrefServiceBase for the interface to a preference service | 9 // SyncablePrefServiceBase for the interface to a preference service |
10 // that stores preferences that can be synced. | 10 // that stores preferences that can be synced. |
11 // | 11 // |
12 // Chromium settings and storage represent user-selected preferences and | 12 // Chromium settings and storage represent user-selected preferences and |
13 // information and MUST not be extracted, overwritten or modified except | 13 // information and MUST not be extracted, overwritten or modified except |
14 // through Chromium defined APIs. | 14 // through Chromium defined APIs. |
15 | 15 |
16 #ifndef BASE_PREFS_PUBLIC_PREF_SERVICE_BASE_H_ | 16 #ifndef BASE_PREFS_PUBLIC_PREF_SERVICE_BASE_H_ |
17 #define BASE_PREFS_PUBLIC_PREF_SERVICE_BASE_H_ | 17 #define BASE_PREFS_PUBLIC_PREF_SERVICE_BASE_H_ |
18 | 18 |
| 19 #include "base/callback_forward.h" |
19 #include "base/values.h" | 20 #include "base/values.h" |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 class BrowserContext; | 23 class BrowserContext; |
23 } | 24 } |
24 | 25 |
25 namespace subtle { | 26 namespace subtle { |
26 class PrefMemberBase; | 27 class PrefMemberBase; |
27 } | 28 } |
28 | 29 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 // access to the otherwise protected members Add/RemovePrefObserver. | 253 // access to the otherwise protected members Add/RemovePrefObserver. |
253 // PrefMember registers for preferences changes notification directly to | 254 // PrefMember registers for preferences changes notification directly to |
254 // avoid the storage overhead of the registrar, so its base class must be | 255 // avoid the storage overhead of the registrar, so its base class must be |
255 // declared as a friend, too. | 256 // declared as a friend, too. |
256 friend class PrefChangeRegistrar; | 257 friend class PrefChangeRegistrar; |
257 friend class subtle::PrefMemberBase; | 258 friend class subtle::PrefMemberBase; |
258 | 259 |
259 // These are protected so they can only be accessed by the friend | 260 // These are protected so they can only be accessed by the friend |
260 // classes listed above. | 261 // classes listed above. |
261 // | 262 // |
262 // If the pref at the given path changes, we call the observer's | 263 // If the pref at the given path changes, we run the closure. Note |
263 // OnPreferenceChanged method. Note that observers should not call | 264 // that observers should not call these methods directly but rather |
264 // these methods directly but rather use a PrefChangeRegistrar to | 265 // use a PrefChangeRegistrar to make sure the observer gets cleaned |
265 // make sure the observer gets cleaned up properly. | 266 // up properly. |
266 virtual void AddPrefObserver(const char* path, PrefObserver* obs) = 0; | 267 virtual void AddPrefObserver(const char* path, const base::Closure& obs) = 0; |
267 virtual void RemovePrefObserver(const char* path, PrefObserver* obs) = 0; | 268 virtual void RemovePrefObserver(const char* path, |
| 269 const base::Closure& obs) = 0; |
268 }; | 270 }; |
269 | 271 |
270 #endif // BASE_PREFS_PUBLIC_PREF_SERVICE_BASE_H_ | 272 #endif // BASE_PREFS_PUBLIC_PREF_SERVICE_BASE_H_ |
OLD | NEW |