mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1045847 - Initialize sProcessType really, really early (r=khuey)
This commit is contained in:
parent
e755103847
commit
d52ab46335
@ -83,6 +83,12 @@ void StartSandboxCallback()
|
||||
int
|
||||
content_process_main(int argc, char* argv[])
|
||||
{
|
||||
// Check for the absolute minimum number of args we need to move
|
||||
// forward here. We expect the last arg to be the child process type.
|
||||
if (argc < 1)
|
||||
return 3;
|
||||
XRE_SetProcessType(argv[--argc]);
|
||||
|
||||
bool isNuwa = false;
|
||||
for (int i = 1; i < argc; i++) {
|
||||
isNuwa |= strcmp(argv[i], "-nuwa") == 0;
|
||||
@ -114,17 +120,11 @@ content_process_main(int argc, char* argv[])
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Check for the absolute minimum number of args we need to move
|
||||
// forward here. We expect the last arg to be the child process type.
|
||||
if (argc < 1)
|
||||
return 3;
|
||||
GeckoProcessType proctype = XRE_StringToChildProcessType(argv[--argc]);
|
||||
|
||||
#ifdef XP_WIN
|
||||
// For plugins, this is done in PluginProcessChild::Init, as we need to
|
||||
// avoid it for unsupported plugins. See PluginProcessChild::Init for
|
||||
// the details.
|
||||
if (proctype != GeckoProcessType_Plugin) {
|
||||
if (XRE_GetProcessType() != GeckoProcessType_Plugin) {
|
||||
mozilla::SanitizeEnvironmentVariables();
|
||||
SetDllDirectory(L"");
|
||||
}
|
||||
@ -144,7 +144,7 @@ content_process_main(int argc, char* argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult rv = XRE_InitChildProcess(argc, argv, proctype);
|
||||
nsresult rv = XRE_InitChildProcess(argc, argv);
|
||||
NS_ENSURE_SUCCESS(rv, 1);
|
||||
|
||||
return 0;
|
||||
|
@ -404,14 +404,14 @@ ChildProcessInit(int argc, char* argv[])
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
GeckoProcessType (*fXRE_StringToChildProcessType)(char*);
|
||||
xul_dlsym("XRE_StringToChildProcessType", &fXRE_StringToChildProcessType);
|
||||
void (*fXRE_SetProcessType)(char*);
|
||||
xul_dlsym("XRE_SetProcessType", &fXRE_SetProcessType);
|
||||
|
||||
mozglueresult (*fXRE_InitChildProcess)(int, char**, GeckoProcessType);
|
||||
mozglueresult (*fXRE_InitChildProcess)(int, char**);
|
||||
xul_dlsym("XRE_InitChildProcess", &fXRE_InitChildProcess);
|
||||
|
||||
GeckoProcessType proctype = fXRE_StringToChildProcessType(argv[--argc]);
|
||||
fXRE_SetProcessType(argv[--argc]);
|
||||
|
||||
return fXRE_InitChildProcess(argc, argv, proctype);
|
||||
return fXRE_InitChildProcess(argc, argv);
|
||||
}
|
||||
|
||||
|
@ -204,25 +204,26 @@ XRE_ChildProcessTypeToString(GeckoProcessType aProcessType)
|
||||
kGeckoProcessTypeString[aProcessType] : nullptr;
|
||||
}
|
||||
|
||||
GeckoProcessType
|
||||
XRE_StringToChildProcessType(const char* aProcessTypeString)
|
||||
{
|
||||
for (int i = 0;
|
||||
i < (int) ArrayLength(kGeckoProcessTypeString);
|
||||
++i) {
|
||||
if (!strcmp(kGeckoProcessTypeString[i], aProcessTypeString)) {
|
||||
return static_cast<GeckoProcessType>(i);
|
||||
}
|
||||
}
|
||||
return GeckoProcessType_Invalid;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace startup {
|
||||
GeckoProcessType sChildProcessType = GeckoProcessType_Default;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
XRE_SetProcessType(const char* aProcessTypeString)
|
||||
{
|
||||
sChildProcessType = GeckoProcessType_Invalid;
|
||||
for (int i = 0;
|
||||
i < (int) ArrayLength(kGeckoProcessTypeString);
|
||||
++i) {
|
||||
if (!strcmp(kGeckoProcessTypeString[i], aProcessTypeString)) {
|
||||
sChildProcessType = static_cast<GeckoProcessType>(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(MOZ_CRASHREPORTER)
|
||||
// FIXME/bug 539522: this out-of-place function is stuck here because
|
||||
// IPDL wants access to this crashreporter interface, and
|
||||
@ -276,8 +277,7 @@ SetTaskbarGroupId(const nsString& aId)
|
||||
|
||||
nsresult
|
||||
XRE_InitChildProcess(int aArgc,
|
||||
char* aArgv[],
|
||||
GeckoProcessType aProcess)
|
||||
char* aArgv[])
|
||||
{
|
||||
NS_ENSURE_ARG_MIN(aArgc, 2);
|
||||
NS_ENSURE_ARG_POINTER(aArgv);
|
||||
@ -313,8 +313,6 @@ XRE_InitChildProcess(int aArgc,
|
||||
PROFILER_LABEL("Startup", "XRE_InitChildProcess",
|
||||
js::ProfileEntry::Category::OTHER);
|
||||
|
||||
sChildProcessType = aProcess;
|
||||
|
||||
// Complete 'task_t' exchange for Mac OS X. This structure has the same size
|
||||
// regardless of architecture so we don't have any cross-arch issues here.
|
||||
#ifdef XP_MACOSX
|
||||
@ -461,7 +459,7 @@ XRE_InitChildProcess(int aArgc,
|
||||
}
|
||||
|
||||
MessageLoop::Type uiLoopType;
|
||||
switch (aProcess) {
|
||||
switch (XRE_GetProcessType()) {
|
||||
case GeckoProcessType_Content:
|
||||
// Content processes need the XPCOM/chromium frankenventloop
|
||||
uiLoopType = MessageLoop::TYPE_MOZILLA_CHILD;
|
||||
@ -486,7 +484,7 @@ XRE_InitChildProcess(int aArgc,
|
||||
mozilla::ipc::windows::InitUIThread();
|
||||
#endif
|
||||
|
||||
switch (aProcess) {
|
||||
switch (XRE_GetProcessType()) {
|
||||
case GeckoProcessType_Default:
|
||||
NS_RUNTIMEABORT("This makes no sense");
|
||||
break;
|
||||
|
@ -377,8 +377,8 @@ static_assert(MOZ_ARRAY_LENGTH(kGeckoProcessTypeString) ==
|
||||
XRE_API(const char*,
|
||||
XRE_ChildProcessTypeToString, (GeckoProcessType aProcessType))
|
||||
|
||||
XRE_API(GeckoProcessType,
|
||||
XRE_StringToChildProcessType, (const char* aProcessTypeString))
|
||||
XRE_API(void,
|
||||
XRE_SetProcessType, (const char* aProcessTypeString))
|
||||
|
||||
#if defined(MOZ_CRASHREPORTER)
|
||||
// Used in the "master" parent process hosting the crash server
|
||||
@ -393,8 +393,7 @@ XRE_API(bool,
|
||||
|
||||
XRE_API(nsresult,
|
||||
XRE_InitChildProcess, (int aArgc,
|
||||
char* aArgv[],
|
||||
GeckoProcessType aProcess))
|
||||
char* aArgv[]))
|
||||
|
||||
XRE_API(GeckoProcessType,
|
||||
XRE_GetProcessType, ())
|
||||
|
Loading…
Reference in New Issue
Block a user