Bug 1838629 - Part 7: Inline nursery cell allocation method in Allocator.h r=sfink
[gecko.git] / toolkit / xre / nsAppRunner.h
blob2b0315f3a31b02f35c240e80a08342c9dfb1fe7c
1 /* -*- Mode: C++; tab-width: 2; 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 #ifndef nsAppRunner_h__
7 #define nsAppRunner_h__
9 #ifdef XP_WIN
10 # include <windows.h>
11 # include "mozilla/WindowsConsole.h"
12 #else
13 # include <limits.h>
14 #endif
16 #ifndef MAXPATHLEN
17 # ifdef PATH_MAX
18 # define MAXPATHLEN PATH_MAX
19 # elif defined(_MAX_PATH)
20 # define MAXPATHLEN _MAX_PATH
21 # elif defined(CCHMAXPATH)
22 # define MAXPATHLEN CCHMAXPATH
23 # else
24 # define MAXPATHLEN 1024
25 # endif
26 #endif
28 #include "nsCOMPtr.h"
29 #include "nsStringFwd.h"
30 #include "nsXULAppAPI.h"
32 class nsINativeAppSupport;
33 class nsXREDirProvider;
34 class nsIToolkitProfileService;
35 class nsIFile;
36 class nsIProfileLock;
37 class nsIProfileUnlocker;
38 class nsIFactory;
40 extern nsXREDirProvider* gDirServiceProvider;
42 // NOTE: gAppData will be null in embedded contexts.
43 extern const mozilla::XREAppData* gAppData;
44 extern bool gSafeMode;
45 extern bool gFxREmbedded;
47 extern int gArgc;
48 extern char** gArgv;
49 extern int gRestartArgc;
50 extern char** gRestartArgv;
51 extern bool gRestartedByOS;
52 extern bool gLogConsoleErrors;
53 extern nsString gAbsoluteArgv0Path;
55 extern bool gIsGtest;
57 namespace mozilla {
58 nsresult AppInfoConstructor(const nsID& aIID, void** aResult);
59 } // namespace mozilla
61 // Exported for gtests.
62 void BuildCompatVersion(const char* aAppVersion, const char* aAppBuildID,
63 const char* aToolkitBuildID, nsACString& aBuf);
65 /**
66 * Compares the provided compatibility versions. Returns 0 if they match,
67 * < 0 if the new version is considered an upgrade from the old version and
68 * > 0 if the new version is considered a downgrade from the old version.
70 int32_t CompareCompatVersions(const nsACString& aOldCompatVersion,
71 const nsACString& aNewCompatVersion);
73 /**
74 * Create the nativeappsupport implementation.
76 * @note XPCOMInit has not happened yet.
78 nsresult NS_CreateNativeAppSupport(nsINativeAppSupport** aResult);
79 already_AddRefed<nsINativeAppSupport> NS_GetNativeAppSupport();
81 /**
82 * Try to acquire exclusive access to the specified profile directory.
84 * @param aPath
85 * The profile directory to lock.
86 * @param aTempPath
87 * The corresponding profile temporary directory.
88 * @param aUnlocker
89 * A callback interface used to attempt to unlock a profile that
90 * appears to be locked.
91 * @param aResult
92 * The resulting profile lock object (or null if the profile could
93 * not be locked).
95 * @return NS_ERROR_FILE_ACCESS_DENIED to indicate that the profile
96 * directory cannot be unlocked.
98 nsresult NS_LockProfilePath(nsIFile* aPath, nsIFile* aTempPath,
99 nsIProfileUnlocker** aUnlocker,
100 nsIProfileLock** aResult);
102 void WriteConsoleLog();
104 void OverrideDefaultLocaleIfNeeded();
107 * Allow exit() calls to complete. This should be done from a proper Gecko
108 * shutdown path. Otherwise we aim to catch improper shutdowns.
110 void MozExpectedExit();
112 class nsINativeAppSupport;
114 // If aBlankCommandLine is true, then the application will be launched with a
115 // blank command line instead of being launched with the same command line that
116 // it was initially started with.
117 // If aTryExec is true then we use exec on platforms that support it to
118 // remain in the foreground.
119 nsresult LaunchChild(bool aBlankCommandLine, bool aTryExec = false);
121 void UnlockProfile();
123 #ifdef XP_WIN
125 BOOL WinLaunchChild(const wchar_t* exePath, int argc, char** argv,
126 HANDLE userToken = nullptr, HANDLE* hProcess = nullptr);
128 # define PREF_WIN_REGISTER_APPLICATION_RESTART \
129 "toolkit.winRegisterApplicationRestart"
131 # define PREF_WIN_ALTERED_DLL_PREFETCH "startup.experiments.alteredDllPrefetch"
133 # if defined(MOZ_LAUNCHER_PROCESS)
134 # define PREF_WIN_LAUNCHER_PROCESS_ENABLED "browser.launcherProcess.enabled"
135 # endif // defined(MOZ_LAUNCHER_PROCESS)
136 #endif
138 namespace mozilla {
139 namespace startup {
140 Result<nsCOMPtr<nsIFile>, nsresult> GetIncompleteStartupFile(nsIFile* aProfLD);
142 void IncreaseDescriptorLimits();
143 } // namespace startup
145 const char* PlatformBuildID();
147 bool RunningGTest();
149 } // namespace mozilla
152 * Set up platform specific error handling such as suppressing DLL load dialog
153 * and the JIT debugger on Windows, and install unix signal handlers.
155 void SetupErrorHandling(const char* progname);
157 #ifdef MOZ_ASAN_REPORTER
158 extern "C" {
159 void MOZ_EXPORT __sanitizer_set_report_path(const char* path);
161 void setASanReporterPath(nsIFile* aDir);
162 #endif
164 bool IsWaylandEnabled();
166 #endif // nsAppRunner_h__