Chromium Code Reviews| Index: chrome/browser/prefs/pref_model_associator.h |
| diff --git a/chrome/browser/prefs/pref_model_associator.h b/chrome/browser/prefs/pref_model_associator.h |
| index 584e27172252a7b7853654bc33d9fe3f1e6f9e28..4423b31ab9dbbf1c8fb152e0ab5acbaef26ebc59 100644 |
| --- a/chrome/browser/prefs/pref_model_associator.h |
| +++ b/chrome/browser/prefs/pref_model_associator.h |
| @@ -5,13 +5,17 @@ |
| #ifndef CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ |
| #define CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ |
| +#include <list> |
|
battre
2013/08/06 15:54:39
nit: not used.
Ken Rockot(use gerrit already)
2013/08/06 20:18:32
Done.
|
| #include <map> |
| #include <set> |
| #include <string> |
| #include "base/basictypes.h" |
| #include "base/compiler_specific.h" |
| +#include "base/containers/hash_tables.h" |
| +#include "base/observer_list.h" |
| #include "base/threading/non_thread_safe.h" |
| +#include "chrome/browser/prefs/synced_pref_observer.h" |
| #include "sync/api/sync_data.h" |
| #include "sync/api/syncable_service.h" |
| @@ -97,6 +101,14 @@ class PrefModelAssociator |
| // Note this does not refer to SYNCABLE_PREF. |
| bool IsPrefSynced(const std::string& name) const; |
| + // Adds a SyncedPrefObserver to watch for changes to a specific pref. |
| + void AddSyncedPrefObserver(const std::string& name, |
| + SyncedPrefObserver* observer); |
| + |
| + // Removes a SyncedPrefObserver from a pref's list of observers. |
| + void RemoveSyncedPrefObserver(const std::string& name, |
| + SyncedPrefObserver* observer); |
| + |
| protected: |
| friend class ProfileSyncServicePreferenceTest; |
| @@ -157,6 +169,18 @@ class PrefModelAssociator |
| // PRIORITY_PREFERENCES. |
| syncer::ModelType type_; |
| + private: |
| + // Map prefs to lists of observers. Observers will receive notification when |
| + // a pref changes, including the detail of whether or not the change came |
| + // from sync. |
| + typedef ObserverList<SyncedPrefObserver> SyncedPrefObserverList; |
| + typedef base::hash_map<std::string, SyncedPrefObserverList*> |
| + SyncedPrefObserverMap; |
| + |
| + void NotifySyncedPrefObservers(const std::string& path, bool from_sync); |
|
battre
2013/08/06 15:54:39
can you make this function const?
Ken Rockot(use gerrit already)
2013/08/06 20:18:32
Done.
|
| + |
| + SyncedPrefObserverMap synced_pref_observers_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator); |
| }; |