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

Unified Diff: chrome/browser/pref_service.h

Issue 1120006: detect preferences errors (Closed)
Patch Set: changes from review Created 10 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/page_state.cc ('k') | chrome/browser/pref_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/pref_service.h
diff --git a/chrome/browser/pref_service.h b/chrome/browser/pref_service.h
index 85dd42ca8f7858ef2e18d44814ea8e9bc49b56bb..7a79286ee994fdacd919490116a611203cceb447 100644
--- a/chrome/browser/pref_service.h
+++ b/chrome/browser/pref_service.h
@@ -184,7 +184,23 @@ class PrefService : public NonThreadSafe,
// ImportantFileWriter::DataSerializer
virtual bool SerializeData(std::string* output);
+ bool read_only() const { return read_only_; }
+
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,
+ };
+
// Add a preference to the PreferenceMap. If the pref already exists, return
// false. This method takes ownership of |pref|.
void RegisterPreference(Preference* pref);
@@ -201,6 +217,13 @@ class PrefService : public NonThreadSafe,
void FireObserversIfChanged(const wchar_t* pref_name,
const Value* old_value);
+ // Load from disk. Returns a non-zero error code on failure.
+ PrefReadError LoadPersistentPrefs();
+
+ // Load preferences from disk, attempting to diagnose and handle errors.
+ // This should only be called from the constructor.
+ void InitFromDisk();
+
scoped_ptr<DictionaryValue> persistent_;
// Helper for safe writing pref data.
@@ -216,6 +239,11 @@ class PrefService : public NonThreadSafe,
PrefObserverMap;
PrefObserverMap pref_observers_;
+ // 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);
};
« no previous file with comments | « chrome/browser/page_state.cc ('k') | chrome/browser/pref_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698