mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
061201563e
- Bug 1274192 part 1 - make the MediaDecoderReaderWrapper as a proxy of WaitForData(); r=jwwang (9debdca9a9) - Bug 1274192 part 2 - make MDSM and SeekTask to adopt new MediaDecoderReaderWrapper API; r=jwwang (156f924dc9) - Bug 1276495: Don't reset audio promises for video only seek. r=jwwang,jya (c4632c7ff6) - Bug 1276318, part 1 - Fix leading tabs in ipc/glue. r=billm (46bcc4ccb3) - Bug 1035125 Part 1: Back out changeset 1910714b56c6 and associated subsequent changes. r=bsmedberg (3ead5efb66) - Bug 1035125 Part 2: Back out changeset 3c59642f6445 and associated subsequent changes. r=glandium (e86b4f4651) - Bug 1035125 Part 3: Back out changeset fa15c3e929d0 and associated subsequent changes. r=glandium (49585d6caf) - Bug 1188045 - Part 2: Delay-load xul.dll when built with clang-cl (90877526a3) - Bug 1188045 - Part 1: Move the definition of sandboxTarget::Instance() out-of-line; r=bobowen,glandium (5523a15f0e) - Bug 1035125 Part 4: Back out changeset 8ae39d920f5c and associated subsequent changes. r=glandium (4b952b6311) - Bug 1035125 Part 5: Back out changeset baa3f852133b and associated subsequent changes. r=glandium (0b08d2e71d) - Bug 1035125 Part 6: Take Chromium commit 3181ba39ee787e1b40f4aea4be23f4f666ad0945 to add Windows 10 version to enumeration. r=aklotz (af62c8065f) - Bug 1035125 Part 7: Remove unused functions in security/sandbox/chromium/base/time/time.h to avoid nspr dependency. r=aklotz (e10430c6ae) - Bug 1035125 Part 8: Pass sandboxing pointers through XRE_InitChildProcess instead of linking to more functions in xul. r=aklotz,glandium (07590ba9cd) - Bug 1035125 Part 9: Link Chromium sandbox into firefox.exe instead of having a separate DLL. r=aklotz,glandium (ae40d509d5) - Bug 1270752 - Fix lifetime of buffer passed to PR_SetEnv(). r=jduell (bfce06ebea) - Bug 1275117 - Fix static strings leaks when mozlogging is on. r=jduell (8e9066c5d7) - Bug 1114647 - Use firefox for child processes instead of plugin-container. r=ted (4e5871566d) - Bug 1271169 - Move all device binding code into librlz and remove static runtime requirement. r=glandium (fc9cfccbec) - Bug 1271169 - Move EME/GMP device binding code into GMPDeviceBinding.h/cpp. r=gerald (3fabde64b8) - Bug 1273048 - Add MOZ_GCC_VERSION_AT_MOST macro. r=froydnj (cfb5acdbe6) - Bug 1269968 - Remove unnecessary deduction on RefPtr.h. r=froydnj (30cf9bbf47) - Bug 525063 - add attribute to mark member variables that should be skipped by clang plugin initialization checker. r=nfroyd (78aa863f88) - Bug 1278391 - add move constructor to EnumeratedArray (r=njn) (5effe4e473) - Bug 1268518: Update basic-integer tests for rotations + clean up; r=sunfish (46827b6211) - Bug 1270370 - Part 1: Move SetIteratorObject to MapObject.h; r=jorendorff (01a27fbd50) - Bug 1270370 - Part 2: Expose MapIterator and SetIterator through ESClassValues; r=jorendorff (3edb3c7551) - Bug 1267551 (part 3) - Use MOZ_MUST_USE more in js/src/builtin/. r=jonco. (ea96d0fae0) - Bug 1267551 (part 4) - Use MOZ_MUST_USE more in js/src/asmjs/. r=bbouvier. (3e622c736d) - Bug 1268910: Refactor WebAssembly trap handling; r=luke (b59394a287) - Bug 1268910: Trap on edge cases for integer div/mod; r=sunfish (3d85230cc8) - Bug 1267551 (part 5) - Use MOZ_MUST_USE more in js/src/ctypes/. r=sfink. (e6580fb645) - Bug 1267551 (part 6) - Remove dead GenerateBlockId declaration. r=jorendorff. (74afcc549e) - Bug 1240072 - Add public JS APIs related to modules r=shu Bug 1267551 (part 7) - Use MOZ_MUST_USE more in js/src/frontend/. r=jorendorff. (5275c57768) - Bug 1267551 (part 8) - Use MOZ_MUST_USE more in js/src/gc/. r=terrence. (2572cc1c58) - Bug 1261063 - Part 1 - Remove public Telemetry functions that return raw histogram instances. r=chutten (3a68653c8f) - Bug 1261063 - Part 2 - Expose C++ function to clear Telemetry histograms. r=chutten (1f42f6aa1e) - Bug 1261063 - Part 3 - Make RasterImage use the public Telemetry API. r=tnikkel (0f564f3836) - Bug 1261063 - Part 4 - Use a count histogram for WebRTC call counts. r=jesup (b6b7b649e0) - Bug 1270073 - Point to Telemetry documentation in Telemetry.h. r=chutten (517279b284) - Bug 1261052 - Move C++ histogram implementation code into a separate module. r=gfritzsche. (66bcb1e167) - Bug 1145164 - Allow non-unitary increments to count histograms. r=gfritzsche (507e076e28) - Bug 1173447 - Add test for incremental pre-barriers when storing things under roots, r=jonco (caf8bd16be) - Bug 1267551 (part 10) - Use MOZ_MUST_USE in AutoVectorRooterBase. r=terrence. (2c5ed87a9f) - This catches a missing check. (b2fcd30fc5) - Bug 1267551 (part 11b) - Follow-up to fix Android bustage. r=me (f464ca7b98) - Bug 1271854 - Part 1: Allow specifying multiple GC zeal levels; r=terrence (da3c3e1281) - Bug 1271854 - Part 2: Allow specifying zeal modes by name as well; r=terrence (f63926e45b) - Bug 1271854 - Part 3: Avoid saving the GC zeal string inside the JS shell; r=terrence (f09b262e55) - Bug 1270062 - Unbust Windows full duplex. a=Tomcat (3c8b5887b6) - Bug 1270062 - Update libcubeb. rs=jesup (71805cb0e0) - Bug 1270004 - Update libcubeb. rs=jesup (2d90b9662f) - Bug 1280280 - Update cubeb to 073c9f011114. r=kinetik (6bee6a7f21) - Bug 1280280 - Update media/libcube/update.sh to add cubeb_jack.cpp, and sort the list of files. r=kinetik (430b7533c4) - Bug 1272604 - Add a zeal mode to check the heap after a moving GC r=terrence (85c018d71f) - Bug 1272604 - Fix bad implicit conversion constructor build error r=me (5c4e1dbc44) - Bug 1272604 - Fix hazard analysis failure r=me (0591aa2dca) - Bug 1232417 - Use a Variant to represent the CrossCompartmentWrapperMap key; r=jonco (19e759f1ba) - Bug 1269928 - Fold DirectProxyHandler into Wrapper, which is now its only (non-test) consumer. r=efaust (7550dde64d) - Bug 1273639 - Add a nonunified spidermonkey build, r=terrence (065364af2e) - Bug 1273639 - Fix nonunified spidermonkey builds, r=terrence (626042a5e0) - Bug 1273180 - Trigger major GC if necessary after minor GC r=terrence (cab82a4146) - Bug 1268992 - Assert that the heap is empty after a shutdown GC; r=jonco (35e37de1b2) - Bug 1273908 - Refactor GC to make it easier to add new kinds of GC thing r=terrence (edc8c4d66a)
488 lines
14 KiB
C++
488 lines
14 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 "nsXULAppAPI.h"
|
|
#include "mozilla/AppData.h"
|
|
#include "application.ini.h"
|
|
#include "nsXPCOMGlue.h"
|
|
#if defined(XP_WIN)
|
|
#include <windows.h>
|
|
#include <stdlib.h>
|
|
#include <io.h>
|
|
#include <fcntl.h>
|
|
#elif defined(XP_UNIX)
|
|
#include <sys/resource.h>
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#ifdef XP_MACOSX
|
|
#include "MacQuirks.h"
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
#include <time.h>
|
|
|
|
#include "nsCOMPtr.h"
|
|
#include "nsIFile.h"
|
|
#include "nsStringGlue.h"
|
|
|
|
// Easy access to a five second startup delay used to get
|
|
// a debugger attached in the metro environment.
|
|
// #define DEBUG_delay_start_metro
|
|
|
|
#ifdef XP_WIN
|
|
#ifdef MOZ_ASAN
|
|
// ASAN requires firefox.exe to be built with -MD, and it's OK if we don't
|
|
// support Windows XP SP2 in ASAN builds.
|
|
#define XRE_DONT_SUPPORT_XPSP2
|
|
#endif
|
|
#define XRE_WANT_ENVIRON
|
|
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
|
#define snprintf _snprintf
|
|
#endif
|
|
#define strcasecmp _stricmp
|
|
#ifdef MOZ_SANDBOX
|
|
#include "mozilla/sandboxing/SandboxInitialization.h"
|
|
#endif
|
|
#endif
|
|
#include "BinaryPath.h"
|
|
|
|
#include "nsXPCOMPrivate.h" // for MAXPATHLEN and XPCOM_DLL
|
|
|
|
#include "mozilla/Telemetry.h"
|
|
#include "mozilla/WindowsDllBlocklist.h"
|
|
|
|
#if !defined(MOZ_WIDGET_COCOA) && !defined(MOZ_WIDGET_ANDROID) \
|
|
&& !(defined(XP_LINUX) && defined(MOZ_SANDBOX))
|
|
#define MOZ_BROWSER_CAN_BE_CONTENTPROC
|
|
#include "../../ipc/contentproc/plugin-container.cpp"
|
|
#endif
|
|
|
|
using namespace mozilla;
|
|
|
|
#ifdef XP_MACOSX
|
|
#define kOSXResourcesFolder "Resources"
|
|
#endif
|
|
#define kDesktopFolder "browser"
|
|
#define kMetroFolder "metro"
|
|
#define kMetroAppIniFilename "metroapp.ini"
|
|
#ifdef XP_WIN
|
|
#define kMetroTestFile "tests.ini"
|
|
const char* kMetroConsoleIdParam = "testconsoleid=";
|
|
#endif
|
|
|
|
static void Output(const char *fmt, ... )
|
|
{
|
|
va_list ap;
|
|
va_start(ap, fmt);
|
|
|
|
#ifndef XP_WIN
|
|
vfprintf(stderr, fmt, ap);
|
|
#else
|
|
char msg[2048];
|
|
vsnprintf_s(msg, _countof(msg), _TRUNCATE, fmt, ap);
|
|
|
|
wchar_t wide_msg[2048];
|
|
MultiByteToWideChar(CP_UTF8,
|
|
0,
|
|
msg,
|
|
-1,
|
|
wide_msg,
|
|
_countof(wide_msg));
|
|
#if MOZ_WINCONSOLE
|
|
fwprintf_s(stderr, wide_msg);
|
|
#else
|
|
// Linking user32 at load-time interferes with the DLL blocklist (bug 932100).
|
|
// This is a rare codepath, so we can load user32 at run-time instead.
|
|
HMODULE user32 = LoadLibraryW(L"user32.dll");
|
|
if (user32) {
|
|
decltype(MessageBoxW)* messageBoxW =
|
|
(decltype(MessageBoxW)*) GetProcAddress(user32, "MessageBoxW");
|
|
if (messageBoxW) {
|
|
messageBoxW(nullptr, wide_msg, L"Pale Moon", MB_OK
|
|
| MB_ICONERROR
|
|
| MB_SETFOREGROUND);
|
|
}
|
|
FreeLibrary(user32);
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
va_end(ap);
|
|
}
|
|
|
|
/**
|
|
* Return true if |arg| matches the given argument name.
|
|
*/
|
|
static bool IsArg(const char* arg, const char* s)
|
|
{
|
|
if (*arg == '-')
|
|
{
|
|
if (*++arg == '-')
|
|
++arg;
|
|
return !strcasecmp(arg, s);
|
|
}
|
|
|
|
#if defined(XP_WIN)
|
|
if (*arg == '/')
|
|
return !strcasecmp(++arg, s);
|
|
#endif
|
|
|
|
return false;
|
|
}
|
|
|
|
#ifdef XP_WIN
|
|
/*
|
|
* AttachToTestHarness - Windows helper for when we are running
|
|
* in the immersive environment. Firefox is launched by Windows in
|
|
* response to a request by metrotestharness, which is launched by
|
|
* runtests.py. As such stdout in fx doesn't point to the right
|
|
* stream. This helper touches up stdout such that test output gets
|
|
* routed to a named pipe metrotestharness creates and dumps to its
|
|
* stdout.
|
|
*/
|
|
static void AttachToTestHarness()
|
|
{
|
|
// attach to the metrotestharness named logging pipe
|
|
HANDLE winOut = CreateFileA("\\\\.\\pipe\\metrotestharness",
|
|
GENERIC_WRITE,
|
|
FILE_SHARE_WRITE, 0,
|
|
OPEN_EXISTING, 0, 0);
|
|
|
|
if (winOut == INVALID_HANDLE_VALUE) {
|
|
OutputDebugStringW(L"Could not create named logging pipe.\n");
|
|
return;
|
|
}
|
|
|
|
// Set the c runtime handle
|
|
int stdOut = _open_osfhandle((intptr_t)winOut, _O_APPEND);
|
|
if (stdOut == -1) {
|
|
OutputDebugStringW(L"Could not open c-runtime handle.\n");
|
|
return;
|
|
}
|
|
FILE *fp = _fdopen(stdOut, "a");
|
|
*stdout = *fp;
|
|
}
|
|
#endif
|
|
|
|
XRE_GetFileFromPathType XRE_GetFileFromPath;
|
|
XRE_CreateAppDataType XRE_CreateAppData;
|
|
XRE_FreeAppDataType XRE_FreeAppData;
|
|
//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;
|
|
|
|
static const nsDynamicFunctionLoad kXULFuncs[] = {
|
|
{ "XRE_GetFileFromPath", (NSFuncPtr*) &XRE_GetFileFromPath },
|
|
{ "XRE_CreateAppData", (NSFuncPtr*) &XRE_CreateAppData },
|
|
{ "XRE_FreeAppData", (NSFuncPtr*) &XRE_FreeAppData },
|
|
//{ "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 },
|
|
{ nullptr, nullptr }
|
|
};
|
|
|
|
static int do_main(int argc, char* argv[], char* envp[], nsIFile *xreDirectory)
|
|
{
|
|
nsCOMPtr<nsIFile> appini;
|
|
nsresult rv;
|
|
uint32_t mainFlags = 0;
|
|
|
|
// Allow firefox.exe to launch XULRunner apps via -app <application.ini>
|
|
// Note that -app must be the *first* argument.
|
|
const char *appDataFile = getenv("XUL_APP_FILE");
|
|
if (appDataFile && *appDataFile) {
|
|
rv = XRE_GetFileFromPath(appDataFile, getter_AddRefs(appini));
|
|
if (NS_FAILED(rv)) {
|
|
Output("Invalid path found: '%s'", appDataFile);
|
|
return 255;
|
|
}
|
|
}
|
|
else if (argc > 1 && IsArg(argv[1], "app")) {
|
|
if (argc == 2) {
|
|
Output("Incorrect number of arguments passed to -app");
|
|
return 255;
|
|
}
|
|
|
|
rv = XRE_GetFileFromPath(argv[2], getter_AddRefs(appini));
|
|
if (NS_FAILED(rv)) {
|
|
Output("application.ini path not recognized: '%s'", argv[2]);
|
|
return 255;
|
|
}
|
|
|
|
char appEnv[MAXPATHLEN];
|
|
snprintf(appEnv, MAXPATHLEN, "XUL_APP_FILE=%s", argv[2]);
|
|
if (putenv(appEnv)) {
|
|
Output("Couldn't set %s.\n", appEnv);
|
|
return 255;
|
|
}
|
|
argv[2] = argv[0];
|
|
argv += 2;
|
|
argc -= 2;
|
|
} else if (argc > 1 && IsArg(argv[1], "xpcshell")) {
|
|
for (int i = 1; i < argc; i++) {
|
|
argv[i] = argv[i + 1];
|
|
}
|
|
|
|
XREShellData shellData;
|
|
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
|
|
shellData.sandboxBrokerServices =
|
|
sandboxing::GetInitializedBrokerServices();
|
|
#endif
|
|
|
|
return XRE_XPCShellMain(--argc, argv, envp, &shellData);
|
|
}
|
|
|
|
if (appini) {
|
|
nsXREAppData *appData;
|
|
rv = XRE_CreateAppData(appini, &appData);
|
|
if (NS_FAILED(rv)) {
|
|
Output("Couldn't read application.ini");
|
|
return 255;
|
|
}
|
|
// xreDirectory already has a refcount from NS_NewLocalFile
|
|
appData->xreDirectory = xreDirectory;
|
|
int result = XRE_main(argc, argv, appData, mainFlags);
|
|
XRE_FreeAppData(appData);
|
|
return result;
|
|
}
|
|
|
|
ScopedAppData appData(&sAppData);
|
|
nsCOMPtr<nsIFile> exeFile;
|
|
rv = mozilla::BinaryPath::GetFile(argv[0], getter_AddRefs(exeFile));
|
|
if (NS_FAILED(rv)) {
|
|
Output("Couldn't find the application directory.\n");
|
|
return 255;
|
|
}
|
|
|
|
nsCOMPtr<nsIFile> greDir;
|
|
exeFile->GetParent(getter_AddRefs(greDir));
|
|
#ifdef XP_MACOSX
|
|
greDir->SetNativeLeafName(NS_LITERAL_CSTRING(kOSXResourcesFolder));
|
|
#endif
|
|
nsCOMPtr<nsIFile> appSubdir;
|
|
greDir->Clone(getter_AddRefs(appSubdir));
|
|
appSubdir->Append(NS_LITERAL_STRING(kDesktopFolder));
|
|
|
|
SetStrongPtr(appData.directory, static_cast<nsIFile*>(appSubdir.get()));
|
|
// xreDirectory already has a refcount from NS_NewLocalFile
|
|
appData.xreDirectory = xreDirectory;
|
|
|
|
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
|
|
sandbox::BrokerServices* brokerServices =
|
|
sandboxing::GetInitializedBrokerServices();
|
|
#if defined(MOZ_CONTENT_SANDBOX)
|
|
if (!brokerServices) {
|
|
Output("Couldn't initialize the broker services.\n");
|
|
return 255;
|
|
}
|
|
#endif
|
|
appData.sandboxBrokerServices = brokerServices;
|
|
#endif
|
|
|
|
return XRE_main(argc, argv, &appData, mainFlags);
|
|
}
|
|
|
|
static bool
|
|
FileExists(const char *path)
|
|
{
|
|
#ifdef XP_WIN
|
|
wchar_t wideDir[MAX_PATH];
|
|
MultiByteToWideChar(CP_UTF8, 0, path, -1, wideDir, MAX_PATH);
|
|
DWORD fileAttrs = GetFileAttributesW(wideDir);
|
|
return fileAttrs != INVALID_FILE_ATTRIBUTES;
|
|
#else
|
|
return access(path, R_OK) == 0;
|
|
#endif
|
|
}
|
|
|
|
static nsresult
|
|
InitXPCOMGlue(const char *argv0, nsIFile **xreDirectory)
|
|
{
|
|
char exePath[MAXPATHLEN];
|
|
|
|
nsresult rv = mozilla::BinaryPath::Get(argv0, exePath);
|
|
if (NS_FAILED(rv)) {
|
|
Output("Couldn't find the application directory.\n");
|
|
return rv;
|
|
}
|
|
|
|
char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]);
|
|
if (!lastSlash || (size_t(lastSlash - exePath) > MAXPATHLEN -
|
|
sizeof(XPCOM_DLL) - 1))
|
|
return NS_ERROR_FAILURE;
|
|
|
|
strcpy(lastSlash + 1, XPCOM_DLL);
|
|
|
|
if (!FileExists(exePath)) {
|
|
Output("Could not find the Mozilla runtime.\n");
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
// We do this because of data in bug 771745
|
|
XPCOMGlueEnablePreload();
|
|
|
|
rv = XPCOMGlueStartup(exePath);
|
|
if (NS_FAILED(rv)) {
|
|
Output("Couldn't load XPCOM.\n");
|
|
return rv;
|
|
}
|
|
|
|
rv = XPCOMGlueLoadXULFunctions(kXULFuncs);
|
|
if (NS_FAILED(rv)) {
|
|
Output("Couldn't load XRE functions.\n");
|
|
return rv;
|
|
}
|
|
|
|
NS_LogInit();
|
|
|
|
if (xreDirectory) {
|
|
// chop XPCOM_DLL off exePath
|
|
*lastSlash = '\0';
|
|
#ifdef XP_MACOSX
|
|
lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]);
|
|
strcpy(lastSlash + 1, kOSXResourcesFolder);
|
|
#endif
|
|
#ifdef XP_WIN
|
|
rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(exePath), false,
|
|
xreDirectory);
|
|
#else
|
|
rv = NS_NewNativeLocalFile(nsDependentCString(exePath), false,
|
|
xreDirectory);
|
|
#endif
|
|
}
|
|
|
|
return rv;
|
|
}
|
|
|
|
int main(int argc, char* argv[], char* envp[])
|
|
{
|
|
#ifdef MOZ_BROWSER_CAN_BE_CONTENTPROC
|
|
// We are launching as a content process, delegate to the appropriate
|
|
// main
|
|
if (argc > 1 && IsArg(argv[1], "contentproc")) {
|
|
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
|
|
// We need to initialize the sandbox TargetServices before InitXPCOMGlue
|
|
// because we might need the sandbox broker to give access to some files.
|
|
if (!sandboxing::GetInitializedTargetServices()) {
|
|
Output("Failed to initialize the sandbox target services.");
|
|
return 255;
|
|
}
|
|
#endif
|
|
|
|
nsresult rv = InitXPCOMGlue(argv[0], nullptr);
|
|
if (NS_FAILED(rv)) {
|
|
return 255;
|
|
}
|
|
|
|
int result = content_process_main(argc, argv);
|
|
|
|
// InitXPCOMGlue calls NS_LogInit, so we need to balance it here.
|
|
NS_LogTerm();
|
|
|
|
return result;
|
|
}
|
|
#endif
|
|
|
|
#ifdef DEBUG_delay_start_metro
|
|
Sleep(5000);
|
|
#endif
|
|
mozilla::TimeStamp start = mozilla::TimeStamp::Now();
|
|
|
|
#ifdef XP_MACOSX
|
|
TriggerQuirks();
|
|
#endif
|
|
|
|
int gotCounters;
|
|
#if defined(XP_UNIX)
|
|
struct rusage initialRUsage;
|
|
gotCounters = !getrusage(RUSAGE_SELF, &initialRUsage);
|
|
#elif defined(XP_WIN)
|
|
IO_COUNTERS ioCounters;
|
|
gotCounters = GetProcessIoCounters(GetCurrentProcess(), &ioCounters);
|
|
#else
|
|
#error "Unknown platform" // having this here keeps cppcheck happy
|
|
#endif
|
|
|
|
nsIFile *xreDirectory;
|
|
|
|
#ifdef HAS_DLL_BLOCKLIST
|
|
DllBlocklist_Initialize();
|
|
|
|
#ifdef DEBUG
|
|
// In order to be effective against AppInit DLLs, the blocklist must be
|
|
// initialized before user32.dll is loaded into the process (bug 932100).
|
|
if (GetModuleHandleA("user32.dll")) {
|
|
fprintf(stderr, "DLL blocklist was unable to intercept AppInit DLLs.\n");
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
nsresult rv = InitXPCOMGlue(argv[0], &xreDirectory);
|
|
if (NS_FAILED(rv)) {
|
|
return 255;
|
|
}
|
|
|
|
XRE_StartupTimelineRecord(mozilla::StartupTimeline::START, start);
|
|
|
|
if (gotCounters) {
|
|
#if defined(XP_WIN)
|
|
/*XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_OPS,
|
|
int(ioCounters.ReadOperationCount));
|
|
XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_TRANSFER,
|
|
int(ioCounters.ReadTransferCount / 1024));*/
|
|
IO_COUNTERS newIoCounters;
|
|
if (GetProcessIoCounters(GetCurrentProcess(), &newIoCounters)) {
|
|
/*XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_OPS,
|
|
int(newIoCounters.ReadOperationCount - ioCounters.ReadOperationCount));
|
|
XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_TRANSFER,
|
|
int((newIoCounters.ReadTransferCount - ioCounters.ReadTransferCount) / 1024));*/
|
|
}
|
|
#elif defined(XP_UNIX)
|
|
/*XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_HARD_FAULTS,
|
|
int(initialRUsage.ru_majflt));*/
|
|
struct rusage newRUsage;
|
|
if (!getrusage(RUSAGE_SELF, &newRUsage)) {
|
|
/*XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_HARD_FAULTS,
|
|
int(newRUsage.ru_majflt - initialRUsage.ru_majflt));*/
|
|
}
|
|
#else
|
|
#error "Unknown platform" // having this here keeps cppcheck happy
|
|
#endif
|
|
}
|
|
|
|
#ifdef MOZ_BROWSER_CAN_BE_CONTENTPROC
|
|
XRE_EnableSameExecutableForContentProc();
|
|
#endif
|
|
|
|
int result = do_main(argc, argv, envp, xreDirectory);
|
|
|
|
NS_LogTerm();
|
|
|
|
#ifdef XP_MACOSX
|
|
// Allow writes again. While we would like to catch writes from static
|
|
// destructors to allow early exits to use _exit, we know that there is
|
|
// 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
|
|
// of _exit.
|
|
XRE_StopLateWriteChecks();
|
|
#endif
|
|
|
|
return result;
|
|
}
|