1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "mozilla/Bootstrap.h"
9 #include "AutoSQLiteLifetime.h"
11 #ifdef MOZ_WIDGET_ANDROID
12 # ifdef MOZ_PROFILE_GENERATE
13 extern "C" int __llvm_profile_dump(void);
19 class BootstrapImpl final
: public Bootstrap
{
21 AutoSQLiteLifetime mSQLLT
;
23 virtual void Dispose() override
{ delete this; }
26 BootstrapImpl() = default;
28 ~BootstrapImpl() = default;
30 virtual void NS_LogInit() override
{ ::NS_LogInit(); }
32 virtual void NS_LogTerm() override
{ ::NS_LogTerm(); }
34 virtual void XRE_TelemetryAccumulate(int aID
, uint32_t aSample
) override
{
35 ::XRE_TelemetryAccumulate(aID
, aSample
);
38 virtual void XRE_StartupTimelineRecord(int aEvent
,
39 mozilla::TimeStamp aWhen
) override
{
40 ::XRE_StartupTimelineRecord(aEvent
, aWhen
);
43 virtual int XRE_main(int argc
, char* argv
[],
44 const BootstrapConfig
& aConfig
) override
{
45 return ::XRE_main(argc
, argv
, aConfig
);
48 virtual void XRE_StopLateWriteChecks() override
{
49 ::XRE_StopLateWriteChecks();
52 virtual int XRE_XPCShellMain(int argc
, char** argv
, char** envp
,
53 const XREShellData
* aShellData
) override
{
54 return ::XRE_XPCShellMain(argc
, argv
, envp
, aShellData
);
57 virtual GeckoProcessType
XRE_GetProcessType() override
{
58 return ::XRE_GetProcessType();
61 virtual void XRE_SetProcessType(const char* aProcessTypeString
) override
{
62 ::XRE_SetProcessType(aProcessTypeString
);
65 virtual nsresult
XRE_InitChildProcess(
66 int argc
, char* argv
[], const XREChildData
* aChildData
) override
{
67 return ::XRE_InitChildProcess(argc
, argv
, aChildData
);
70 virtual void XRE_EnableSameExecutableForContentProc() override
{
71 ::XRE_EnableSameExecutableForContentProc();
74 #ifdef MOZ_WIDGET_ANDROID
75 virtual void GeckoStart(JNIEnv
* aEnv
, char** argv
, int argc
,
76 const StaticXREAppData
& aAppData
, bool xpcshell
,
77 const char* outFilePath
) override
{
78 ::GeckoStart(aEnv
, argv
, argc
, aAppData
, xpcshell
, outFilePath
);
81 virtual void XRE_SetAndroidChildFds(
82 JNIEnv
* aEnv
, const XRE_AndroidChildFds
& aFds
) override
{
83 ::XRE_SetAndroidChildFds(aEnv
, aFds
);
86 # ifdef MOZ_PROFILE_GENERATE
87 virtual void XRE_WriteLLVMProfData() override
{
88 __android_log_print(ANDROID_LOG_INFO
, "GeckoLibLoad",
89 "Calling __llvm_profile_dump()");
90 __llvm_profile_dump();
96 virtual void XRE_LibFuzzerSetDriver(LibFuzzerDriver aDriver
) override
{
97 ::XRE_LibFuzzerSetDriver(aDriver
);
101 #ifdef MOZ_ENABLE_FORKSERVER
102 virtual int XRE_ForkServer(int* argc
, char*** argv
) override
{
103 return ::XRE_ForkServer(argc
, argv
);
108 extern "C" NS_EXPORT
void NS_FROZENCALL
109 XRE_GetBootstrap(Bootstrap::UniquePtr
& b
) {
110 static bool sBootstrapInitialized
= false;
111 MOZ_RELEASE_ASSERT(!sBootstrapInitialized
);
113 sBootstrapInitialized
= true;
114 b
.reset(new BootstrapImpl());
117 } // namespace mozilla