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 fc48935c9f9f484917598ebee4b4ac1c33f691d6..a9da5bdd92da3449b5dc916b3a87302318a5fcef 100644 |
| --- a/chrome/browser/prefs/pref_metrics_service.h |
| +++ b/chrome/browser/prefs/pref_metrics_service.h |
| @@ -10,11 +10,15 @@ |
| #include "base/memory/scoped_ptr.h" |
| #include "base/memory/singleton.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/prefs/pref_change_registrar.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" |
| +class PrefRegistrySimple; |
| + |
| // PrefMetricsService is responsible for recording prefs-related UMA stats. |
| class PrefMetricsService : public BrowserContextKeyedService { |
| public: |
| @@ -40,12 +44,10 @@ class PrefMetricsService : public BrowserContextKeyedService { |
| 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; |
| + // Registers preferences in local settings. |
|
Mattias Nissler (ping if slow)
2013/08/15 10:14:51
nit: s/local settings/local state/ for consistency
bbudge
2013/08/15 17:33:49
Done.
|
| + static void RegisterPrefs(PrefRegistrySimple* registry); |
| + private: |
| // Function to log a Value to a histogram |
| typedef base::Callback<void(const std::string&, const Value*)> |
| LogHistogramValueCallback; |
| @@ -82,7 +84,35 @@ class PrefMetricsService : public BrowserContextKeyedService { |
| const std::string& histogram_name, |
| const Value* value); |
| + // Callback to receive a unique device_id. This is used to make it harder to |
| + // spoof the preference value checks. |
| + void GetDeviceIdCallback(const std::string& device_id); |
| + |
| + // Checks the tracked preferences against their last known values and reports |
| + // any discrepancies. This must be called after |device_id| has been set by |
| + // GetDeviceIdCallback. |
| + void CheckTrackedPreferences(); |
| + |
| + // Updates the hash of the tracked preference in local settings. This must be |
|
Mattias Nissler (ping if slow)
2013/08/15 10:14:51
local state
bbudge
2013/08/15 17:33:49
Done.
|
| + // called after |device_id| has been set by GetDeviceIdCallback. |
| + void UpdateTrackedPreference(const char* path); |
| + |
| + // Removes the tracked preference from local settings. Returns 'true' iff. the |
|
Mattias Nissler (ping if slow)
2013/08/15 10:14:51
local state
bbudge
2013/08/15 17:33:49
Done.
|
| + // value was present. |
| + bool RemoveTrackedPreference(const char* path); |
| + |
| + // Gets the path to the preference value hash in local settings. |
|
Mattias Nissler (ping if slow)
2013/08/15 10:14:51
local state
bbudge
2013/08/15 17:33:49
Done.
|
| + std::string GetHashedPrefPath(const char* path); |
| + |
| + // Computes an MD5 hash for the given preference value. Salts the hash with |
| + // the pref name and the device id to make it harder to spoof. |
| + std::string GetHashedPrefValue(const char* path, const base::Value* value); |
| + |
| + base::WeakPtrFactory<PrefMetricsService> weak_factory_; |
| + |
| Profile* profile_; |
| + std::string device_id_; |
| + PrefChangeRegistrar pref_registrar_; |
| scoped_ptr<SyncedPrefChangeRegistrar> synced_pref_change_registrar_; |
| }; |