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

Unified Diff: chrome/browser/prefs/pref_model_associator.h

Issue 21580002: Add histograms to track synced pref changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix dynamic histograms and test cleanup Created 7 years, 4 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/prefs/pref_metrics_service.cc ('k') | chrome/browser/prefs/pref_model_associator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..539d38a301c9b71d15547053c8c8093cd5268cd0 100644
--- a/chrome/browser/prefs/pref_model_associator.h
+++ b/chrome/browser/prefs/pref_model_associator.h
@@ -11,7 +11,10 @@
#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 +100,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 +168,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) const;
+
+ SyncedPrefObserverMap synced_pref_observers_;
+
DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator);
};
« no previous file with comments | « chrome/browser/prefs/pref_metrics_service.cc ('k') | chrome/browser/prefs/pref_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698