Backed out changeset f85447f6f56d (bug 1891145) for causing mochitest failures @...
[gecko.git] / ipc / contentproc / plugin-container.cpp
blob62543f88260542887895a938114a29e6852f4c01
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=4 et :
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 "nsXPCOM.h"
8 #include "nsXULAppAPI.h"
9 #include "mozilla/Bootstrap.h"
10 #include "XREChildData.h"
12 #ifdef XP_WIN
13 # include <windows.h>
14 // we want a wmain entry point
15 # include "nsWindowsWMain.cpp"
16 #else
17 // FIXME/cjones testing
18 # include <unistd.h>
19 #endif
21 #if defined(XP_WIN) && defined(MOZ_SANDBOX)
22 # include "mozilla/sandboxing/SandboxInitialization.h"
23 # include "mozilla/sandboxing/sandboxLogging.h"
24 #endif
26 int content_process_main(mozilla::Bootstrap* bootstrap, int argc,
27 char* argv[]) {
28 // Check for the absolute minimum number of args we need to move
29 // forward here. We expect the last arg to be the child process type.
30 if (argc < 1) {
31 return 3;
34 XREChildData childData;
36 #if defined(XP_WIN) && defined(MOZ_SANDBOX)
37 if (IsSandboxedProcess()) {
38 childData.sandboxTargetServices =
39 mozilla::sandboxing::GetInitializedTargetServices();
40 if (!childData.sandboxTargetServices) {
41 return 1;
44 childData.ProvideLogFunction = mozilla::sandboxing::ProvideLogFunction;
46 #endif
48 bootstrap->XRE_SetProcessType(argv[--argc]);
50 #if defined(XP_WIN) && defined(MOZ_SANDBOX)
51 if (bootstrap->XRE_GetProcessType() == GeckoProcessType_RemoteSandboxBroker) {
52 childData.sandboxBrokerServices =
53 mozilla::sandboxing::GetInitializedBrokerServices();
55 #endif
57 nsresult rv = bootstrap->XRE_InitChildProcess(argc, argv, &childData);
58 return NS_FAILED(rv);