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

Unified Diff: chrome/browser/prefs/pref_metrics_service.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 | « no previous file | chrome/browser/prefs/pref_metrics_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prefs/pref_metrics_service.h
diff --git a/chrome/browser/prefs/pref_metrics_service.h b/chrome/browser/prefs/pref_metrics_service.h
index 647cd9497653d1e5cb10be47452ccf45fccd051f..fc48935c9f9f484917598ebee4b4ac1c33f691d6 100644
--- a/chrome/browser/prefs/pref_metrics_service.h
+++ b/chrome/browser/prefs/pref_metrics_service.h
@@ -5,7 +5,12 @@
#ifndef CHROME_BROWSER_PREFS_PREF_METRICS_SERVICE_H_
#define CHROME_BROWSER_PREFS_PREF_METRICS_SERVICE_H_
+#include <map>
+#include <string>
+
+#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
+#include "chrome/browser/prefs/synced_pref_change_registrar.h"
#include "chrome/browser/profiles/profile.h"
#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h"
@@ -34,11 +39,51 @@ class PrefMetricsService : public BrowserContextKeyedService {
virtual content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const OVERRIDE;
};
+
private:
+ // Use a map to convert domains to their histogram identifiers. Ids are
+ // defined in tools/metrics/histograms/histograms.xml and (usually) also in
+ // chrome/browser/search_engines/prepopulated_engines.json.
+ typedef std::map<std::string, int> DomainIdMap;
+
+ // Function to log a Value to a histogram
+ typedef base::Callback<void(const std::string&, const Value*)>
+ LogHistogramValueCallback;
+
// Record prefs state on browser context creation.
void RecordLaunchPrefs();
+ // Register callbacks for synced pref changes.
+ void RegisterSyncedPrefObservers();
+
+ // Registers a histogram logging callback for a synced pref change.
+ void AddPrefObserver(const std::string& path,
+ const std::string& histogram_name_prefix,
+ const LogHistogramValueCallback& callback);
+
+ // Generic callback to observe a synced pref change.
+ void OnPrefChanged(const std::string& histogram_name_prefix,
+ const LogHistogramValueCallback& callback,
+ const std::string& path,
+ bool from_sync);
+
+ // Callback for a boolean pref change histogram.
+ void LogBooleanPrefChange(const std::string& histogram_name,
+ const Value* value);
+
+ // Callback for an integer pref change histogram.
+ void LogIntegerPrefChange(int boundary_value,
+ const std::string& histogram_name,
+ const Value* value);
+
+ // Callback for a list pref change. Each item in the list
+ // is logged using the given histogram callback.
+ void LogListPrefChange(const LogHistogramValueCallback& item_callback,
+ const std::string& histogram_name,
+ const Value* value);
+
Profile* profile_;
+ scoped_ptr<SyncedPrefChangeRegistrar> synced_pref_change_registrar_;
};
#endif // CHROME_BROWSER_PREFS_PREF_METRICS_SERVICE_H_
« no previous file with comments | « no previous file | chrome/browser/prefs/pref_metrics_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698