diff --git a/gfx/ipc/GPUProcessHost.cpp b/gfx/ipc/GPUProcessHost.cpp index d8e17316df15..243c770b79f5 100644 --- a/gfx/ipc/GPUProcessHost.cpp +++ b/gfx/ipc/GPUProcessHost.cpp @@ -11,6 +11,7 @@ #include "nsITimer.h" #include "mozilla/Preferences.h" #include "VRGPUChild.h" +#include "ProcessUtils.h" namespace mozilla { namespace gfx { @@ -35,6 +36,12 @@ bool GPUProcessHost::Launch(StringVector aExtraOpts) { MOZ_ASSERT(!mGPUChild); MOZ_ASSERT(!gfxPlatform::IsHeadless()); + mPrefSerializer = MakeUnique(); + if (!mPrefSerializer->SerializeToSharedMemory()) { + return false; + } + mPrefSerializer->AddSharedPrefCmdLineArgs(*this, aExtraOpts); + #if defined(XP_WIN) && defined(MOZ_SANDBOX) mSandboxLevel = Preferences::GetInt("security.sandbox.gpu.level"); #endif @@ -123,6 +130,7 @@ void GPUProcessHost::InitAfterConnect(bool aSucceeded) { MOZ_ASSERT(!mGPUChild); mLaunchPhase = LaunchPhase::Complete; + mPrefSerializer = nullptr; if (aSucceeded) { mProcessToken = ++sProcessTokenCounter; diff --git a/gfx/ipc/GPUProcessHost.h b/gfx/ipc/GPUProcessHost.h index 6118a5453d4e..22f53db0672a 100644 --- a/gfx/ipc/GPUProcessHost.h +++ b/gfx/ipc/GPUProcessHost.h @@ -13,6 +13,11 @@ #include "mozilla/ipc/ProtocolUtils.h" #include "mozilla/ipc/TaskFactory.h" +namespace mozilla { +namespace ipc { +class SharedPreferenceSerializer; +} +} // namespace mozilla class nsITimer; namespace mozilla { @@ -122,6 +127,8 @@ class GPUProcessHost final : public mozilla::ipc::GeckoChildProcessHost { UniquePtr mGPUChild; uint64_t mProcessToken; + UniquePtr mPrefSerializer; + bool mShutdownRequested; bool mChannelClosed; diff --git a/gfx/ipc/GPUProcessImpl.cpp b/gfx/ipc/GPUProcessImpl.cpp index ad8bae20a6c1..2193169933f1 100644 --- a/gfx/ipc/GPUProcessImpl.cpp +++ b/gfx/ipc/GPUProcessImpl.cpp @@ -6,6 +6,7 @@ #include "GPUProcessImpl.h" #include "mozilla/ipc/IOThreadChild.h" #include "nsXPCOM.h" +#include "ProcessUtils.h" #if defined(OS_WIN) && defined(MOZ_SANDBOX) # include "mozilla/sandboxTarget.h" @@ -26,15 +27,48 @@ bool GPUProcessImpl::Init(int aArgc, char* aArgv[]) { mozilla::SandboxTarget::Instance()->StartSandbox(); #endif char* parentBuildID = nullptr; + char* prefsHandle = nullptr; + char* prefMapHandle = nullptr; + char* prefsLen = nullptr; + char* prefMapSize = nullptr; for (int i = 1; i < aArgc; i++) { if (!aArgv[i]) { continue; } if (strcmp(aArgv[i], "-parentBuildID") == 0) { parentBuildID = aArgv[i + 1]; + +#ifdef XP_WIN + } else if (strcmp(aArgv[i], "-prefsHandle") == 0) { + if (++i == aArgc) { + return false; + } + prefsHandle = aArgv[i]; + } else if (strcmp(aArgv[i], "-prefMapHandle") == 0) { + if (++i == aArgc) { + return false; + } + prefMapHandle = aArgv[i]; +#endif + } else if (strcmp(aArgv[i], "-prefsLen") == 0) { + if (++i == aArgc) { + return false; + } + prefsLen = aArgv[i]; + } else if (strcmp(aArgv[i], "-prefMapSize") == 0) { + if (++i == aArgc) { + return false; + } + prefMapSize = aArgv[i]; } } + SharedPreferenceDeserializer deserializer; + if (!deserializer.DeserializeFromSharedMemory(prefsHandle, prefMapHandle, + prefsLen, prefMapSize)) { + return false; + } + return mGPU.Init(ParentPid(), parentBuildID, IOThreadChild::message_loop(), IOThreadChild::channel()); }