Files
palemoon27/dom/ipc/ContentProcess.cpp
roytam1 ce2aac9fa1 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1256992 Part 2: Move SandboxBroker Initialization earlier and add telemetry and extra null checks. r=aklotz (acb4442402)
- Bug 1262753: P4. Add resampling capabilities to AudioConverter. r=kinetik (19788419ec)
- Bug 1233921 - Fix profiler crash when we're doing a debugger bailout. r=shu (6400ae545d)
- Bug 1166169 - Add MOZ_GONK_MEDIACODEC in configure and define it in moz.build. r=cpearce, r=glandium (812843d120)
- Bug 1236108: Modify sandbox initialization code to use directory service to obtain content process temp directory; r=bobowen,haik (8779ce1e57)
- Bug 1247832 - Adjust framePushed value in unboxed array baseline IC failure path, r=jandem. (f5914e1df4)
- Bug 1254122 - Don't bother saving scratch registers across TypeUpdate IC calls. (r=jandem) (4aea3f599e)
- Bug 1238815 - Limit baseline script size on ARM. r=jandem (7c13813ac6)
- Bug 1258349 - Remove a bogus assert. r=efaust (36d9edca40)
- Bug 1252903 - Add a missing OOM check in IonBuilder::inlineCalls. r=jonco (d7b146c7ef)
- Bug 1257929 - Instruction Reordering: Do not move instructions above the safeInsertTop location. r=bhackett (b5db952945)
- Bug 1258397 - Reorder Instruction: Renumber all instructions including the entry blocks. r=bhackett (0fe3de3028)
- Bug 1264429 - Trace script pointers in IonCache r=terrence (744354d567)
- Bug 1263558 - Part 0.2: Handle OOM inside SplitCriticalEdges and EliminatePhis at AnalyzeNewScriptDefiniteProperties and AnalyzeArgumentsUsage. r=jandem (8e3bad3c16)
- Bug 1236114 - IonMonkey: Move 'Sink' phase before the 'Remove Unnecessary Bitops' phase. r=sunfish (cbfd51d377)
- Bug 1259476 - Branch Pruning: Check if the Phi nodes have removed uses after popping them out of the worklist. r=jandem (8d5e1dca76)
- Bug 1186006 - Add a copy of the successor resume point to the split-edge blocks. r=bhackett (bf9ff0b37f)
- Bug 1246229 - Enable DCE to remove OSR guards if their values are optimized-out. r=h4writer (610dabfd1f)
- Bug 1247915 - IonMonkey adjustPhiInputs: Handle Phi operands artifact left by removing branches early. r=h4writer (9719e855f0)
- Bug 1258748 - adjustPhiInputs: Add MBox in the predecessor block instead of the definition block. r=jolesen (b0eafd8ff6)
- Bug 1263794 - IonMonkey: Crash when iterating graph and finding a nullptr MDefinition, r=jandem (fb3d0f2868)
- Bug 1257929 - Add assertions to ensure the safety of entry resume point encoding. r=h4writer (34c6410c56)
- Bug 1255949 - Check fallible flag in MBoundsCheck::congruentTo. r=h4writer (2aed033ca0)
- Bug 1240929 - Copy some HTTP request headers automatically on redirect, r=mcmanus (bff8d03edd)
- Bug 1236650 - make h2 push work in the face of redirects. r=mcmanus (9e0cd52a55)
2024-05-07 22:20:46 +08:00

144 lines
4.0 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ipc/IOThreadChild.h"
#include "ContentProcess.h"
#if defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX)
#include "mozilla/WindowsVersion.h"
#endif
#if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX)
#include <stdlib.h>
#endif
#if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX)
#include "mozilla/Preferences.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryService.h"
#include "nsDirectoryServiceDefs.h"
#endif
using mozilla::ipc::IOThreadChild;
namespace mozilla {
namespace dom {
#if defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX)
static bool
IsSandboxTempDirRequired()
{
// On Windows, a sandbox-writable temp directory is only used
// for Vista or later with sandbox pref level >= 1.
return (IsVistaOrLater() &&
(Preferences::GetInt("security.sandbox.content.level") >= 1));
}
static void
SetTmpEnvironmentVariable(nsIFile* aValue)
{
// Save the TMP environment variable so that is is picked up by GetTempPath().
// Note that we specifically write to the TMP variable, as that is the first
// variable that is checked by GetTempPath() to determine its output.
nsAutoString fullTmpPath;
nsresult rv = aValue->GetPath(fullTmpPath);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
NS_WARN_IF(!SetEnvironmentVariableW(L"TMP", fullTmpPath.get()));
// We also set TEMP in case there is naughty third-party code that is
// referencing the environment variable directly.
NS_WARN_IF(!SetEnvironmentVariableW(L"TEMP", fullTmpPath.get()));
}
#endif
#if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX)
static bool
IsSandboxTempDirRequired()
{
// On OSX, use the sandbox-writable temp when the pref level >= 1.
return (Preferences::GetInt("security.sandbox.content.level") >= 1);
}
static void
SetTmpEnvironmentVariable(nsIFile* aValue)
{
nsAutoCString fullTmpPath;
nsresult rv = aValue->GetNativePath(fullTmpPath);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
NS_WARN_IF(setenv("TMPDIR", fullTmpPath.get(), 1) != 0);
}
#endif
#if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX)
static void
SetUpSandboxEnvironment()
{
MOZ_ASSERT(nsDirectoryService::gService,
"SetUpSandboxEnvironment relies on nsDirectoryService being initialized");
if (!IsSandboxTempDirRequired()) {
return;
}
nsCOMPtr<nsIFile> sandboxedContentTemp;
nsresult rv =
nsDirectoryService::gService->Get(NS_APP_CONTENT_PROCESS_TEMP_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(sandboxedContentTemp));
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
// Change the gecko defined temp directory to our sandbox-writable one.
// Undefine returns a failure if the property is not already set.
Unused << nsDirectoryService::gService->Undefine(NS_OS_TEMP_DIR);
rv = nsDirectoryService::gService->Set(NS_OS_TEMP_DIR, sandboxedContentTemp);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
SetTmpEnvironmentVariable(sandboxedContentTemp);
}
#endif
void
ContentProcess::SetAppDir(const nsACString& aPath)
{
mXREEmbed.SetAppDir(aPath);
}
bool
ContentProcess::Init()
{
mContent.Init(IOThreadChild::message_loop(),
ParentPid(),
IOThreadChild::channel());
mXREEmbed.Start();
mContent.InitXPCOM();
mContent.InitGraphicsDeviceData();
#if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX)
SetUpSandboxEnvironment();
#endif
return true;
}
// Note: CleanUp() never gets called in non-debug builds because we exit early
// in ContentChild::ActorDestroy().
void
ContentProcess::CleanUp()
{
mXREEmbed.Stop();
}
} // namespace dom
} // namespace mozilla