mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 04:38:02 +00:00
Bug 1306327 - Use the new XRE Bootstrap API in Desktop Firefox. r=bsmedberg
This just wraps all the XRE method calls to go through the Bootstrap API instead of relying on the XPCOM glue methods. --HG-- extra : rebase_source : eccbe18b9b21ca1ab6c403515ffd60f0a9174d9c
This commit is contained in:
parent
5f3d2e8810
commit
09dc362a61
@ -161,40 +161,7 @@ static bool IsArg(const char* arg, const char* s)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
XRE_GetFileFromPathType XRE_GetFileFromPath;
|
Bootstrap::UniquePtr gBootstrap;
|
||||||
XRE_ParseAppDataType XRE_ParseAppData;
|
|
||||||
XRE_TelemetryAccumulateType XRE_TelemetryAccumulate;
|
|
||||||
XRE_StartupTimelineRecordType XRE_StartupTimelineRecord;
|
|
||||||
XRE_mainType XRE_main;
|
|
||||||
XRE_StopLateWriteChecksType XRE_StopLateWriteChecks;
|
|
||||||
XRE_XPCShellMainType XRE_XPCShellMain;
|
|
||||||
XRE_GetProcessTypeType XRE_GetProcessType;
|
|
||||||
XRE_SetProcessTypeType XRE_SetProcessType;
|
|
||||||
XRE_InitChildProcessType XRE_InitChildProcess;
|
|
||||||
XRE_EnableSameExecutableForContentProcType XRE_EnableSameExecutableForContentProc;
|
|
||||||
#ifdef LIBFUZZER
|
|
||||||
XRE_LibFuzzerSetMainType XRE_LibFuzzerSetMain;
|
|
||||||
XRE_LibFuzzerGetFuncsType XRE_LibFuzzerGetFuncs;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const nsDynamicFunctionLoad kXULFuncs[] = {
|
|
||||||
{ "XRE_GetFileFromPath", (NSFuncPtr*) &XRE_GetFileFromPath },
|
|
||||||
{ "XRE_ParseAppData", (NSFuncPtr*) &XRE_ParseAppData },
|
|
||||||
{ "XRE_TelemetryAccumulate", (NSFuncPtr*) &XRE_TelemetryAccumulate },
|
|
||||||
{ "XRE_StartupTimelineRecord", (NSFuncPtr*) &XRE_StartupTimelineRecord },
|
|
||||||
{ "XRE_main", (NSFuncPtr*) &XRE_main },
|
|
||||||
{ "XRE_StopLateWriteChecks", (NSFuncPtr*) &XRE_StopLateWriteChecks },
|
|
||||||
{ "XRE_XPCShellMain", (NSFuncPtr*) &XRE_XPCShellMain },
|
|
||||||
{ "XRE_GetProcessType", (NSFuncPtr*) &XRE_GetProcessType },
|
|
||||||
{ "XRE_SetProcessType", (NSFuncPtr*) &XRE_SetProcessType },
|
|
||||||
{ "XRE_InitChildProcess", (NSFuncPtr*) &XRE_InitChildProcess },
|
|
||||||
{ "XRE_EnableSameExecutableForContentProc", (NSFuncPtr*) &XRE_EnableSameExecutableForContentProc },
|
|
||||||
#ifdef LIBFUZZER
|
|
||||||
{ "XRE_LibFuzzerSetMain", (NSFuncPtr*) &XRE_LibFuzzerSetMain },
|
|
||||||
{ "XRE_LibFuzzerGetFuncs", (NSFuncPtr*) &XRE_LibFuzzerGetFuncs },
|
|
||||||
#endif
|
|
||||||
{ nullptr, nullptr }
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef LIBFUZZER
|
#ifdef LIBFUZZER
|
||||||
int libfuzzer_main(int argc, char **argv);
|
int libfuzzer_main(int argc, char **argv);
|
||||||
@ -203,7 +170,7 @@ int libfuzzer_main(int argc, char **argv);
|
|||||||
|
|
||||||
void libFuzzerGetFuncs(const char* moduleName, LibFuzzerInitFunc* initFunc,
|
void libFuzzerGetFuncs(const char* moduleName, LibFuzzerInitFunc* initFunc,
|
||||||
LibFuzzerTestingFunc* testingFunc) {
|
LibFuzzerTestingFunc* testingFunc) {
|
||||||
return XRE_LibFuzzerGetFuncs(moduleName, initFunc, testingFunc);
|
return gBootstrap->XRE_LibFuzzerGetFuncs(moduleName, initFunc, testingFunc);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -216,7 +183,7 @@ static int do_main(int argc, char* argv[], char* envp[])
|
|||||||
// Note that -app must be the *first* argument.
|
// Note that -app must be the *first* argument.
|
||||||
const char *appDataFile = getenv("XUL_APP_FILE");
|
const char *appDataFile = getenv("XUL_APP_FILE");
|
||||||
if (appDataFile && *appDataFile) {
|
if (appDataFile && *appDataFile) {
|
||||||
rv = XRE_GetFileFromPath(appDataFile, getter_AddRefs(appini));
|
rv = gBootstrap->XRE_GetFileFromPath(appDataFile, getter_AddRefs(appini));
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
Output("Invalid path found: '%s'", appDataFile);
|
Output("Invalid path found: '%s'", appDataFile);
|
||||||
return 255;
|
return 255;
|
||||||
@ -228,7 +195,7 @@ static int do_main(int argc, char* argv[], char* envp[])
|
|||||||
return 255;
|
return 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = XRE_GetFileFromPath(argv[2], getter_AddRefs(appini));
|
rv = gBootstrap->XRE_GetFileFromPath(argv[2], getter_AddRefs(appini));
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
Output("application.ini path not recognized: '%s'", argv[2]);
|
Output("application.ini path not recognized: '%s'", argv[2]);
|
||||||
return 255;
|
return 255;
|
||||||
@ -254,13 +221,13 @@ static int do_main(int argc, char* argv[], char* envp[])
|
|||||||
sandboxing::GetInitializedBrokerServices();
|
sandboxing::GetInitializedBrokerServices();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return XRE_XPCShellMain(--argc, argv, envp, &shellData);
|
return gBootstrap->XRE_XPCShellMain(--argc, argv, envp, &shellData);
|
||||||
}
|
}
|
||||||
|
|
||||||
XREAppData appData;
|
XREAppData appData;
|
||||||
|
|
||||||
if (appini) {
|
if (appini) {
|
||||||
rv = XRE_ParseAppData(appini, appData);
|
rv = gBootstrap->XRE_ParseAppData(appini, appData);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
Output("Couldn't read application.ini");
|
Output("Couldn't read application.ini");
|
||||||
return 255;
|
return 255;
|
||||||
@ -303,10 +270,10 @@ static int do_main(int argc, char* argv[], char* envp[])
|
|||||||
|
|
||||||
#ifdef LIBFUZZER
|
#ifdef LIBFUZZER
|
||||||
if (getenv("LIBFUZZER"))
|
if (getenv("LIBFUZZER"))
|
||||||
XRE_LibFuzzerSetMain(argc, argv, libfuzzer_main);
|
gBootstrap->XRE_LibFuzzerSetMain(argc, argv, libfuzzer_main);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return XRE_main(argc, argv, appData);
|
return gBootstrap->XRE_main(argc, argv, appData);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@ -345,20 +312,14 @@ InitXPCOMGlue(const char *argv0)
|
|||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = XPCOMGlueStartup(exePath);
|
gBootstrap = mozilla::GetBootstrap(exePath);
|
||||||
if (NS_FAILED(rv)) {
|
if (!gBootstrap) {
|
||||||
Output("Couldn't load XPCOM.\n");
|
Output("Couldn't load XPCOM.\n");
|
||||||
return rv;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
|
||||||
|
|
||||||
rv = XPCOMGlueLoadXULFunctions(kXULFuncs);
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
Output("Couldn't load XRE functions.\n");
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will set this thread as the main thread.
|
// This will set this thread as the main thread.
|
||||||
NS_LogInit();
|
gBootstrap->NS_LogInit();
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -397,10 +358,10 @@ int main(int argc, char* argv[], char* envp[])
|
|||||||
return 255;
|
return 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = content_process_main(argc, argv);
|
int result = content_process_main(gBootstrap.get(), argc, argv);
|
||||||
|
|
||||||
// InitXPCOMGlue calls NS_LogInit, so we need to balance it here.
|
// InitXPCOMGlue calls NS_LogInit, so we need to balance it here.
|
||||||
NS_LogTerm();
|
gBootstrap->NS_LogTerm();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -412,15 +373,15 @@ int main(int argc, char* argv[], char* envp[])
|
|||||||
return 255;
|
return 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
XRE_StartupTimelineRecord(mozilla::StartupTimeline::START, start);
|
gBootstrap->XRE_StartupTimelineRecord(mozilla::StartupTimeline::START, start);
|
||||||
|
|
||||||
#ifdef MOZ_BROWSER_CAN_BE_CONTENTPROC
|
#ifdef MOZ_BROWSER_CAN_BE_CONTENTPROC
|
||||||
XRE_EnableSameExecutableForContentProc();
|
gBootstrap->XRE_EnableSameExecutableForContentProc();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int result = do_main(argc, argv, envp);
|
int result = do_main(argc, argv, envp);
|
||||||
|
|
||||||
NS_LogTerm();
|
gBootstrap->NS_LogTerm();
|
||||||
|
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
// Allow writes again. While we would like to catch writes from static
|
// Allow writes again. While we would like to catch writes from static
|
||||||
@ -428,8 +389,10 @@ int main(int argc, char* argv[], char* envp[])
|
|||||||
// at least one such write that we don't control (see bug 826029). For
|
// at least one such write that we don't control (see bug 826029). For
|
||||||
// now we enable writes again and early exits will have to use exit instead
|
// now we enable writes again and early exits will have to use exit instead
|
||||||
// of _exit.
|
// of _exit.
|
||||||
XRE_StopLateWriteChecks();
|
gBootstrap->XRE_StopLateWriteChecks();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
gBootstrap.reset();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,11 @@
|
|||||||
|
|
||||||
#include "../contentproc/plugin-container.cpp"
|
#include "../contentproc/plugin-container.cpp"
|
||||||
|
|
||||||
|
#include "mozilla/Bootstrap.h"
|
||||||
#include "mozilla/WindowsDllBlocklist.h"
|
#include "mozilla/WindowsDllBlocklist.h"
|
||||||
|
|
||||||
|
using namespace mozilla;
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -15,5 +18,10 @@ main(int argc, char *argv[])
|
|||||||
DllBlocklist_Initialize();
|
DllBlocklist_Initialize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return content_process_main(argc, argv);
|
Bootstrap::UniquePtr bootstrap;
|
||||||
|
XRE_GetBootstrap(bootstrap);
|
||||||
|
if (!bootstrap) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
return content_process_main(bootstrap.get(), argc, argv);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "nsXPCOM.h"
|
#include "nsXPCOM.h"
|
||||||
#include "nsXULAppAPI.h"
|
#include "nsXULAppAPI.h"
|
||||||
#include "nsAutoPtr.h"
|
#include "nsAutoPtr.h"
|
||||||
|
#include "mozilla/Bootstrap.h"
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@ -71,7 +72,7 @@ MakeSandboxStarter()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
content_process_main(int argc, char* argv[])
|
content_process_main(mozilla::Bootstrap* bootstrap, int argc, char* argv[])
|
||||||
{
|
{
|
||||||
// Check for the absolute minimum number of args we need to move
|
// 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.
|
// forward here. We expect the last arg to be the child process type.
|
||||||
@ -93,13 +94,13 @@ content_process_main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XRE_SetProcessType(argv[--argc]);
|
bootstrap->XRE_SetProcessType(argv[--argc]);
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
// For plugins, this is done in PluginProcessChild::Init, as we need to
|
// For plugins, this is done in PluginProcessChild::Init, as we need to
|
||||||
// avoid it for unsupported plugins. See PluginProcessChild::Init for
|
// avoid it for unsupported plugins. See PluginProcessChild::Init for
|
||||||
// the details.
|
// the details.
|
||||||
if (XRE_GetProcessType() != GeckoProcessType_Plugin) {
|
if (bootstrap->XRE_GetProcessType() != GeckoProcessType_Plugin) {
|
||||||
mozilla::SanitizeEnvironmentVariables();
|
mozilla::SanitizeEnvironmentVariables();
|
||||||
SetDllDirectoryW(L"");
|
SetDllDirectoryW(L"");
|
||||||
}
|
}
|
||||||
@ -107,10 +108,10 @@ content_process_main(int argc, char* argv[])
|
|||||||
#if !defined(XP_LINUX) && defined(MOZ_PLUGIN_CONTAINER)
|
#if !defined(XP_LINUX) && defined(MOZ_PLUGIN_CONTAINER)
|
||||||
// On Windows and MacOS, the GMPLoader lives in plugin-container, so that its
|
// On Windows and MacOS, the GMPLoader lives in plugin-container, so that its
|
||||||
// code can be covered by an EME/GMP vendor's voucher.
|
// code can be covered by an EME/GMP vendor's voucher.
|
||||||
if (XRE_GetProcessType() == GeckoProcessType_GMPlugin) {
|
if (bootstrap->XRE_GetProcessType() == GeckoProcessType_GMPlugin) {
|
||||||
childData.gmpLoader = mozilla::gmp::CreateGMPLoader(MakeSandboxStarter());
|
childData.gmpLoader = mozilla::gmp::CreateGMPLoader(MakeSandboxStarter());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
nsresult rv = XRE_InitChildProcess(argc, argv, &childData);
|
nsresult rv = bootstrap->XRE_InitChildProcess(argc, argv, &childData);
|
||||||
return NS_FAILED(rv);
|
return NS_FAILED(rv);
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,16 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "nsXULAppAPI.h"
|
#define MOZ_IPDL_TESTS
|
||||||
|
#include "mozilla/Bootstrap.h"
|
||||||
|
|
||||||
#if defined(XP_WIN)
|
#if defined(XP_WIN)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "nsWindowsWMain.cpp"
|
#include "nsWindowsWMain.cpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using namespace mozilla;
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char** argv)
|
main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
@ -16,5 +19,10 @@ main(int argc, char** argv)
|
|||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return XRE_RunIPDLTest(argc, argv);
|
Bootstrap::UniquePtr bootstrap;
|
||||||
|
XRE_GetBootstrap(bootstrap);
|
||||||
|
if (!bootstrap) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
return bootstrap->XRE_RunIPDLTest(argc, argv);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "mozilla/WindowsDllBlocklist.h"
|
#include "mozilla/WindowsDllBlocklist.h"
|
||||||
|
#include "mozilla/Bootstrap.h"
|
||||||
|
|
||||||
#include "nsXULAppAPI.h"
|
#include "nsXULAppAPI.h"
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
@ -59,7 +60,13 @@ main(int argc, char** argv, char** envp)
|
|||||||
mozilla::sandboxing::GetInitializedBrokerServices();
|
mozilla::sandboxing::GetInitializedBrokerServices();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int result = XRE_XPCShellMain(argc, argv, envp, &shellData);
|
mozilla::Bootstrap::UniquePtr bootstrap;
|
||||||
|
XRE_GetBootstrap(bootstrap);
|
||||||
|
if (!bootstrap) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int result = bootstrap->XRE_XPCShellMain(argc, argv, envp, &shellData);
|
||||||
|
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
FinishAutoreleasePool();
|
FinishAutoreleasePool();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user