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

Unified Diff: chrome/common/pref_store.h

Issue 5441002: Clean up pref change notification handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix extension prefs breakage 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/notification_type.h ('k') | chrome/common/pref_store_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/pref_store.h
diff --git a/chrome/common/pref_store.h b/chrome/common/pref_store.h
index 7011eba30dcd51ce8dab7657bb036a53b56175c0..808ffbd20d986e369b63148ee03c21bd1f5af304 100644
--- a/chrome/common/pref_store.h
+++ b/chrome/common/pref_store.h
@@ -6,15 +6,33 @@
#define CHROME_COMMON_PREF_STORE_H_
#pragma once
+#include <string>
+
+#include "base/basictypes.h"
+
class DictionaryValue;
class Value;
// This is an abstract interface for reading and writing from/to a persistent
-// preference store, used by |PrefService|. An implementation using a JSON file
-// can be found in |JsonPrefStore|, while an implementation without any backing
-// store (currently used for testing) can be found in |DummyPrefStore|.
+// preference store, used by PrefService. An implementation using a JSON file
+// can be found in JsonPrefStore, while an implementation without any backing
+// store for testing can be found in TestingPrefStore. Furthermore, there is
+// CommandLinePrefStore, which bridges command line options to preferences and
+// ConfigurationPolicyPrefStore, which is used for hooking up configuration
+// policy with the preference subsystem.
class PrefStore {
public:
+ // Observer interface for monitoring PrefStore.
+ class ObserverInterface {
+ public:
+ virtual ~ObserverInterface() {}
+
+ // Called when the value for the given |key| in the store changes.
+ virtual void OnPrefValueChanged(const std::string& key) = 0;
+ // Notification about the PrefStore being fully initialized.
+ virtual void OnInitializationCompleted() = 0;
+ };
+
// 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
@@ -44,12 +62,20 @@ class PrefStore {
// CreateUseDefaultSentinelValue.
static bool IsUseDefaultSentinelValue(Value* value);
- virtual ~PrefStore() { }
+ PrefStore() {}
+ virtual ~PrefStore() {}
+
+ // Add and remove observers.
+ virtual void AddObserver(ObserverInterface* observer) {}
+ virtual void RemoveObserver(ObserverInterface* observer) {}
+
+ // Whether the store has completed all asynchronous initialization.
+ virtual bool IsInitializationComplete() { return true; }
// Whether the store 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.
- virtual bool ReadOnly() { return true; }
+ virtual bool ReadOnly() const { return true; }
// TODO(danno): PrefValueStore shouldn't allow direct access to the
// DictionaryValue. Instead, it should have getters that return a
@@ -62,6 +88,8 @@ class PrefStore {
virtual bool WritePrefs() { return true; }
virtual void ScheduleWritePrefs() { }
+
+ DISALLOW_COPY_AND_ASSIGN(PrefStore);
};
#endif // CHROME_COMMON_PREF_STORE_H_
« no previous file with comments | « chrome/common/notification_type.h ('k') | chrome/common/pref_store_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698