--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -2950,17 +2950,17 @@ TelemetryPrefValue()
/* static */ void
Preferences::SetupTelemetryPref()
{
MOZ_ASSERT(XRE_IsParentProcess());
Maybe<bool> telemetryPrefValue = TelemetryPrefValue();
if (telemetryPrefValue.isSome()) {
- Preferences::SetBoolInAnyProcess(
+ Preferences::SetBool(
kTelemetryPref, *telemetryPrefValue, PrefValueKind::Default);
}
}
#else // !MOZ_WIDGET_ANDROID
static bool
TelemetryPrefValue()
@@ -2998,19 +2998,19 @@ TelemetryPrefValue()
return false;
}
/* static */ void
Preferences::SetupTelemetryPref()
{
MOZ_ASSERT(XRE_IsParentProcess());
- Preferences::SetBoolInAnyProcess(
+ Preferences::SetBool(
kTelemetryPref, TelemetryPrefValue(), PrefValueKind::Default);
- Preferences::LockInAnyProcess(kTelemetryPref);
+ Preferences::Lock(kTelemetryPref);
}
static void
CheckTelemetryPref()
{
MOZ_ASSERT(!XRE_IsParentProcess());
// Make sure the children got passed the right telemetry pref details.
@@ -4167,20 +4167,21 @@ Preferences::GetComplex(const char* aPre
void** aResult,
PrefValueKind aKind)
{
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return GetRootBranch(aKind)->GetComplexValue(aPrefName, aType, aResult);
}
/* static */ nsresult
-Preferences::SetCStringInAnyProcess(const char* aPrefName,
- const nsACString& aValue,
- PrefValueKind aKind)
+Preferences::SetCString(const char* aPrefName,
+ const nsACString& aValue,
+ PrefValueKind aKind)
{
+ ENSURE_PARENT_PROCESS("SetCString", aPrefName);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
if (aValue.Length() > MAX_PREF_LENGTH) {
return NS_ERROR_ILLEGAL_VALUE;
}
// It's ok to stash a pointer to the temporary PromiseFlatCString's chars in
// pref because pref_SetPref() duplicates those chars.
@@ -4192,110 +4193,79 @@ Preferences::SetCStringInAnyProcess(cons
aKind,
prefValue,
/* isSticky */ false,
/* isLocked */ false,
/* fromFile */ false);
}
/* static */ nsresult
-Preferences::SetCString(const char* aPrefName,
- const nsACString& aValue,
- PrefValueKind aKind)
+Preferences::SetBool(const char* aPrefName, bool aValue, PrefValueKind aKind)
{
- ENSURE_PARENT_PROCESS("SetCString", aPrefName);
- return SetCStringInAnyProcess(aPrefName, aValue, aKind);
-}
-
-/* static */ nsresult
-Preferences::SetBoolInAnyProcess(const char* aPrefName,
- bool aValue,
- PrefValueKind aKind)
-{
+ ENSURE_PARENT_PROCESS("SetBool", aPrefName);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
PrefValue prefValue;
prefValue.mBoolVal = aValue;
return pref_SetPref(aPrefName,
PrefType::Bool,
aKind,
prefValue,
/* isSticky */ false,
/* isLocked */ false,
/* fromFile */ false);
}
/* static */ nsresult
-Preferences::SetBool(const char* aPrefName, bool aValue, PrefValueKind aKind)
+Preferences::SetInt(const char* aPrefName, int32_t aValue, PrefValueKind aKind)
{
- ENSURE_PARENT_PROCESS("SetBool", aPrefName);
- return SetBoolInAnyProcess(aPrefName, aValue, aKind);
-}
-
-/* static */ nsresult
-Preferences::SetIntInAnyProcess(const char* aPrefName,
- int32_t aValue,
- PrefValueKind aKind)
-{
+ ENSURE_PARENT_PROCESS("SetInt", aPrefName);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
PrefValue prefValue;
prefValue.mIntVal = aValue;
return pref_SetPref(aPrefName,
PrefType::Int,
aKind,
prefValue,
/* isSticky */ false,
/* isLocked */ false,
/* fromFile */ false);
}
/* static */ nsresult
-Preferences::SetInt(const char* aPrefName, int32_t aValue, PrefValueKind aKind)
-{
- ENSURE_PARENT_PROCESS("SetInt", aPrefName);
- return SetIntInAnyProcess(aPrefName, aValue, aKind);
-}
-
-/* static */ nsresult
Preferences::SetComplex(const char* aPrefName,
const nsIID& aType,
nsISupports* aValue,
PrefValueKind aKind)
{
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return GetRootBranch(aKind)->SetComplexValue(aPrefName, aType, aValue);
}
/* static */ nsresult
-Preferences::LockInAnyProcess(const char* aPrefName)
+Preferences::Lock(const char* aPrefName)
{
+ ENSURE_PARENT_PROCESS("Lock", aPrefName);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
Pref* pref = pref_HashTableLookup(aPrefName);
if (!pref) {
return NS_ERROR_UNEXPECTED;
}
if (!pref->IsLocked()) {
pref->SetIsLocked(true);
NotifyCallbacks(aPrefName);
}
return NS_OK;
}
/* static */ nsresult
-Preferences::Lock(const char* aPrefName)
-{
- ENSURE_PARENT_PROCESS("Lock", aPrefName);
- return Preferences::LockInAnyProcess(aPrefName);
-}
-
-/* static */ nsresult
Preferences::Unlock(const char* aPrefName)
{
ENSURE_PARENT_PROCESS("Unlock", aPrefName);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
Pref* pref = pref_HashTableLookup(aPrefName);
if (!pref) {
return NS_ERROR_UNEXPECTED;
@@ -4314,18 +4284,19 @@ Preferences::IsLocked(const char* aPrefN
{
NS_ENSURE_TRUE(InitStaticMembers(), false);
Pref* pref = pref_HashTableLookup(aPrefName);
return pref && pref->IsLocked();
}
/* static */ nsresult
-Preferences::ClearUserInAnyProcess(const char* aPrefName)
+Preferences::ClearUser(const char* aPrefName)
{
+ ENSURE_PARENT_PROCESS("ClearUser", aPrefName);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
PrefEntry* entry = pref_HashTableLookupInner(aPrefName);
Pref* pref;
if (entry && (pref = entry->mPref) && pref->HasUserValue()) {
pref->ClearUserValue();
if (!pref->HasDefaultValue()) {
@@ -4333,23 +4304,16 @@ Preferences::ClearUserInAnyProcess(const
}
NotifyCallbacks(aPrefName);
Preferences::HandleDirty();
}
return NS_OK;
}
-/* static */ nsresult
-Preferences::ClearUser(const char* aPrefName)
-{
- ENSURE_PARENT_PROCESS("ClearUser", aPrefName);
- return ClearUserInAnyProcess(aPrefName);
-}
-
/* static */ bool
Preferences::HasUserValue(const char* aPrefName)
{
NS_ENSURE_TRUE(InitStaticMembers(), false);
Pref* pref = pref_HashTableLookup(aPrefName);
return pref && pref->HasUserValue();
}
--- a/modules/libpref/Preferences.h
+++ b/modules/libpref/Preferences.h
@@ -393,39 +393,16 @@ public:
PrefixMatch,
ExactMatch,
};
private:
static void SetupTelemetryPref();
static mozilla::Result<mozilla::Ok, const char*> InitInitialObjects();
- // Functions above that modify prefs will fail if they are not run in the
- // parent process. The "InAnyProcess" functions below will succeed outside
- // the content process, and are used when passing pref values from the parent
- // process to content processes.
-
- static nsresult SetBoolInAnyProcess(
- const char* aPrefName,
- bool aValue,
- PrefValueKind aKind = PrefValueKind::User);
-
- static nsresult SetIntInAnyProcess(const char* aPrefName,
- int32_t aValue,
- PrefValueKind aKind = PrefValueKind::User);
-
- static nsresult SetCStringInAnyProcess(
- const char* aPrefName,
- const nsACString& aValue,
- PrefValueKind aKind = PrefValueKind::User);
-
- static nsresult ClearUserInAnyProcess(const char* aPrefName);
-
- static nsresult LockInAnyProcess(const char* aPrefName);
-
static nsresult RegisterCallback(PrefChangedFunc aCallback,
const char* aPref,
void* aClosure,
MatchKind aMatchKind,
bool aIsPriority = false);
static nsresult UnregisterCallback(PrefChangedFunc aCallback,
const char* aPref,
void* aClosure,