Revert 221966 "Revert 221944 "Add UMA to report Preferences File..."

Re-apply and disable for Chrome Frame.

> Revert 221944 "Add UMA to report Preferences File Corruption"
> 
> Breaks chrome_frame_tests on Win Aura.
> http://test-results.appspot.com/dashboards/flakiness_dashboard.html#group=%40ToT%20Chromium&testType=chrome_frame_tests&builder=Win%20Aura%20Tests%20(1)
> 
> > Add UMA to report Preferences File Corruption
> > Adds PrefMetricsService methods to track changes to user preferences
> > that happen outside of Chrome and report discrepancies via UMA.
> > 
> > BUG=266569
> > 
> > Review URL: https://chromiumcodereview.appspot.com/22676002
> 
> TBR=bbudge@chromium.org
> 
> Review URL: https://codereview.chromium.org/23597020

TBR=bbudge@chromium.org

Review URL: https://codereview.chromium.org/23788010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221972 0039d316-1c4b-4281-b951-d872f2087c98
parent 507f5b06
......@@ -378,6 +378,9 @@
<include name="IDR_NETWORK_JS" file="resources\chromeos\network.js" type="BINDATA" />
<include name="IDR_NETWORK_CSS" file="resources\chromeos\network.css" type="BINDATA" />
</if>
<if expr="pp_ifdef('_google_chrome')">
<include name="IDR_PREF_HASH_SEED_BIN" file="resources\settings_internal\pref_hash_seed.bin" type="BINDATA" />
</if>
</includes>
</release>
</grit>
......@@ -52,6 +52,7 @@
#include "chrome/browser/pepper_flash_settings_manager.h"
#include "chrome/browser/plugins/plugin_finder.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/prefs/pref_metrics_service.h"
#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/printing/cloud_print/cloud_print_url.h"
......@@ -217,6 +218,7 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
MetricsLog::RegisterPrefs(registry);
MetricsService::RegisterPrefs(registry);
metrics::CachingPermutedEntropyProvider::RegisterPrefs(registry);
PrefMetricsService::RegisterPrefs(registry);
PrefProxyConfigTrackerImpl::RegisterPrefs(registry);
ProfileInfoCache::RegisterPrefs(registry);
profiles::RegisterPrefs(registry);
......
......@@ -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,16 +44,23 @@ class PrefMetricsService : public BrowserContextKeyedService {
content::BrowserContext* context) const OVERRIDE;
};
// Registers preferences in local state.
static void RegisterPrefs(PrefRegistrySimple* registry);
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;
friend class PrefMetricsServiceTest;
// Function to log a Value to a histogram
typedef base::Callback<void(const std::string&, const Value*)>
LogHistogramValueCallback;
// For unit testing only.
PrefMetricsService(Profile* profile,
PrefService* local_settings,
const std::string& device_id,
const char** tracked_pref_paths,
int tracked_pref_path_count);
// Record prefs state on browser context creation.
void RecordLaunchPrefs();
......@@ -82,8 +93,45 @@ class PrefMetricsService : public BrowserContextKeyedService {
const std::string& histogram_name,
const Value* value);
// Callback to receive a unique device_id.
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.
void CheckTrackedPreferences();
// Updates the hash of the tracked preference in local state. This must be
// called after |device_id| has been set.
void UpdateTrackedPreference(const char* path);
// Removes the tracked preference from local state. Returns 'true' iff. the
// value was present.
bool RemoveTrackedPreference(const char* path);
// Gets the path to the preference value hash in local state.
std::string GetHashedPrefPath(const char* path);
// Computes an MD5 hash for the given preference value.
std::string GetHashedPrefValue(const char* path, const base::Value* value);
void InitializePrefObservers();
Profile* profile_;
PrefService* prefs_;
PrefService* local_state_;
std::string profile_name_;
std::string pref_hash_seed_;
std::string device_id_;
const char** tracked_pref_paths_;
const int tracked_pref_path_count_;
bool checked_tracked_prefs_;
PrefChangeRegistrar pref_registrar_;
scoped_ptr<SyncedPrefChangeRegistrar> synced_pref_change_registrar_;
base::WeakPtrFactory<PrefMetricsService> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(PrefMetricsService);
};
#endif // CHROME_BROWSER_PREFS_PREF_METRICS_SERVICE_H_
This diff is collapsed.
......@@ -1098,6 +1098,7 @@
'browser/prefs/chrome_pref_service_unittest.cc',
'browser/prefs/command_line_pref_store_unittest.cc',
'browser/prefs/incognito_mode_prefs_unittest.cc',
'browser/prefs/pref_metrics_service_unittest.cc',
'browser/prefs/pref_model_associator_unittest.cc',
'browser/prefs/proxy_config_dictionary_unittest.cc',
'browser/prefs/proxy_policy_unittest.cc',
......
......@@ -2597,4 +2597,9 @@ const char kEnableDRM[] = "settings.privacy.drm_enabled";
const char kWatchdogExtensionActive[] =
"profile.extensions.activity_log.watchdog_extension_active";
// A dictionary pref which maps profile names to dictionary values which hold
// hashes of profile prefs that we track to detect changes that happen outside
// of Chrome.
const char kProfilePreferenceHashes[] = "profile.preference_hashes";
} // namespace prefs
......@@ -949,6 +949,8 @@ extern const char kEnableDRM[];
extern const char kWatchdogExtensionActive[];
extern const char kProfilePreferenceHashes[];
} // namespace prefs
#endif // CHROME_COMMON_PREF_NAMES_H_
......@@ -14387,6 +14387,36 @@ other types of suffix sets.
</summary>
</histogram>
<histogram name="Settings.TrackedPreferenceChanged" enum="TrackedPreference">
<summary>
The id of a tracked preference whose value has been changed since the last
time Chrome set it.
</summary>
</histogram>
<histogram name="Settings.TrackedPreferenceCleared" enum="TrackedPreference">
<summary>
The id of a tracked preference whose value has been cleared since the last
time Chrome set it.
</summary>
</histogram>
<histogram name="Settings.TrackedPreferenceInitialized"
enum="TrackedPreference">
<summary>
The id of a tracked preference whose last value isn't known. We may be just
starting to track the preference, or local state may have been changed
outside of Chrome.
</summary>
</histogram>
<histogram name="Settings.TrackedPreferenceUnchanged" enum="TrackedPreference">
<summary>
The id of a tracked preference whose value has not changed since the last
time Chrome set it.
</summary>
</histogram>
<histogram name="SimpleCache.App.CheckCRCResult" enum="CheckCRCResult">
<summary>
Whether or not the CRC was checked at the moment when the last reference to
......@@ -25196,6 +25226,21 @@ other types of suffix sets.
</int>
</enum>
<enum name="TrackedPreference" type="int">
<int value="0" label="prefs::kShowHomeButton"/>
<int value="1" label="prefs::kHomePageIsNewTabPage"/>
<int value="2" label="prefs::kHomePage"/>
<int value="3" label="prefs::kRestoreOnStartup"/>
<int value="4" label="prefs::kURLsToRestoreOnStartup"/>
<int value="5" label="prefs::kExtensionsPref"/>
<int value="6" label="prefs::kGoogleServicesLastUsername"/>
<int value="7" label="prefs::kSearchProviderOverrides"/>
<int value="8" label="prefs::kDefaultSearchProviderSearchURL"/>
<int value="9" label="prefs::kDefaultSearchProviderKeyword"/>
<int value="10" label="prefs::kDefaultSearchProviderName"/>
<int value="11" label="prefs::kPinnedTabs"/>
</enum>
<enum name="TranslateError" type="int">
<int value="0" label="No error"/>
<int value="1" label="Network error"/>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment