/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
nsresult Omnijar::InitOne(nsIFile* aPath, Type aType) {
constexpr auto kOmnijarName = nsLiteralCString{MOZ_STRINGIFY(OMNIJAR_NAME)};
nsCOMPtr<nsIFile> file; if (aPath) {
file = aPath;
} else {
nsCOMPtr<nsIFile> dir;
MOZ_TRY(nsDirectoryService::gService->Get(SPROP(aType), NS_GET_IID(nsIFile),
getter_AddRefs(dir)));
MOZ_TRY(dir->Clone(getter_AddRefs(file)));
MOZ_TRY(file->AppendNative(kOmnijarName));
}
bool isFile = false; if (NS_FAILED(file->IsFile(&isFile)) || !isFile) { // If we're not using an omni.jar for GRE, and we don't have an // omni.jar for APP, check if both directories are the same. if ((aType == APP) && (!sPath[GRE])) {
nsCOMPtr<nsIFile> greDir, appDir; bool equals;
nsDirectoryService::gService->Get(sProp[GRE], NS_GET_IID(nsIFile),
getter_AddRefs(greDir));
nsDirectoryService::gService->Get(sProp[APP], NS_GET_IID(nsIFile),
getter_AddRefs(appDir)); if (NS_SUCCEEDED(greDir->Equals(appDir, &equals)) && equals) {
sIsUnified = true;
}
} return NS_OK;
}
// If we're using omni.jar on both GRE and APP and their path // is the same, we're also in the unified case. bool equals; if ((aType == APP) && (sPath[GRE]) &&
NS_SUCCEEDED(sPath[GRE]->Equals(file, &equals)) && equals) { // If we're using omni.jar on both GRE and APP and their path // is the same, we're in the unified case.
sIsUnified = true; return NS_OK;
}
RefPtr<nsZipArchive> zipReader = nsZipArchive::OpenArchive(file); if (!zipReader) { // As file has been checked to exist as file above, any error indicates // that it is somehow corrupted internally. return NS_ERROR_FILE_CORRUPTED;
}
RefPtr<nsZipArchive> outerReader;
RefPtr<nsZipHandle> handle; // If we find a wrapped OMNIJAR, unwrap it. if (NS_SUCCEEDED(
nsZipHandle::Init(zipReader, kOmnijarName, getter_AddRefs(handle)))) {
outerReader = zipReader;
zipReader = nsZipArchive::OpenArchive(handle); if (!zipReader) { return NS_ERROR_FILE_CORRUPTED;
}
}
nsresult Omnijar::FallibleInit(nsIFile* aGrePath, nsIFile* aAppPath) { // Even on error we do not want to come here again.
sInitialized = true;
// Let's always try to init both before returning any error for the benefit // of callers that do not handle the error at all.
nsresult rvGRE = InitOne(aGrePath, GRE);
nsresult rvAPP = InitOne(aAppPath, APP);
MOZ_TRY(rvGRE);
MOZ_TRY(rvAPP);
// Android builds are always packaged, so if we can't find anything for // greOmni, then this content process is useless, so kill it immediately. // On release, we do this via QuickExit() because the crash volume is so // high. See bug 1915788. if (auto greOmniStr = geckoargs::sGREOmni.Get(aArgc, aArgv)) { if (NS_WARN_IF(NS_FAILED(
XRE_GetFileFromPath(*greOmniStr, getter_AddRefs(greOmni))))) {
ANDROID_DIAGNOSTIC_CRASH_OR_EXIT("XRE_GetFileFromPath failed");
greOmni = nullptr;
}
} else {
ANDROID_DIAGNOSTIC_CRASH_OR_EXIT("sGREOmni.Get failed");
} if (auto appOmniStr = geckoargs::sAppOmni.Get(aArgc, aArgv)) { if (NS_WARN_IF(NS_FAILED(
XRE_GetFileFromPath(*appOmniStr, getter_AddRefs(appOmni))))) {
appOmni = nullptr;
}
}
// If we're unified, then only the -greomni flag is present // (reflecting the state of sPath in the parent process) but that // path should be used for both (not nullptr, which will try to // invoke the directory service, which probably isn't up yet.) if (!appOmni) {
appOmni = greOmni;
}
if (greOmni) {
Init(greOmni, appOmni);
} else { // We should never have an appOmni without a greOmni.
MOZ_ASSERT(!appOmni);
}
}
#undef ANDROID_DIAGNOSTIC_CRASH_OR_EXIT
} /* namespace mozilla */
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.