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

Unified Diff: chrome/browser/prefs/pref_metrics_service.cc

Issue 79013003: Introduce a temporary workaround to ensure tracked preferences set to empty list/dict are not confu… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mark in constructor Created 7 years, 1 month 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.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prefs/pref_metrics_service.cc
diff --git a/chrome/browser/prefs/pref_metrics_service.cc b/chrome/browser/prefs/pref_metrics_service.cc
index a4a4f33294c741b278a76ac116e2e02da40d3f0f..6d2476292a9c0bf037be468e18100b81e3f0c686 100644
--- a/chrome/browser/prefs/pref_metrics_service.cc
+++ b/chrome/browser/prefs/pref_metrics_service.cc
@@ -92,6 +92,8 @@ PrefMetricsService::PrefMetricsService(Profile* profile)
RegisterSyncedPrefObservers();
+ MarkNeedsEmptyValueForTrackedPreferences();
+
// The following code might cause callbacks into this instance before we exit
// the constructor. This instance should be initialized at this point.
#if defined(OS_WIN) || defined(OS_MACOSX)
@@ -120,6 +122,7 @@ PrefMetricsService::PrefMetricsService(Profile* profile,
tracked_pref_path_count_(tracked_pref_path_count),
checked_tracked_prefs_(false),
weak_factory_(this) {
+ MarkNeedsEmptyValueForTrackedPreferences();
CheckTrackedPreferences();
}
@@ -266,6 +269,19 @@ void PrefMetricsService::GetDeviceIdCallback(const std::string& device_id) {
CheckTrackedPreferences();
}
+void PrefMetricsService::MarkNeedsEmptyValueForTrackedPreferences() {
+ for (int i = 0; i < tracked_pref_path_count_; ++i) {
+ // Skip prefs that haven't been registered.
+ if (!prefs_->FindPreference(tracked_pref_paths_[i]))
+ continue;
+
+ // Make sure tracked prefs are saved to disk even if empty.
+ // TODO(gab): Guarantee this for all prefs at a lower level and remove this
+ // hack.
+ prefs_->MarkUserStoreNeedsEmptyValue(tracked_pref_paths_[i]);
+ }
+}
+
// To detect changes to Preferences that happen outside of Chrome, we hash
// selected pref values and save them in local state. CheckTrackedPreferences
// compares the saved values to the values observed in the profile's prefs. A
« no previous file with comments | « chrome/browser/prefs/pref_metrics_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698