mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-25 01:01:52 +00:00
fb36126f61
Backed out changeset 5497c90b03de (bug 1607984) Backed out changeset 71dffa590c10 (bug 1607984) Backed out changeset fdacabac2c54 (bug 1607984) Backed out changeset 5f9fe17e46b8 (bug 1607984) Backed out changeset 8f9058eb821d (bug 1607984) Backed out changeset 025af7792f2a (bug 1607984) Backed out changeset c7edd070b2f3 (bug 1607984) Backed out changeset 8e7c95d322e8 (bug 1607984) Backed out changeset e51f6b7a745c (bug 1607984) Backed out changeset 979d99eb12d1 (bug 1607984) Backed out changeset f554d4ce6718 (bug 1607984) Backed out changeset fe84e5c64b4e (bug 1607984) Backed out changeset 05d2032060db (bug 1607984) Backed out changeset 07ce7b11fee9 (bug 1607984) Backed out changeset 718d89be09d2 (bug 1607984)
107 lines
2.8 KiB
C++
107 lines
2.8 KiB
C++
/* -*- 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 "base/command_line.h"
|
|
#include "base/shared_memory.h"
|
|
#include "base/string_util.h"
|
|
#include "mozilla/ipc/IOThreadChild.h"
|
|
#include "mozilla/BackgroundHangMonitor.h"
|
|
#include "mozilla/Preferences.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];
|
|
}
|
|
}
|
|
|
|
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
|