diff options
Diffstat (limited to 'dom/ipc/ContentChild.cpp')
-rw-r--r-- | dom/ipc/ContentChild.cpp | 330 |
1 files changed, 2 insertions, 328 deletions
diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 75678ca96..fc288e2c5 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -11,7 +11,6 @@ #include "ContentChild.h" #include "BlobChild.h" -#include "CrashReporterChild.h" #include "GeckoProfiler.h" #include "TabChild.h" #include "HandlerServiceChild.h" @@ -32,7 +31,6 @@ #include "mozilla/dom/ExternalHelperAppChild.h" #include "mozilla/dom/FlyWebPublishedServerIPC.h" #include "mozilla/dom/GetFilesHelper.h" -#include "mozilla/dom/PCrashReporterChild.h" #include "mozilla/dom/ProcessGlobal.h" #include "mozilla/dom/PushNotifier.h" #include "mozilla/dom/workers/ServiceWorkerManager.h" @@ -65,21 +63,6 @@ #include "imgLoader.h" #include "GMPServiceChild.h" -#if defined(MOZ_CONTENT_SANDBOX) -#if defined(XP_WIN) -#define TARGET_SANDBOX_EXPORTS -#include "mozilla/sandboxTarget.h" -#elif defined(XP_LINUX) -#include "mozilla/Sandbox.h" -#include "mozilla/SandboxInfo.h" - -// Remove this include with Bug 1104619 -#include "CubebUtils.h" -#elif defined(XP_MACOSX) -#include "mozilla/Sandbox.h" -#endif -#endif - #include "mozilla/Unused.h" #include "mozInlineSpellChecker.h" @@ -152,12 +135,6 @@ #include "APKOpen.h" #endif -#if defined(MOZ_WIDGET_GONK) -#include "nsVolume.h" -#include "nsVolumeService.h" -#include "SpeakerManagerService.h" -#endif - #ifdef XP_WIN #include <process.h> #define getpid _getpid @@ -211,9 +188,6 @@ using namespace mozilla::net; using namespace mozilla::jsipc; using namespace mozilla::psm; using namespace mozilla::widget; -#if defined(MOZ_WIDGET_GONK) -using namespace mozilla::system; -#endif using namespace mozilla::widget; namespace mozilla { @@ -559,8 +533,7 @@ ContentChild::Init(MessageLoop* aIOLoop, NS_ASSERTION(!sSingleton, "only one ContentChild per child"); // Once we start sending IPC messages, we need the thread manager to be - // initialized so we can deal with the responses. Do that here before we - // try to construct the crash reporter. + // initialized so we can deal with the responses. Do that here. nsresult rv = nsThreadManager::get().Init(); if (NS_WARN_IF(NS_FAILED(rv))) { return false; @@ -600,15 +573,7 @@ ContentChild::Init(MessageLoop* aIOLoop, void ContentChild::InitProcessAttributes() { -#ifdef MOZ_WIDGET_GONK - if (mIsForApp && !mIsForBrowser) { - SetProcessName(NS_LITERAL_STRING("(Preallocated app)"), false); - } else { - SetProcessName(NS_LITERAL_STRING("Browser"), false); - } -#else SetProcessName(NS_LITERAL_STRING("Web Content"), true); -#endif } void @@ -1250,192 +1215,11 @@ ContentChild::AllocPProcessHangMonitorChild(Transport* aTransport, return CreateHangMonitorChild(aTransport, aOtherProcess); } -#if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX) - -#include <stdlib.h> - -static bool -GetAppPaths(nsCString &aAppPath, nsCString &aAppBinaryPath, nsCString &aAppDir) -{ - nsAutoCString appPath; - nsAutoCString appBinaryPath( - (CommandLine::ForCurrentProcess()->argv()[0]).c_str()); - - nsAutoCString::const_iterator start, end; - appBinaryPath.BeginReading(start); - appBinaryPath.EndReading(end); - if (RFindInReadable(NS_LITERAL_CSTRING(".app/Contents/MacOS/"), start, end)) { - end = start; - ++end; ++end; ++end; ++end; - appBinaryPath.BeginReading(start); - appPath.Assign(Substring(start, end)); - } else { - return false; - } - - nsCOMPtr<nsIFile> app, appBinary; - nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(appPath), - true, getter_AddRefs(app)); - if (NS_FAILED(rv)) { - return false; - } - rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(appBinaryPath), - true, getter_AddRefs(appBinary)); - if (NS_FAILED(rv)) { - return false; - } - - nsCOMPtr<nsIFile> appDir; - nsCOMPtr<nsIProperties> dirSvc = - do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID); - if (!dirSvc) { - return false; - } - rv = dirSvc->Get(NS_XPCOM_CURRENT_PROCESS_DIR, - NS_GET_IID(nsIFile), getter_AddRefs(appDir)); - if (NS_FAILED(rv)) { - return false; - } - bool exists; - rv = appDir->Exists(&exists); - if (NS_FAILED(rv) || !exists) { - return false; - } - - bool isLink; - app->IsSymlink(&isLink); - if (isLink) { - app->GetNativeTarget(aAppPath); - } else { - app->GetNativePath(aAppPath); - } - appBinary->IsSymlink(&isLink); - if (isLink) { - appBinary->GetNativeTarget(aAppBinaryPath); - } else { - appBinary->GetNativePath(aAppBinaryPath); - } - appDir->IsSymlink(&isLink); - if (isLink) { - appDir->GetNativeTarget(aAppDir); - } else { - appDir->GetNativePath(aAppDir); - } - - return true; -} - -static bool -StartMacOSContentSandbox() -{ - int sandboxLevel = Preferences::GetInt("security.sandbox.content.level"); - if (sandboxLevel < 1) { - return false; - } - - nsAutoCString appPath, appBinaryPath, appDir; - if (!GetAppPaths(appPath, appBinaryPath, appDir)) { - MOZ_CRASH("Error resolving child process path"); - } - - // During sandboxed content process startup, before reaching - // this point, NS_OS_TEMP_DIR is modified to refer to a sandbox- - // writable temporary directory - nsCOMPtr<nsIFile> tempDir; - nsresult rv = nsDirectoryService::gService->Get(NS_OS_TEMP_DIR, - NS_GET_IID(nsIFile), getter_AddRefs(tempDir)); - if (NS_FAILED(rv)) { - MOZ_CRASH("Failed to get NS_OS_TEMP_DIR"); - } - - nsAutoCString tempDirPath; - tempDir->Normalize(); - rv = tempDir->GetNativePath(tempDirPath); - if (NS_FAILED(rv)) { - MOZ_CRASH("Failed to get NS_OS_TEMP_DIR path"); - } - - nsCOMPtr<nsIFile> profileDir; - ContentChild::GetSingleton()->GetProfileDir(getter_AddRefs(profileDir)); - nsCString profileDirPath; - if (profileDir) { - rv = profileDir->GetNativePath(profileDirPath); - if (NS_FAILED(rv) || profileDirPath.IsEmpty()) { - MOZ_CRASH("Failed to get profile path"); - } - } - - MacSandboxInfo info; - info.type = MacSandboxType_Content; - info.level = info.level = sandboxLevel; - info.appPath.assign(appPath.get()); - info.appBinaryPath.assign(appBinaryPath.get()); - info.appDir.assign(appDir.get()); - info.appTempDir.assign(tempDirPath.get()); - - if (profileDir) { - info.hasSandboxedProfile = true; - info.profileDir.assign(profileDirPath.get()); - } else { - info.hasSandboxedProfile = false; - } - - std::string err; - if (!mozilla::StartMacSandbox(info, err)) { - NS_WARNING(err.c_str()); - MOZ_CRASH("sandbox_init() failed"); - } - - return true; -} -#endif - bool ContentChild::RecvSetProcessSandbox(const MaybeFileDesc& aBroker) { // We may want to move the sandbox initialization somewhere else // at some point; see bug 880808. -#if defined(MOZ_CONTENT_SANDBOX) - bool sandboxEnabled = true; -#if defined(XP_LINUX) -#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 19 - // For B2G >= KitKat, sandboxing is mandatory; this has already - // been enforced by ContentParent::StartUp(). - MOZ_ASSERT(SandboxInfo::Get().CanSandboxContent()); -#else - // Otherwise, sandboxing is best-effort. - if (!SandboxInfo::Get().CanSandboxContent()) { - sandboxEnabled = false; - } else { - // This triggers the initialization of cubeb, which needs to happen - // before seccomp is enabled (Bug 1259508). It also increases the startup - // time of the content process, because cubeb is usually initialized - // when it is actually needed. This call here is no longer required - // once Bug 1104619 (remoting audio) is resolved. - Unused << CubebUtils::GetCubebContext(); - } - -#endif /* MOZ_WIDGET_GONK && ANDROID_VERSION >= 19 */ - if (sandboxEnabled) { - int brokerFd = -1; - if (aBroker.type() == MaybeFileDesc::TFileDescriptor) { - auto fd = aBroker.get_FileDescriptor().ClonePlatformHandle(); - brokerFd = fd.release(); - // brokerFd < 0 means to allow direct filesystem access, so - // make absolutely sure that doesn't happen if the parent - // didn't intend it. - MOZ_RELEASE_ASSERT(brokerFd >= 0); - } - sandboxEnabled = SetContentProcessSandbox(brokerFd); - } -#elif defined(XP_WIN) - mozilla::SandboxTarget::Instance()->StartSandbox(); -#elif defined(XP_MACOSX) - sandboxEnabled = StartMacOSContentSandbox(); -#endif - -#endif /* MOZ_CONTENT_SANDBOX */ - return true; } @@ -1453,15 +1237,6 @@ ContentChild::RecvNotifyLayerAllocated(const dom::TabId& aTabId, const uint64_t& bool ContentChild::RecvSpeakerManagerNotify() { -#ifdef MOZ_WIDGET_GONK - // Only notify the process which has the SpeakerManager instance. - RefPtr<SpeakerManagerService> service = - SpeakerManagerService::GetSpeakerManagerService(); - if (service) { - service->Notify(); - } - return true; -#endif return false; } @@ -1719,19 +1494,6 @@ ContentChild::RecvNotifyEmptyHTTPCache() return true; } -PCrashReporterChild* -ContentChild::AllocPCrashReporterChild(const mozilla::dom::NativeThreadId& id, - const uint32_t& processType) -{ - return nullptr; -} - -bool -ContentChild::DeallocPCrashReporterChild(PCrashReporterChild* crashreporter) -{ - delete crashreporter; - return true; -} PHalChild* ContentChild::AllocPHalChild() @@ -2480,12 +2242,6 @@ ContentChild::RecvLastPrivateDocShellDestroyed() bool ContentChild::RecvVolumes(nsTArray<VolumeInfo>&& aVolumes) { -#ifdef MOZ_WIDGET_GONK - RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton(); - if (vs) { - vs->RecvVolumesFromParent(aVolumes); - } -#endif return true; } @@ -2502,17 +2258,6 @@ ContentChild::RecvFileSystemUpdate(const nsString& aFsName, const bool& aIsRemovable, const bool& aIsHotSwappable) { -#ifdef MOZ_WIDGET_GONK - RefPtr<nsVolume> volume = new nsVolume(aFsName, aVolumeName, aState, - aMountGeneration, aIsMediaPresent, - aIsSharing, aIsFormatting, aIsFake, - aIsUnmounting, aIsRemovable, aIsHotSwappable); - - RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton(); - if (vs) { - vs->UpdateVolume(volume); - } -#else // Remove warnings about unused arguments Unused << aFsName; Unused << aVolumeName; @@ -2525,22 +2270,15 @@ ContentChild::RecvFileSystemUpdate(const nsString& aFsName, Unused << aIsUnmounting; Unused << aIsRemovable; Unused << aIsHotSwappable; -#endif + return true; } bool ContentChild::RecvVolumeRemoved(const nsString& aFsName) { -#ifdef MOZ_WIDGET_GONK - RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton(); - if (vs) { - vs->RemoveVolumeByName(aFsName); - } -#else // Remove warnings about unused arguments Unused << aFsName; -#endif return true; } @@ -2666,61 +2404,6 @@ ContentChild::DeallocPOfflineCacheUpdateChild(POfflineCacheUpdateChild* actor) } bool -ContentChild::RecvStartProfiler(const ProfilerInitParams& params) -{ - nsTArray<const char*> featureArray; - for (size_t i = 0; i < params.features().Length(); ++i) { - featureArray.AppendElement(params.features()[i].get()); - } - - nsTArray<const char*> threadNameFilterArray; - for (size_t i = 0; i < params.threadFilters().Length(); ++i) { - threadNameFilterArray.AppendElement(params.threadFilters()[i].get()); - } - - profiler_start(params.entries(), params.interval(), - featureArray.Elements(), featureArray.Length(), - threadNameFilterArray.Elements(), - threadNameFilterArray.Length()); - - return true; -} - -bool -ContentChild::RecvStopProfiler() -{ - profiler_stop(); - return true; -} - -bool -ContentChild::RecvPauseProfiler(const bool& aPause) -{ - if (aPause) { - profiler_pause(); - } else { - profiler_resume(); - } - - return true; -} - -bool -ContentChild::RecvGatherProfile() -{ - nsCString profileCString; - UniquePtr<char[]> profile = profiler_get_profile(); - if (profile) { - profileCString = nsCString(profile.get(), strlen(profile.get())); - } else { - profileCString = EmptyCString(); - } - - Unused << SendProfile(profileCString); - return true; -} - -bool ContentChild::RecvLoadPluginResult(const uint32_t& aPluginId, const bool& aResult) { @@ -2874,15 +2557,6 @@ ContentChild::RecvShutdown() GetIPCChannel()->SetAbortOnError(false); -#ifdef MOZ_ENABLE_PROFILER_SPS - if (profiler_is_active()) { - // We're shutting down while we were profiling. Send the - // profile up to the parent so that we don't lose this - // information. - Unused << RecvGatherProfile(); - } -#endif - // Start a timer that will insure we quickly exit after a reasonable // period of time. Prevents shutdown hangs after our connection to the // parent closes. |