Bug 1927641 - Remove Android's Bootstrap::GeckoStart. r=nika

When I wrapped the XRE entry points in the Bootstrap class back in bug
1306327, I didn't think too much about it. Now that I'm looking at the
iOS port, I realize the function doesn't really make much sense, and can
be inlined in its (sole) caller.

Differential Revision: https://phabricator.services.mozilla.com/D227120
This commit is contained in:
Mike Hommey 2024-10-29 21:39:03 +00:00
parent 708e84b19f
commit e182007396
5 changed files with 45 additions and 84 deletions

View File

@ -41,6 +41,7 @@
#include "mozilla/Try.h"
#include "mozilla/UniquePtr.h"
#include "XREChildData.h"
#include "XREShellData.h"
/* Android headers don't define RUSAGE_THREAD */
#ifndef RUSAGE_THREAD
@ -381,15 +382,48 @@ Java_org_mozilla_gecko_mozglue_GeckoLoader_nativeRun(JNIEnv* jenv, jclass jc,
#ifdef MOZ_LINKER
ElfLoader::Singleton.ExpectShutdown(false);
#endif
const char* outFilePathRaw = nullptr;
gBootstrap->XRE_SetGeckoThreadEnv(jenv);
if (!argv) {
__android_log_print(ANDROID_LOG_FATAL, "mozglue",
"Failed to get arguments for %s",
xpcshell ? "XRE_XPCShellMain" : "XRE_main");
return;
}
if (xpcshell) {
MOZ_ASSERT(outFilePath);
outFilePathRaw = jenv->GetStringUTFChars(outFilePath, nullptr);
}
gBootstrap->GeckoStart(jenv, argv, argc, sAppData, xpcshell,
outFilePathRaw);
if (outFilePathRaw) {
jenv->ReleaseStringUTFChars(outFilePath, outFilePathRaw);
const char* outFilePathRaw =
jenv->GetStringUTFChars(outFilePath, nullptr);
FILE* outFile = outFilePathRaw ? fopen(outFilePathRaw, "w") : nullptr;
if (outFile) {
XREShellData shellData;
// We redirect both stdout and stderr to the same file, to conform with
// what runxpcshell.py does on Desktop.
shellData.outFile = outFile;
shellData.errFile = outFile;
int result =
gBootstrap->XRE_XPCShellMain(argc, argv, nullptr, &shellData);
fclose(shellData.outFile);
if (result) {
__android_log_print(ANDROID_LOG_INFO, "mozglue",
"XRE_XPCShellMain returned %d", result);
}
} else {
__android_log_print(ANDROID_LOG_FATAL, "mozglue",
"XRE_XPCShellMain cannot open %s", outFilePathRaw);
}
if (outFilePathRaw) {
jenv->ReleaseStringUTFChars(outFilePath, outFilePathRaw);
}
} else {
BootstrapConfig config;
config.appData = &sAppData;
config.appDataPath = nullptr;
int result = gBootstrap->XRE_main(argc, argv, config);
if (result) {
__android_log_print(ANDROID_LOG_INFO, "mozglue", "XRE_main returned %d",
result);
}
}
#ifdef MOZ_LINKER
ElfLoader::Singleton.ExpectShutdown(true);

View File

@ -13,6 +13,7 @@
#endif // XP_WIN && _M_X64 && MOZ_DIAGNOSTIC_ASSERT_ENABLED
#ifdef MOZ_WIDGET_ANDROID
# include "mozilla/jni/Utils.h"
# ifdef MOZ_PROFILE_GENERATE
extern "C" int __llvm_profile_dump(void);
# endif
@ -68,10 +69,8 @@ class BootstrapImpl final : public Bootstrap {
}
#ifdef MOZ_WIDGET_ANDROID
virtual void GeckoStart(JNIEnv* aEnv, char** argv, int argc,
const StaticXREAppData& aAppData, bool xpcshell,
const char* outFilePath) override {
::GeckoStart(aEnv, argv, argc, aAppData, xpcshell, outFilePath);
virtual void XRE_SetGeckoThreadEnv(JNIEnv* aEnv) override {
mozilla::jni::SetGeckoThreadEnv(aEnv);
}
virtual void XRE_SetAndroidChildFds(JNIEnv* aEnv, jintArray aFds) override {

View File

@ -22,14 +22,6 @@
#ifdef MOZ_WIDGET_ANDROID
# include "jni.h"
namespace mozilla {
struct StaticXREAppData;
}
extern "C" NS_EXPORT void GeckoStart(JNIEnv* aEnv, char** argv, int argc,
const mozilla::StaticXREAppData& aAppData,
bool xpcshell, const char* outFilePath);
#endif
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
@ -109,9 +101,7 @@ class Bootstrap {
virtual void XRE_EnableSameExecutableForContentProc() = 0;
#ifdef MOZ_WIDGET_ANDROID
virtual void GeckoStart(JNIEnv* aEnv, char** argv, int argc,
const StaticXREAppData& aAppData, bool xpcshell,
const char* outFilePath) = 0;
virtual void XRE_SetGeckoThreadEnv(JNIEnv* aEnv) = 0;
virtual void XRE_SetAndroidChildFds(JNIEnv* aEnv, jintArray aFds) = 0;
# ifdef MOZ_PROFILE_GENERATE

View File

@ -124,11 +124,6 @@ if CONFIG["MOZ_X11"]:
"nsX11ErrorHandler.cpp",
]
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
UNIFIED_SOURCES += [
"nsAndroidStartup.cpp",
]
if CONFIG["MOZ_WIDGET_TOOLKIT"] != "android":
UNIFIED_SOURCES += [
"MultiInstanceLock.cpp",

View File

@ -1,57 +0,0 @@
/* -*- Mode: C++; tab-width: 4; 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 <android/log.h>
#include <jni.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "mozilla/jni/Utils.h"
#include "nsTArray.h"
#include "nsString.h"
#include "nsAppRunner.h"
#include "mozilla/Bootstrap.h"
#include "XREShellData.h"
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, MOZ_APP_NAME, args)
using namespace mozilla;
extern "C" NS_EXPORT void GeckoStart(JNIEnv* env, char** argv, int argc,
const StaticXREAppData& aAppData,
bool xpcshell, const char* outFilePath) {
mozilla::jni::SetGeckoThreadEnv(env);
if (!argv) {
LOG("Failed to get arguments for GeckoStart\n");
return;
}
if (xpcshell) {
XREShellData shellData;
FILE* outFile = fopen(outFilePath, "w");
if (!outFile) {
LOG("XRE_XPCShellMain cannot open %s", outFilePath);
return;
}
// We redirect both stdout and stderr to the same file, to conform with
// what runxpcshell.py does on Desktop.
shellData.outFile = outFile;
shellData.errFile = outFile;
int result = XRE_XPCShellMain(argc, argv, nullptr, &shellData);
fclose(shellData.outFile);
if (result) LOG("XRE_XPCShellMain returned %d", result);
} else {
BootstrapConfig config;
config.appData = &aAppData;
config.appDataPath = nullptr;
int result = XRE_main(argc, argv, config);
if (result) LOG("XRE_main returned %d", result);
}
}