diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 9faa2b6c2896..eb3e27e02724 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -3641,7 +3641,8 @@ ContentParent::Observe(nsISupports* aSubject, const char* aTopic, NS_LossyConvertUTF16toASCII strData(aData); // A pref changed. If it is useful to do so, inform child processes. - if (!ShouldSyncPreference(strData.Data())) { + if (!ShouldSyncPreference(strData.Data(), + /* will be fixed later */ false)) { return NS_OK; } diff --git a/dom/media/ipc/RDDProcessManager.cpp b/dom/media/ipc/RDDProcessManager.cpp index ab14bab50cdc..066b60c85af2 100644 --- a/dom/media/ipc/RDDProcessManager.cpp +++ b/dom/media/ipc/RDDProcessManager.cpp @@ -97,7 +97,7 @@ void RDDProcessManager::OnPreferenceChange(const char16_t* aData) { NS_LossyConvertUTF16toASCII strData(aData); // A pref changed. If it is useful to do so, inform child processes. - if (!ShouldSyncPreference(strData.Data())) { + if (!ShouldSyncPreference(strData.Data(), false)) { return; } diff --git a/gfx/ipc/GPUProcessManager.cpp b/gfx/ipc/GPUProcessManager.cpp index e7ba83817964..c77ec9fa7c6a 100644 --- a/gfx/ipc/GPUProcessManager.cpp +++ b/gfx/ipc/GPUProcessManager.cpp @@ -164,7 +164,7 @@ void GPUProcessManager::OnPreferenceChange(const char16_t* aData) { NS_LossyConvertUTF16toASCII strData(aData); // A pref changed. If it is useful to do so, inform child processes. - if (!ShouldSyncPreference(strData.Data())) { + if (!ShouldSyncPreference(strData.Data(), false)) { return; } diff --git a/gfx/vr/ipc/VRProcessManager.cpp b/gfx/vr/ipc/VRProcessManager.cpp index 1d489d5c42e4..a6dca8db3064 100644 --- a/gfx/vr/ipc/VRProcessManager.cpp +++ b/gfx/vr/ipc/VRProcessManager.cpp @@ -217,7 +217,7 @@ void VRProcessManager::OnPreferenceChange(const char16_t* aData) { NS_LossyConvertUTF16toASCII strData(aData); // A pref changed. If it is useful to do so, inform child processes. - if (!ShouldSyncPreference(strData.Data())) { + if (!ShouldSyncPreference(strData.Data(), false)) { return; } diff --git a/ipc/glue/ProcessUtils.h b/ipc/glue/ProcessUtils.h index 023750847f82..3f28ffb89235 100644 --- a/ipc/glue/ProcessUtils.h +++ b/ipc/glue/ProcessUtils.h @@ -26,7 +26,7 @@ void SetThisProcessName(const char* aName); class SharedPreferenceSerializer final { public: explicit SharedPreferenceSerializer( - std::function&& aShouldSerializeFn); + std::function&& aShouldSerializeFn); SharedPreferenceSerializer(SharedPreferenceSerializer&& aOther); ~SharedPreferenceSerializer(); @@ -48,7 +48,7 @@ class SharedPreferenceSerializer final { size_t mPrefsLength; UniqueFileHandle mPrefMapHandle; UniqueFileHandle mPrefsHandle; - std::function mShouldSerializeFn; + std::function mShouldSerializeFn; }; class SharedPreferenceDeserializer final { diff --git a/ipc/glue/ProcessUtils_common.cpp b/ipc/glue/ProcessUtils_common.cpp index 5dbe13cc7b2f..fd3e066b6f7f 100644 --- a/ipc/glue/ProcessUtils_common.cpp +++ b/ipc/glue/ProcessUtils_common.cpp @@ -18,7 +18,7 @@ namespace mozilla { namespace ipc { SharedPreferenceSerializer::SharedPreferenceSerializer( - std::function&& aShouldSerializeFn) + std::function&& aShouldSerializeFn) : mPrefMapSize(0), mPrefsLength(0), mShouldSerializeFn(aShouldSerializeFn) { MOZ_COUNT_CTOR(SharedPreferenceSerializer); } diff --git a/ipc/glue/UtilityProcessManager.cpp b/ipc/glue/UtilityProcessManager.cpp index b5f11e56143d..bdb9848a29dc 100644 --- a/ipc/glue/UtilityProcessManager.cpp +++ b/ipc/glue/UtilityProcessManager.cpp @@ -95,7 +95,7 @@ void UtilityProcessManager::OnPreferenceChange(const char16_t* aData) { NS_LossyConvertUTF16toASCII strData(aData); // A pref changed. If it is useful to do so, inform child processes. - if (!ShouldSyncPreference(strData.Data())) { + if (!ShouldSyncPreference(strData.Data(), false)) { return; } diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index 6cd3271abd50..cb93307a2481 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -3588,7 +3588,7 @@ NS_IMPL_ISUPPORTS(Preferences, nsIPrefService, nsIObserver, nsIPrefBranch, /* static */ void Preferences::SerializePreferences( nsCString& aStr, - const std::function& aShouldSerializeFn) { + const std::function& aShouldSerializeFn) { MOZ_RELEASE_ASSERT(InitStaticMembers()); aStr.Truncate(); @@ -3596,7 +3596,9 @@ void Preferences::SerializePreferences( for (auto iter = HashTable()->iter(); !iter.done(); iter.next()) { Pref* pref = iter.get().get(); if (!pref->IsTypeNone() && pref->HasAdvisablySizedValues()) { - pref->SerializeAndAppend(aStr, !aShouldSerializeFn(pref->Name())); + pref->SerializeAndAppend( + aStr, !aShouldSerializeFn(pref->Name(), + /* will be fixed later */ false)); } } @@ -5673,7 +5675,7 @@ namespace mozilla { void UnloadPrefsModule() { Preferences::Shutdown(); } -bool ShouldSyncPreference(const char* aPref) { +bool ShouldSyncPreference(const char* aPref, bool aIsDestWebContentProcess) { #define PREF_LIST_ENTRY(s) \ { s, (sizeof(s) / sizeof(char)) - 1 } struct PrefListEntry { diff --git a/modules/libpref/Preferences.h b/modules/libpref/Preferences.h index 044380cb9135..d953f8404ad4 100644 --- a/modules/libpref/Preferences.h +++ b/modules/libpref/Preferences.h @@ -401,7 +401,7 @@ class Preferences final : public nsIPrefService, // prefs in bulk from the parent process, via shared memory. static void SerializePreferences( nsCString& aStr, - const std::function& aShouldSerializeFn); + const std::function& aShouldSerializeFn); static void DeserializePreferences(char* aStr, size_t aPrefsLen); static mozilla::ipc::FileDescriptor EnsureSnapshot(size_t* aSize); @@ -532,7 +532,7 @@ class Preferences final : public nsIPrefService, static bool InitStaticMembers(); }; -bool ShouldSyncPreference(const char* aPref); +bool ShouldSyncPreference(const char* aPref, bool aIsDestWebContentProcess); } // namespace mozilla diff --git a/modules/libpref/test/gtest/Basics.cpp b/modules/libpref/test/gtest/Basics.cpp index 8f6e0bef1fc3..4f0ee3a17d7b 100644 --- a/modules/libpref/test/gtest/Basics.cpp +++ b/modules/libpref/test/gtest/Basics.cpp @@ -44,10 +44,10 @@ TEST(PrefsBasics, Serialize) nsCString str; Preferences::SerializePreferences( - str, [](const char* aPref) -> bool { return false; }); + str, [](const char* aPref, bool) -> bool { return false; }); ASSERT_STREQ(str.Data(), ""); - Preferences::SerializePreferences(str, [](const char* aPref) -> bool { + Preferences::SerializePreferences(str, [](const char* aPref, bool) -> bool { return strncmp(aPref, "foo.bool", 8) == 0; }); ASSERT_STREQ(str.Data(), "B-:8/foo.bool:T:F\n");