diff options
Diffstat (limited to 'chrome/browser/pref_service.h')
-rw-r--r-- | chrome/browser/pref_service.h | 55 |
1 files changed, 11 insertions, 44 deletions
diff --git a/chrome/browser/pref_service.h b/chrome/browser/pref_service.h index 48c8438..5b18d9d 100644 --- a/chrome/browser/pref_service.h +++ b/chrome/browser/pref_service.h @@ -3,14 +3,6 @@ // found in the LICENSE file. // This provides a way to access the application's current preferences. -// This service has two preference stores, one for "persistent" preferences, -// which get serialized for use in the next session, and one for "transient" -// preferences, which are in effect for only the current session -// (this usually encodes things like command-line switches). -// -// Calling the getter functions in this class basically looks at both the -// persistent and transient stores, where any corresponding value in the -// transient store overrides the one in the persistent store. #ifndef CHROME_BROWSER_PREF_SERVICE_H_ #define CHROME_BROWSER_PREF_SERVICE_H_ @@ -23,14 +15,13 @@ #include "base/observer_list.h" #include "base/scoped_ptr.h" #include "base/values.h" -#include "chrome/browser/important_file_writer.h" +#include "chrome/browser/pref_store.h" class NotificationObserver; class Preference; class ScopedPrefUpdate; -class PrefService : public NonThreadSafe, - public ImportantFileWriter::DataSerializer { +class PrefService : public NonThreadSafe { public: // A helper class to store all the information associated with a preference. @@ -73,9 +64,8 @@ class PrefService : public NonThreadSafe, DISALLOW_COPY_AND_ASSIGN(Preference); }; - // |pref_filename| is the path to the prefs file we will try to load or save - // to. Saves will be executed on the file thread. - explicit PrefService(const FilePath& pref_filename); + // The |PrefStore| manages reading and writing the preferences. + explicit PrefService(PrefStore* store); ~PrefService(); // Reloads the data from file. This should only be called when the importer @@ -183,27 +173,9 @@ class PrefService : public NonThreadSafe, // preference is not registered. const Preference* FindPreference(const wchar_t* pref_name) const; - // ImportantFileWriter::DataSerializer - virtual bool SerializeData(std::string* output); - - bool read_only() const { return read_only_; } + bool read_only() const { return store_->ReadOnly(); } private: - // Unique integer code for each type of error so we can report them - // distinctly in a histogram. - // NOTE: Don't change the order here as it will change the server's meaning - // of the histogram. - enum PrefReadError { - PREF_READ_ERROR_NONE = 0, - PREF_READ_ERROR_JSON_PARSE, - PREF_READ_ERROR_JSON_TYPE, - PREF_READ_ERROR_ACCESS_DENIED, - PREF_READ_ERROR_FILE_OTHER, - PREF_READ_ERROR_FILE_LOCKED, - PREF_READ_ERROR_NO_FILE, - PREF_READ_ERROR_JSON_REPEAT, - }; - // Add a preference to the PreferenceMap. If the pref already exists, return // false. This method takes ownership of |pref|. void RegisterPreference(Preference* pref); @@ -221,16 +193,16 @@ class PrefService : public NonThreadSafe, const Value* old_value); // Load from disk. Returns a non-zero error code on failure. - PrefReadError LoadPersistentPrefs(); + PrefStore::PrefReadError LoadPersistentPrefs(); - // Load preferences from disk, attempting to diagnose and handle errors. + // Load preferences from storage, attempting to diagnose and handle errors. // This should only be called from the constructor. - void InitFromDisk(); + void InitFromStorage(); - scoped_ptr<DictionaryValue> persistent_; + scoped_ptr<PrefStore> store_; - // Helper for safe writing pref data. - ImportantFileWriter writer_; + // The user-defined preference values. Owned by the |PrefStore|. + DictionaryValue* persistent_; // A set of all the registered Preference objects. PreferenceSet prefs_; @@ -244,11 +216,6 @@ class PrefService : public NonThreadSafe, friend class ScopedPrefUpdate; - // Whether the service is in a pseudo-read-only mode where changes are not - // actually persisted to disk. This happens in some cases when there are - // read errors during startup. - bool read_only_; - DISALLOW_COPY_AND_ASSIGN(PrefService); }; |