1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "../contentproc/plugin-container.cpp"
9 #include "mozilla/Bootstrap.h"
11 # include "mozilla/WindowsDllBlocklist.h"
12 #endif // defined(XP_WIN)
14 using namespace mozilla
;
16 static bool UseForkServer(int argc
, char* argv
[]) {
17 #if defined(MOZ_ENABLE_FORKSERVER)
18 return strcmp(argv
[argc
- 1], "forkserver") == 0;
24 static int RunForkServer(Bootstrap::UniquePtr
&& bootstrap
, int argc
,
26 #if defined(MOZ_ENABLE_FORKSERVER)
29 bootstrap
->NS_LogInit();
31 // Run a fork server in this process, single thread. When it
32 // returns, it means the fork server have been stopped or a new
33 // content process is created.
35 // For the later case, XRE_ForkServer() will return false, running
36 // in a content process just forked from the fork server process.
37 // argc & argv will be updated with the values passing from the
38 // chrome process. With the new values, this function
39 // continues the reset of the code acting as a content process.
40 if (bootstrap
->XRE_ForkServer(&argc
, &argv
)) {
41 // Return from the fork server in the fork server process.
42 // Stop the fork server.
44 // In a content process forked from the fork server.
45 // Start acting as a content process.
46 ret
= content_process_main(bootstrap
.get(), argc
, argv
);
49 bootstrap
->NS_LogTerm();
56 int main(int argc
, char* argv
[]) {
57 Bootstrap::UniquePtr bootstrap
= GetBootstrap();
63 if (UseForkServer(argc
, argv
)) {
64 ret
= RunForkServer(std::move(bootstrap
), argc
, argv
);
66 #ifdef HAS_DLL_BLOCKLIST
67 DllBlocklist_Initialize(eDllBlocklistInitFlagIsChildProcess
);
70 ret
= content_process_main(bootstrap
.get(), argc
, argv
);
72 #if defined(DEBUG) && defined(HAS_DLL_BLOCKLIST)
73 DllBlocklist_Shutdown();