Bug 1876541 - Remove an assert that doesn't hold for svg roots.
[gecko.git] / netwerk / ipc / SocketProcessImpl.cpp
bloba863d4a8759b41cb8e1a3259649013dea1bfa8cb
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "SocketProcessImpl.h"
8 #include "base/command_line.h"
9 #include "base/shared_memory.h"
10 #include "base/string_util.h"
11 #include "mozilla/BackgroundHangMonitor.h"
12 #include "mozilla/Preferences.h"
13 #include "mozilla/GeckoArgs.h"
14 #include "mozilla/ipc/ProcessUtils.h"
15 #include "mozilla/ipc/IOThreadChild.h"
17 #if defined(XP_WIN) && defined(MOZ_SANDBOX)
18 # include "mozilla/sandboxTarget.h"
19 #elif defined(__OpenBSD__) && defined(MOZ_SANDBOX)
20 # include "mozilla/SandboxSettings.h"
21 # include "prlink.h"
22 #endif
24 #ifdef XP_UNIX
25 # include <unistd.h> // For sleep().
26 #endif
28 using mozilla::ipc::IOThreadChild;
30 namespace mozilla {
31 namespace net {
33 LazyLogModule gSocketProcessLog("socketprocess");
35 SocketProcessImpl::~SocketProcessImpl() = default;
37 bool SocketProcessImpl::Init(int aArgc, char* aArgv[]) {
38 #ifdef XP_UNIX
39 if (PR_GetEnv("MOZ_DEBUG_SOCKET_PROCESS")) {
40 printf_stderr("\n\nSOCKETPROCESSnSOCKETPROCESS\n debug me @ %d\n\n",
41 base::GetCurrentProcId());
42 sleep(30);
44 #endif
45 #if defined(MOZ_SANDBOX) && defined(XP_WIN)
46 LoadLibraryW(L"nss3.dll");
47 LoadLibraryW(L"softokn3.dll");
48 LoadLibraryW(L"freebl3.dll");
49 LoadLibraryW(L"ipcclientcerts.dll");
50 LoadLibraryW(L"winmm.dll");
51 mozilla::SandboxTarget::Instance()->StartSandbox();
52 #elif defined(__OpenBSD__) && defined(MOZ_SANDBOX)
53 PR_LoadLibrary("libnss3.so");
54 PR_LoadLibrary("libsoftokn3.so");
55 PR_LoadLibrary("libfreebl3.so");
56 PR_LoadLibrary("libipcclientcerts.so");
57 StartOpenBSDSandbox(GeckoProcessType_Socket);
58 #endif
60 Maybe<const char*> parentBuildID =
61 geckoargs::sParentBuildID.Get(aArgc, aArgv);
62 if (parentBuildID.isNothing()) {
63 return false;
66 if (!ProcessChild::InitPrefs(aArgc, aArgv)) {
67 return false;
70 return mSocketProcessChild->Init(TakeInitialEndpoint(), *parentBuildID);
73 void SocketProcessImpl::CleanUp() { mSocketProcessChild->CleanUp(); }
75 } // namespace net
76 } // namespace mozilla