Chromium Code Reviews| 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..dc05f3002fd8c1e593e387b8860f1ff22eedfec4 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,66 @@ 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*)> |
| + ValueHistogramCallback; |
| + |
| // 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_base, |
| + const ValueHistogramCallback& callback); |
| + |
| + // Builds a map that associates domain name strings with histogram enum |
| + // values, for prepopulated DSEs and select non-prepopulated ones. |
| + void BuildDomainIdMap(); |
| + |
| + // Add a domain/id pair to the map. |
| + void AddToDomainIdMap(const std::string& domain, int domain_id); |
| + |
| + // Generic callback to observe a synced pref change. |
| + void OnPrefChanged(const std::string& histogram_base, |
| + const ValueHistogramCallback& callback, |
| + const std::string& path, |
| + bool from_sync); |
| + |
| + // Callback to for a boolean pref change histogram. |
|
bbudge
2013/08/01 17:48:08
s/to for/for?
Ken Rockot(use gerrit already)
2013/08/01 17:55:15
Done.
|
| + void LogBooleanPrefChange(const std::string& histogram_name, |
| + const Value* value); |
| + |
| + // Callback to for an integer pref change histogram. |
| + void LogIntegerPrefChange(int boundary_value, |
|
bbudge
2013/08/01 17:48:08
ditto
Ken Rockot(use gerrit already)
2013/08/01 17:55:15
Done.
Ken Rockot(use gerrit already)
2013/08/01 17:55:15
Done.
|
| + const std::string& histogram_name, |
| + const Value* value); |
| + |
| + // Callback to for a URL pref change histogram. |
| + void LogUrlPrefChange(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 ValueHistogramCallback& item_callback, |
| + const std::string& histogram_name, |
| + const Value* value); |
| + |
| + // Maps a host name to a histogram enum value. The enum value '0' represents |
| + // 'Unknown', i.e. an unrecognized host. |
| + int MapHostToId(const std::string& host) const; |
| + |
| Profile* profile_; |
| + DomainIdMap domain_id_map_; |
| + scoped_ptr<SyncedPrefChangeRegistrar> synced_pref_change_registrar_; |
| }; |
| #endif // CHROME_BROWSER_PREFS_PREF_METRICS_SERVICE_H_ |