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 47eca5b09ca9dfbf7903ebe9bf0f4d93944374d7..0bc8c1779dde865207af00007088761fd33eecf0 100644 |
--- a/chrome/browser/prefs/pref_metrics_service.cc |
+++ b/chrome/browser/prefs/pref_metrics_service.cc |
@@ -80,7 +80,9 @@ PrefMetricsService::PrefMetricsService(Profile* profile) |
profile_name_(profile_->GetPath().AsUTF8Unsafe()), |
tracked_pref_paths_(kTrackedPrefs), |
tracked_pref_path_count_(arraysize(kTrackedPrefs)), |
+#if defined(ENABLE_DCHECK) |
checked_tracked_prefs_(false), |
+#endif |
weak_factory_(this) { |
pref_hash_seed_ = ResourceBundle::GetSharedInstance().GetRawDataResource( |
IDR_PREF_HASH_SEED_BIN).as_string(); |
@@ -118,7 +120,9 @@ PrefMetricsService::PrefMetricsService(Profile* profile, |
device_id_(device_id), |
tracked_pref_paths_(tracked_pref_paths), |
tracked_pref_path_count_(tracked_pref_path_count), |
+#if defined(ENABLE_DCHECK) |
checked_tracked_prefs_(false), |
+#endif |
weak_factory_(this) { |
CheckTrackedPreferences(); |
} |
@@ -260,10 +264,14 @@ void PrefMetricsService::LogIntegerPrefChange(int boundary_value, |
} |
void PrefMetricsService::GetDeviceIdCallback(const std::string& device_id) { |
+#if !defined(OS_WIN) || defined(ENABLE_RLZ) |
+ // A device_id is expected in all scenarios except when RLZ is disabled on |
+ // Windows. |
+ DCHECK(!device_id.empty()); |
+#endif |
+ |
device_id_ = device_id; |
- // On Aura, this seems to be called twice. |
- if (!checked_tracked_prefs_) |
- CheckTrackedPreferences(); |
+ CheckTrackedPreferences(); |
} |
// To detect changes to Preferences that happen outside of Chrome, we hash |
@@ -273,7 +281,11 @@ void PrefMetricsService::GetDeviceIdCallback(const std::string& device_id) { |
// profile. To make the system more resistant to spoofing, pref values are |
// hashed with the pref path and the device id. |
void PrefMetricsService::CheckTrackedPreferences() { |
+#if defined(ENABLE_DCHECK) |
+ // Make sure this is only called once per instance of this service. |
DCHECK(!checked_tracked_prefs_); |
+ checked_tracked_prefs_ = true; |
+#endif |
const base::DictionaryValue* pref_hash_dicts = |
local_state_->GetDictionary(prefs::kProfilePreferenceHashes); |
@@ -337,8 +349,6 @@ void PrefMetricsService::CheckTrackedPreferences() { |
} |
} |
- checked_tracked_prefs_ = true; |
- |
// Now that we've checked the incoming preferences, register for change |
// notifications, unless this is test code. |
// TODO(bbudge) Fix failing browser_tests and so we can remove this test. |