diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /netwerk/ipc/SocketProcessImpl.cpp | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/ipc/SocketProcessImpl.cpp')
-rw-r--r-- | netwerk/ipc/SocketProcessImpl.cpp | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/netwerk/ipc/SocketProcessImpl.cpp b/netwerk/ipc/SocketProcessImpl.cpp new file mode 100644 index 0000000000..a67dd9c9bd --- /dev/null +++ b/netwerk/ipc/SocketProcessImpl.cpp @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "SocketProcessImpl.h" + +#include "ProcessUtils.h" +#include "base/command_line.h" +#include "base/shared_memory.h" +#include "base/string_util.h" +#include "mozilla/BackgroundHangMonitor.h" +#include "mozilla/Preferences.h" +#include "ProcessUtils.h" +#include "mozilla/ipc/IOThreadChild.h" + +#if defined(OS_WIN) && defined(MOZ_SANDBOX) +# include "mozilla/sandboxTarget.h" +#endif + +#ifdef OS_POSIX +# include <unistd.h> // For sleep(). +#endif + +using mozilla::ipc::IOThreadChild; + +namespace mozilla { +namespace net { + +LazyLogModule gSocketProcessLog("socketprocess"); + +SocketProcessImpl::SocketProcessImpl(ProcessId aParentPid) + : ProcessChild(aParentPid) {} + +SocketProcessImpl::~SocketProcessImpl() = default; + +bool SocketProcessImpl::Init(int aArgc, char* aArgv[]) { +#ifdef OS_POSIX + if (PR_GetEnv("MOZ_DEBUG_SOCKET_PROCESS")) { + printf_stderr("\n\nSOCKETPROCESSnSOCKETPROCESS\n debug me @ %d\n\n", + base::GetCurrentProcId()); + sleep(30); + } +#endif +#if defined(MOZ_SANDBOX) && defined(OS_WIN) + LoadLibraryW(L"nss3.dll"); + LoadLibraryW(L"softokn3.dll"); + LoadLibraryW(L"freebl3.dll"); + 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) { + if (++i == aArgc) { + return false; + } + + parentBuildID = aArgv[i]; + +#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]; + } + } + + ipc::SharedPreferenceDeserializer deserializer; + if (!deserializer.DeserializeFromSharedMemory(prefsHandle, prefMapHandle, + prefsLen, prefMapSize)) { + return false; + } + + return mSocketProcessChild.Init(ParentPid(), parentBuildID, + IOThreadChild::message_loop(), + IOThreadChild::TakeChannel()); +} + +void SocketProcessImpl::CleanUp() { mSocketProcessChild.CleanUp(); } + +} // namespace net +} // namespace mozilla |