зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1752332: Move ShouldSyncPreferences to Preferences module r=KrisWright
Depends on D141409 Differential Revision: https://phabricator.services.mozilla.com/D141410
This commit is contained in:
Родитель
b7307088a9
Коммит
b662df4c61
|
@ -3786,39 +3786,6 @@ ContentParent::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool ContentParent::ShouldSyncPreference(const char* aPref) {
|
||||
#define PREF_LIST_ENTRY(s) \
|
||||
{ s, (sizeof(s) / sizeof(char)) - 1 }
|
||||
struct PrefListEntry {
|
||||
const char* mPrefBranch;
|
||||
size_t mLen;
|
||||
};
|
||||
|
||||
// These prefs are not useful in child processes.
|
||||
static const PrefListEntry sParentOnlyPrefBranchList[] = {
|
||||
PREF_LIST_ENTRY("app.update.lastUpdateTime."),
|
||||
PREF_LIST_ENTRY("datareporting.policy."),
|
||||
PREF_LIST_ENTRY("browser.safebrowsing.provider."),
|
||||
PREF_LIST_ENTRY("browser.shell."),
|
||||
PREF_LIST_ENTRY("browser.slowStartup."),
|
||||
PREF_LIST_ENTRY("browser.startup."),
|
||||
PREF_LIST_ENTRY("extensions.getAddons.cache."),
|
||||
PREF_LIST_ENTRY("media.gmp-manager."),
|
||||
PREF_LIST_ENTRY("media.gmp-gmpopenh264."),
|
||||
PREF_LIST_ENTRY("privacy.sanitize."),
|
||||
};
|
||||
#undef PREF_LIST_ENTRY
|
||||
|
||||
for (const auto& entry : sParentOnlyPrefBranchList) {
|
||||
if (strncmp(entry.mPrefBranch, aPref, entry.mLen) == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ContentParent::UpdateNetworkLinkType() {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsINetworkLinkService> nls =
|
||||
|
|
|
@ -1460,8 +1460,6 @@ class ContentParent final
|
|||
|
||||
void UpdateNetworkLinkType();
|
||||
|
||||
static bool ShouldSyncPreference(const char* aPref);
|
||||
|
||||
already_AddRefed<JSActor> InitJSActor(JS::HandleObject aMaybeActor,
|
||||
const nsACString& aName,
|
||||
ErrorResult& aRv) override;
|
||||
|
|
|
@ -46,8 +46,8 @@ bool RDDProcessHost::Launch(StringVector aExtraOpts) {
|
|||
MOZ_ASSERT(mLaunchPhase == LaunchPhase::Unlaunched);
|
||||
MOZ_ASSERT(!mRDDChild);
|
||||
|
||||
mPrefSerializer = MakeUnique<ipc::SharedPreferenceSerializer>(
|
||||
dom::ContentParent::ShouldSyncPreference);
|
||||
mPrefSerializer =
|
||||
MakeUnique<ipc::SharedPreferenceSerializer>(ShouldSyncPreference);
|
||||
if (!mPrefSerializer->SerializeToSharedMemory()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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 (!dom::ContentParent::ShouldSyncPreference(strData.Data())) {
|
||||
if (!ShouldSyncPreference(strData.Data())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,8 +42,8 @@ bool GPUProcessHost::Launch(StringVector aExtraOpts) {
|
|||
MOZ_ASSERT(!mGPUChild);
|
||||
MOZ_ASSERT(!gfxPlatform::IsHeadless());
|
||||
|
||||
mPrefSerializer = MakeUnique<ipc::SharedPreferenceSerializer>(
|
||||
dom::ContentParent::ShouldSyncPreference);
|
||||
mPrefSerializer =
|
||||
MakeUnique<ipc::SharedPreferenceSerializer>(ShouldSyncPreference);
|
||||
if (!mPrefSerializer->SerializeToSharedMemory()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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 (!dom::ContentParent::ShouldSyncPreference(strData.Data())) {
|
||||
if (!ShouldSyncPreference(strData.Data())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 (!dom::ContentParent::ShouldSyncPreference(strData.Data())) {
|
||||
if (!ShouldSyncPreference(strData.Data())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "mozilla/ipc/ProcessUtils.h"
|
||||
#include "mozilla/ipc/ProtocolTypes.h"
|
||||
#include "mozilla/ipc/ProtocolUtils.h" // for IToplevelProtocol
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/TimeStamp.h" // for TimeStamp
|
||||
#include "mozilla/Unused.h"
|
||||
|
@ -54,8 +55,8 @@ bool VRProcessParent::Launch() {
|
|||
std::vector<std::string> extraArgs;
|
||||
ProcessChild::AddPlatformBuildID(extraArgs);
|
||||
|
||||
mPrefSerializer = MakeUnique<ipc::SharedPreferenceSerializer>(
|
||||
dom::ContentParent::ShouldSyncPreference);
|
||||
mPrefSerializer =
|
||||
MakeUnique<ipc::SharedPreferenceSerializer>(ShouldSyncPreference);
|
||||
if (!mPrefSerializer->SerializeToSharedMemory()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -60,8 +60,8 @@ bool UtilityProcessHost::Launch(StringVector aExtraOpts) {
|
|||
MOZ_ASSERT(mLaunchPhase == LaunchPhase::Unlaunched);
|
||||
MOZ_ASSERT(!mUtilityProcessParent);
|
||||
|
||||
mPrefSerializer = MakeUnique<ipc::SharedPreferenceSerializer>(
|
||||
dom::ContentParent::ShouldSyncPreference);
|
||||
mPrefSerializer =
|
||||
MakeUnique<ipc::SharedPreferenceSerializer>(ShouldSyncPreference);
|
||||
if (!mPrefSerializer->SerializeToSharedMemory()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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 (!dom::ContentParent::ShouldSyncPreference(strData.Data())) {
|
||||
if (!ShouldSyncPreference(strData.Data())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ already_AddRefed<IPDLUnitTestParent> IPDLUnitTestParent::CreateCrossProcess() {
|
|||
std::vector<std::string> extraArgs;
|
||||
|
||||
auto prefSerializer = MakeUnique<ipc::SharedPreferenceSerializer>(
|
||||
mozilla::dom::ContentParent::ShouldSyncPreference);
|
||||
ShouldSyncPreference);
|
||||
if (!prefSerializer->SerializeToSharedMemory()) {
|
||||
ADD_FAILURE()
|
||||
<< "SharedPreferenceSerializer::SerializeToSharedMemory failed";
|
||||
|
|
|
@ -5673,6 +5673,38 @@ namespace mozilla {
|
|||
|
||||
void UnloadPrefsModule() { Preferences::Shutdown(); }
|
||||
|
||||
bool ShouldSyncPreference(const char* aPref) {
|
||||
#define PREF_LIST_ENTRY(s) \
|
||||
{ s, (sizeof(s) / sizeof(char)) - 1 }
|
||||
struct PrefListEntry {
|
||||
const char* mPrefBranch;
|
||||
size_t mLen;
|
||||
};
|
||||
|
||||
// These prefs are not useful in child processes.
|
||||
static const PrefListEntry sParentOnlyPrefBranchList[] = {
|
||||
PREF_LIST_ENTRY("app.update.lastUpdateTime."),
|
||||
PREF_LIST_ENTRY("datareporting.policy."),
|
||||
PREF_LIST_ENTRY("browser.safebrowsing.provider."),
|
||||
PREF_LIST_ENTRY("browser.shell."),
|
||||
PREF_LIST_ENTRY("browser.slowStartup."),
|
||||
PREF_LIST_ENTRY("browser.startup."),
|
||||
PREF_LIST_ENTRY("extensions.getAddons.cache."),
|
||||
PREF_LIST_ENTRY("media.gmp-manager."),
|
||||
PREF_LIST_ENTRY("media.gmp-gmpopenh264."),
|
||||
PREF_LIST_ENTRY("privacy.sanitize."),
|
||||
};
|
||||
#undef PREF_LIST_ENTRY
|
||||
|
||||
for (const auto& entry : sParentOnlyPrefBranchList) {
|
||||
if (strncmp(entry.mPrefBranch, aPref, entry.mLen) == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
// This file contains the C wrappers for the C++ static pref getters, as used
|
||||
|
|
|
@ -532,6 +532,8 @@ class Preferences final : public nsIPrefService,
|
|||
static bool InitStaticMembers();
|
||||
};
|
||||
|
||||
bool ShouldSyncPreference(const char* aPref);
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_Preferences_h
|
||||
|
|
|
@ -68,8 +68,7 @@ bool SocketProcessHost::Launch() {
|
|||
std::vector<std::string> extraArgs;
|
||||
ProcessChild::AddPlatformBuildID(extraArgs);
|
||||
|
||||
SharedPreferenceSerializer prefSerializer(
|
||||
mozilla::dom::ContentParent::ShouldSyncPreference);
|
||||
SharedPreferenceSerializer prefSerializer(ShouldSyncPreference);
|
||||
if (!prefSerializer.SerializeToSharedMemory()) {
|
||||
return false;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче