Bug 1444275 - Don't set the telemetry pref in content processes. r=glandium
It'll be set via the normal parent-to-child pref setting process.
MozReview-Commit-ID: By4mG7brc55
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -2946,16 +2946,18 @@ TelemetryPrefValue()
kChannelPref, channelPrefValue, PrefValueKind::Default);
return Some(prefValue.EqualsLiteral("beta"));
#endif
}
/* static */ void
Preferences::SetupTelemetryPref()
{
+ MOZ_ASSERT(XRE_IsParentProcess());
+
Maybe<bool> telemetryPrefValue = TelemetryPrefValue();
if (telemetryPrefValue.isSome()) {
Preferences::SetBoolInAnyProcess(
kTelemetryPref, *telemetryPrefValue, PrefValueKind::Default);
}
}
#else // !MOZ_WIDGET_ANDROID
@@ -2994,21 +2996,37 @@ TelemetryPrefValue()
}
return false;
}
/* static */ void
Preferences::SetupTelemetryPref()
{
+ MOZ_ASSERT(XRE_IsParentProcess());
+
Preferences::SetBoolInAnyProcess(
kTelemetryPref, TelemetryPrefValue(), PrefValueKind::Default);
Preferences::LockInAnyProcess(kTelemetryPref);
}
+static void
+CheckTelemetryPref()
+{
+ MOZ_ASSERT(!XRE_IsParentProcess());
+
+ // Make sure the children got passed the right telemetry pref details.
+ DebugOnly<bool> value;
+ MOZ_ASSERT(NS_SUCCEEDED(Preferences::GetBool(kTelemetryPref, &value)) &&
+ value == TelemetryPrefValue());
+ // njn: uncomment after bug 1436911 lands; it ensures that the locked status
+ // is passed correctly
+ // MOZ_ASSERT(Preferences::IsLocked(kTelemetryPref));
+}
+
#endif // MOZ_WIDGET_ANDROID
/* static */ already_AddRefed<Preferences>
Preferences::GetInstanceForService()
{
if (sPreferences) {
return do_AddRef(sPreferences);
}
@@ -3037,16 +3055,20 @@ Preferences::GetInstanceForService()
if (!XRE_IsParentProcess()) {
MOZ_ASSERT(gEarlyDomPrefs);
for (unsigned int i = 0; i < gEarlyDomPrefs->Length(); i++) {
Preferences::SetPreference(gEarlyDomPrefs->ElementAt(i));
}
delete gEarlyDomPrefs;
gEarlyDomPrefs = nullptr;
+#ifndef MOZ_WIDGET_ANDROID
+ CheckTelemetryPref();
+#endif
+
} else {
// Check if there is a deployment configuration file. If so, set up the
// pref config machinery, which will actually read the file.
nsAutoCString lockFileName;
nsresult rv = Preferences::GetCString(
"general.config.filename", lockFileName, PrefValueKind::User);
if (NS_SUCCEEDED(rv)) {
NS_CreateServicesFromCategory(
@@ -4022,17 +4044,19 @@ Preferences::InitInitialObjects()
continue;
}
// Do we care if a file provided by this process fails to load?
pref_LoadPrefsInDir(path, nullptr, 0);
}
}
- SetupTelemetryPref();
+ if (XRE_IsParentProcess()) {
+ SetupTelemetryPref();
+ }
NS_CreateServicesFromCategory(NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID,
nullptr,
NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID);
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
NS_ENSURE_SUCCESS(rv, Err("GetObserverService() failed (2)"));