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

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

Issue 6894020: Adds async interface method to PersistentPrefStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: always call OnInit.. Created 9 years, 8 months 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) 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 // This provides a way to access the application's current preferences. 5 // This provides a way to access the application's current preferences.
6 6
7 #ifndef CHROME_BROWSER_PREFS_PREF_SERVICE_H_ 7 #ifndef CHROME_BROWSER_PREFS_PREF_SERVICE_H_
8 #define CHROME_BROWSER_PREFS_PREF_SERVICE_H_ 8 #define CHROME_BROWSER_PREFS_PREF_SERVICE_H_
9 #pragma once 9 #pragma once
10 10
(...skipping 23 matching lines...) Expand all
34 }; 34 };
35 35
36 class PrefService; 36 class PrefService;
37 37
38 class PrefServiceDelegate { 38 class PrefServiceDelegate {
39 public: 39 public:
40 virtual void OnPrefsLoaded(PrefService* prefs, bool success) = 0; 40 virtual void OnPrefsLoaded(PrefService* prefs, bool success) = 0;
41 }; 41 };
42 42
43 class PrefService : public base::NonThreadSafe, 43 class PrefService : public base::NonThreadSafe,
44 public JsonPrefStore::Delegate { 44 public PrefStore::Observer {
45 public: 45 public:
46 // A helper class to store all the information associated with a preference. 46 // A helper class to store all the information associated with a preference.
47 class Preference { 47 class Preference {
48 public: 48 public:
49 49
50 // The type of the preference is determined by the type with which it is 50 // The type of the preference is determined by the type with which it is
51 // registered. This type needs to be a boolean, integer, double, string, 51 // registered. This type needs to be a boolean, integer, double, string,
52 // dictionary (a branch), or list. You shouldn't need to construct this on 52 // dictionary (a branch), or list. You shouldn't need to construct this on
53 // your own; use the PrefService::Register*Pref methods instead. 53 // your own; use the PrefService::Register*Pref methods instead.
54 Preference(const PrefService* service, 54 Preference(const PrefService* service,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 std::string name_; 113 std::string name_;
114 114
115 Value::ValueType type_; 115 Value::ValueType type_;
116 116
117 // Reference to the PrefService in which this pref was created. 117 // Reference to the PrefService in which this pref was created.
118 const PrefService* pref_service_; 118 const PrefService* pref_service_;
119 119
120 DISALLOW_COPY_AND_ASSIGN(Preference); 120 DISALLOW_COPY_AND_ASSIGN(Preference);
121 }; 121 };
122 122
123 // JsonPrefStore::Delegate implementaion.
124 virtual void OnPrefsRead(PersistentPrefStore::PrefReadError error,
125 bool no_dir);
126
127 // Factory method that creates a new instance of a PrefService with the 123 // Factory method that creates a new instance of a PrefService with the
128 // applicable PrefStores. The |pref_filename| points to the user preference 124 // applicable PrefStores. The |pref_filename| points to the user preference
129 // file. The |profile| is the one to which these preferences apply; it may be 125 // file. The |profile| is the one to which these preferences apply; it may be
130 // NULL if we're dealing with the local state. This is the usual way to create 126 // NULL if we're dealing with the local state. This is the usual way to create
131 // a new PrefService. |extension_pref_store| is used as the source for 127 // a new PrefService. |extension_pref_store| is used as the source for
132 // extension-controlled preferences and may be NULL. The PrefService takes 128 // extension-controlled preferences and may be NULL. The PrefService takes
133 // ownership of |extension_pref_store|. 129 // ownership of |extension_pref_store|.
134 static PrefService* CreatePrefService(const FilePath& pref_filename, 130 static PrefService* CreatePrefService(const FilePath& pref_filename,
135 PrefStore* extension_pref_store, 131 PrefStore* extension_pref_store,
136 Profile* profile); 132 Profile* profile);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 PrefService(PrefStore* managed_platform_prefs, 252 PrefService(PrefStore* managed_platform_prefs,
257 PrefStore* managed_cloud_prefs, 253 PrefStore* managed_cloud_prefs,
258 PrefStore* extension_prefs, 254 PrefStore* extension_prefs,
259 PrefStore* command_line_prefs, 255 PrefStore* command_line_prefs,
260 PersistentPrefStore* user_prefs, 256 PersistentPrefStore* user_prefs,
261 PrefStore* recommended_platform_prefs, 257 PrefStore* recommended_platform_prefs,
262 PrefStore* recommended_cloud_prefs, 258 PrefStore* recommended_cloud_prefs,
263 DefaultPrefStore* default_store, 259 DefaultPrefStore* default_store,
264 PrefServiceDelegate* delegate); 260 PrefServiceDelegate* delegate);
265 261
262 // PrefStore::Observer implementation:
263 virtual void OnPrefValueChanged(const std::string&) {}
264 virtual void OnInitializationCompleted();
265
266 // The PrefNotifier handles registering and notifying preference observers. 266 // The PrefNotifier handles registering and notifying preference observers.
267 // It is created and owned by this PrefService. Subclasses may access it for 267 // It is created and owned by this PrefService. Subclasses may access it for
268 // unit testing. 268 // unit testing.
269 scoped_ptr<PrefNotifierImpl> pref_notifier_; 269 scoped_ptr<PrefNotifierImpl> pref_notifier_;
270 270
271 private: 271 private:
272 class PreferencePathComparator { 272 class PreferencePathComparator {
273 public: 273 public:
274 bool operator() (Preference* lhs, Preference* rhs) const { 274 bool operator() (Preference* lhs, Preference* rhs) const {
275 return lhs->name() < rhs->name(); 275 return lhs->name() < rhs->name();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 mutable PreferenceSet prefs_; 344 mutable PreferenceSet prefs_;
345 345
346 // Holds delegator to be called after initialization, if async version 346 // Holds delegator to be called after initialization, if async version
347 // is used. 347 // is used.
348 PrefServiceDelegate* delegate_; 348 PrefServiceDelegate* delegate_;
349 349
350 DISALLOW_COPY_AND_ASSIGN(PrefService); 350 DISALLOW_COPY_AND_ASSIGN(PrefService);
351 }; 351 };
352 352
353 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_H_ 353 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698