mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 556644 - 1. Move omnijar setup to NS_InitXPCOM and use omni.jar by default, r=bsmedberg a=blocking2.0
This commit is contained in:
parent
699c96697a
commit
dc746e4977
@ -237,14 +237,6 @@ GeckoChildProcessHost::PerformAsyncLaunch(std::vector<std::string> aExtraOpts)
|
||||
newEnvVars["LD_LIBRARY_PATH"] = path.get();
|
||||
#elif OS_MACOSX
|
||||
newEnvVars["DYLD_LIBRARY_PATH"] = path.get();
|
||||
#endif
|
||||
#ifdef MOZ_OMNIJAR
|
||||
// Make sure the child process can find the omnijar
|
||||
// See ScopedXPCOMStartup::Initialize in nsAppRunner.cpp
|
||||
nsCAutoString omnijarPath;
|
||||
if (mozilla::OmnijarPath())
|
||||
mozilla::OmnijarPath()->GetNativePath(omnijarPath);
|
||||
newEnvVars["OMNIJAR_PATH"] = omnijarPath.get();
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
@ -280,6 +272,17 @@ GeckoChildProcessHost::PerformAsyncLaunch(std::vector<std::string> aExtraOpts)
|
||||
|
||||
childArgv.insert(childArgv.end(), aExtraOpts.begin(), aExtraOpts.end());
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
// Make sure the child process can find the omnijar
|
||||
// See XRE_InitCommandLine in nsAppRunner.cpp
|
||||
nsCAutoString omnijarPath;
|
||||
if (mozilla::OmnijarPath()) {
|
||||
mozilla::OmnijarPath()->GetNativePath(omnijarPath);
|
||||
childArgv.push_back("-omnijar");
|
||||
childArgv.push_back(omnijarPath.get());
|
||||
}
|
||||
#endif
|
||||
|
||||
childArgv.push_back(pidstring);
|
||||
childArgv.push_back(childProcessType);
|
||||
|
||||
@ -330,6 +333,18 @@ GeckoChildProcessHost::PerformAsyncLaunch(std::vector<std::string> aExtraOpts)
|
||||
}
|
||||
|
||||
cmdLine.AppendLooseValue(std::wstring(mGroupId.get()));
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
// Make sure the child process can find the omnijar
|
||||
// See XRE_InitCommandLine in nsAppRunner.cpp
|
||||
nsAutoString omnijarPath;
|
||||
if (mozilla::OmnijarPath()) {
|
||||
mozilla::OmnijarPath()->GetPath(omnijarPath);
|
||||
cmdLine.AppendLooseValue(UTF8ToWide("-omnijar"));
|
||||
cmdLine.AppendLooseValue(omnijarPath.get());
|
||||
}
|
||||
#endif
|
||||
|
||||
cmdLine.AppendLooseValue(UTF8ToWide(pidstring));
|
||||
cmdLine.AppendLooseValue(UTF8ToWide(childProcessType));
|
||||
#if defined(MOZ_CRASHREPORTER)
|
||||
|
@ -1114,10 +1114,6 @@ ScopedXPCOMStartup::~ScopedXPCOMStartup()
|
||||
|
||||
NS_ShutdownXPCOM(mServiceManager);
|
||||
mServiceManager = nsnull;
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
mozilla::SetOmnijar(nsnull);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -1175,16 +1171,6 @@ ScopedXPCOMStartup::Initialize()
|
||||
NS_ASSERTION(gDirServiceProvider, "Should not get here!");
|
||||
|
||||
nsresult rv;
|
||||
#ifdef MOZ_OMNIJAR
|
||||
nsCOMPtr<nsILocalFile> lf;
|
||||
char *omnijarPath = getenv("OMNIJAR_PATH");
|
||||
if (omnijarPath)
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(omnijarPath), PR_TRUE, getter_AddRefs(lf));
|
||||
else
|
||||
rv = XRE_GetBinaryPath(gArgv[0], getter_AddRefs(lf));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mozilla::SetOmnijar(lf);
|
||||
#endif
|
||||
|
||||
#ifndef MOZ_ENABLE_LIBXUL
|
||||
#ifndef _BUILD_STATIC_BIN
|
||||
@ -3777,16 +3763,6 @@ XRE_InitCommandLine(int aArgc, char* aArgv[])
|
||||
#if defined(OS_WIN)
|
||||
CommandLine::Init(aArgc, aArgv);
|
||||
#else
|
||||
#ifdef MOZ_OMNIJAR
|
||||
nsCOMPtr<nsILocalFile> lf;
|
||||
char *omnijarPath = getenv("OMNIJAR_PATH");
|
||||
if (omnijarPath)
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(omnijarPath), PR_TRUE, getter_AddRefs(lf));
|
||||
else
|
||||
rv = XRE_GetBinaryPath(gArgv[0], getter_AddRefs(lf));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mozilla::SetOmnijar(lf);
|
||||
#endif
|
||||
|
||||
// these leak on error, but that's OK: we'll just exit()
|
||||
char** canonArgs = new char*[aArgc];
|
||||
@ -3818,6 +3794,25 @@ XRE_InitCommandLine(int aArgc, char* aArgv[])
|
||||
delete[] canonArgs;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
const char *omnijarPath = nsnull;
|
||||
ArgResult ar = CheckArg("omnijar", PR_FALSE, &omnijarPath);
|
||||
if (ar == ARG_BAD) {
|
||||
PR_fprintf(PR_STDERR, "Error: argument -omnijar requires an omnijar path\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!omnijarPath)
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsILocalFile> omnijar;
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(omnijarPath), PR_TRUE,
|
||||
getter_AddRefs(omnijar));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mozilla::SetOmnijar(omnijar);
|
||||
#endif
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -45,15 +45,43 @@
|
||||
static nsILocalFile* sOmnijarPath = nsnull;
|
||||
static nsZipArchive* sOmnijarReader = nsnull;
|
||||
|
||||
static void
|
||||
SetupReader()
|
||||
{
|
||||
if (!sOmnijarPath) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsZipArchive* zipReader = new nsZipArchive();
|
||||
if (!zipReader) {
|
||||
NS_IF_RELEASE(sOmnijarPath);
|
||||
return;
|
||||
}
|
||||
|
||||
if (NS_FAILED(zipReader->OpenArchive(sOmnijarPath))) {
|
||||
delete zipReader;
|
||||
NS_IF_RELEASE(sOmnijarPath);
|
||||
return;
|
||||
}
|
||||
|
||||
sOmnijarReader = zipReader;
|
||||
}
|
||||
|
||||
nsILocalFile*
|
||||
mozilla::OmnijarPath()
|
||||
{
|
||||
if (!sOmnijarReader)
|
||||
SetupReader();
|
||||
|
||||
return sOmnijarPath;
|
||||
}
|
||||
|
||||
nsZipArchive*
|
||||
mozilla::OmnijarReader()
|
||||
{
|
||||
if (!sOmnijarReader)
|
||||
SetupReader();
|
||||
|
||||
return sOmnijarReader;
|
||||
}
|
||||
|
||||
@ -67,22 +95,7 @@ mozilla::SetOmnijar(nsILocalFile* aPath)
|
||||
sOmnijarReader = nsnull;
|
||||
}
|
||||
|
||||
if (!aPath) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsZipArchive* zipReader = new nsZipArchive();
|
||||
if (!zipReader) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NS_FAILED(zipReader->OpenArchive(aPath))) {
|
||||
delete zipReader;
|
||||
return;
|
||||
}
|
||||
|
||||
sOmnijarReader = zipReader;
|
||||
sOmnijarPath = aPath;
|
||||
NS_ADDREF(sOmnijarPath);
|
||||
NS_IF_ADDREF(sOmnijarPath);
|
||||
}
|
||||
|
||||
|
@ -142,6 +142,7 @@ extern nsresult nsStringInputStreamConstructor(nsISupports *, REFNSIID, void **)
|
||||
#include <locale.h>
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/FunctionTimer.h"
|
||||
#include "mozilla/Omnijar.h"
|
||||
|
||||
#include "nsChromeRegistry.h"
|
||||
#include "nsChromeProtocolHandler.h"
|
||||
@ -419,6 +420,7 @@ NS_InitXPCOM2(nsIServiceManager* *result,
|
||||
|
||||
NS_StartupNativeCharsetUtils();
|
||||
#endif
|
||||
|
||||
NS_TIME_FUNCTION_MARK("Next: startup local file");
|
||||
|
||||
NS_StartupLocalFile();
|
||||
@ -457,6 +459,26 @@ NS_InitXPCOM2(nsIServiceManager* *result,
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
NS_TIME_FUNCTION_MARK("Next: Omnijar init");
|
||||
|
||||
if (!mozilla::OmnijarPath()) {
|
||||
nsCOMPtr<nsILocalFile> omnijar;
|
||||
nsCOMPtr<nsIFile> file;
|
||||
|
||||
rv = NS_ERROR_FAILURE;
|
||||
nsDirectoryService::gService->Get(NS_GRE_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(file));
|
||||
if (file)
|
||||
rv = file->Append(NS_LITERAL_STRING("omni.jar"));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
omnijar = do_QueryInterface(file);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mozilla::SetOmnijar(omnijar);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
if ((sCommandLineWasInitialized = !CommandLine::IsInitialized())) {
|
||||
NS_TIME_FUNCTION_MARK("Next: IPC command line init");
|
||||
@ -734,6 +756,10 @@ ShutdownXPCOM(nsIServiceManager* servMgr)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
mozilla::SetOmnijar(nsnull);
|
||||
#endif
|
||||
|
||||
NS_LogTerm();
|
||||
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user