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/. */
5
6 #include "mozilla/Bootstrap.h"
7 #include "nsXPCOM.h"
8
9 #include "AutoSQLiteLifetime.h"
10
11 #ifdef MOZ_WIDGET_ANDROID
12 # ifdef MOZ_PROFILE_GENERATE
13 extern "C" int __llvm_profile_dump(void);
14 # endif
15 #endif
16
17 namespace mozilla {
18
19 class BootstrapImpl final : public Bootstrap {
20 protected:
21 AutoSQLiteLifetime mSQLLT;
22
Dispose()23 virtual void Dispose() override { delete this; }
24
25 public:
26 BootstrapImpl() = default;
27
28 ~BootstrapImpl() = default;
29
NS_LogInit()30 virtual void NS_LogInit() override { ::NS_LogInit(); }
31
NS_LogTerm()32 virtual void NS_LogTerm() override { ::NS_LogTerm(); }
33
XRE_TelemetryAccumulate(int aID,uint32_t aSample)34 virtual void XRE_TelemetryAccumulate(int aID, uint32_t aSample) override {
35 ::XRE_TelemetryAccumulate(aID, aSample);
36 }
37
XRE_StartupTimelineRecord(int aEvent,mozilla::TimeStamp aWhen)38 virtual void XRE_StartupTimelineRecord(int aEvent,
39 mozilla::TimeStamp aWhen) override {
40 ::XRE_StartupTimelineRecord(aEvent, aWhen);
41 }
42
XRE_main(int argc,char * argv[],const BootstrapConfig & aConfig)43 virtual int XRE_main(int argc, char* argv[],
44 const BootstrapConfig& aConfig) override {
45 return ::XRE_main(argc, argv, aConfig);
46 }
47
XRE_StopLateWriteChecks()48 virtual void XRE_StopLateWriteChecks() override {
49 ::XRE_StopLateWriteChecks();
50 }
51
XRE_XPCShellMain(int argc,char ** argv,char ** envp,const XREShellData * aShellData)52 virtual int XRE_XPCShellMain(int argc, char** argv, char** envp,
53 const XREShellData* aShellData) override {
54 return ::XRE_XPCShellMain(argc, argv, envp, aShellData);
55 }
56
XRE_GetProcessType()57 virtual GeckoProcessType XRE_GetProcessType() override {
58 return ::XRE_GetProcessType();
59 }
60
XRE_SetProcessType(const char * aProcessTypeString)61 virtual void XRE_SetProcessType(const char* aProcessTypeString) override {
62 ::XRE_SetProcessType(aProcessTypeString);
63 }
64
XRE_InitChildProcess(int argc,char * argv[],const XREChildData * aChildData)65 virtual nsresult XRE_InitChildProcess(
66 int argc, char* argv[], const XREChildData* aChildData) override {
67 return ::XRE_InitChildProcess(argc, argv, aChildData);
68 }
69
XRE_EnableSameExecutableForContentProc()70 virtual void XRE_EnableSameExecutableForContentProc() override {
71 ::XRE_EnableSameExecutableForContentProc();
72 }
73
74 #ifdef MOZ_WIDGET_ANDROID
GeckoStart(JNIEnv * aEnv,char ** argv,int argc,const StaticXREAppData & aAppData,bool xpcshell,const char * outFilePath)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);
79 }
80
XRE_SetAndroidChildFds(JNIEnv * aEnv,const XRE_AndroidChildFds & aFds)81 virtual void XRE_SetAndroidChildFds(
82 JNIEnv* aEnv, const XRE_AndroidChildFds& aFds) override {
83 ::XRE_SetAndroidChildFds(aEnv, aFds);
84 }
85
86 # ifdef MOZ_PROFILE_GENERATE
XRE_WriteLLVMProfData()87 virtual void XRE_WriteLLVMProfData() override {
88 __android_log_print(ANDROID_LOG_INFO, "GeckoLibLoad",
89 "Calling __llvm_profile_dump()");
90 __llvm_profile_dump();
91 }
92 # endif
93 #endif
94
95 #ifdef LIBFUZZER
XRE_LibFuzzerSetDriver(LibFuzzerDriver aDriver)96 virtual void XRE_LibFuzzerSetDriver(LibFuzzerDriver aDriver) override {
97 ::XRE_LibFuzzerSetDriver(aDriver);
98 }
99 #endif
100
101 #ifdef MOZ_ENABLE_FORKSERVER
XRE_ForkServer(int * argc,char *** argv)102 virtual int XRE_ForkServer(int* argc, char*** argv) override {
103 return ::XRE_ForkServer(argc, argv);
104 }
105 #endif
106 };
107
108 extern "C" NS_EXPORT void NS_FROZENCALL
XRE_GetBootstrap(Bootstrap::UniquePtr & b)109 XRE_GetBootstrap(Bootstrap::UniquePtr& b) {
110 static bool sBootstrapInitialized = false;
111 MOZ_RELEASE_ASSERT(!sBootstrapInitialized);
112
113 sBootstrapInitialized = true;
114 b.reset(new BootstrapImpl());
115 }
116
117 } // namespace mozilla
118