--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -7912,17 +7912,17 @@ StyleDataTypesWithNode(nsINode* aNode)
static void
CheckCrossStyleBackendAdoption(nsIDocument* aOldDoc,
nsIDocument* aNewDoc, nsINode* aAdoptedNode)
{
EnumSet<StyleDataType> styleDataTypes = StyleDataTypesWithNode(aAdoptedNode);
if (styleDataTypes.isEmpty()) {
return;
}
-#ifdef MOZ_CRASHREPORTER
+
// We are adopting node with pre-existing style data across style
// backend. We want some more information to help diagnose when that
// can happen.
nsAutoCString note;
nsIDocument* geckoDoc;
if (aOldDoc->GetStyleBackendType() == StyleBackendType::Servo) {
note.AppendLiteral("Servo -> Gecko");
geckoDoc = aNewDoc;
@@ -7977,17 +7977,17 @@ CheckCrossStyleBackendAdoption(nsIDocume
nsAutoCString scheme;
geckoURI->GetScheme(scheme);
note.Append(scheme);
note.AppendLiteral(": (omitted)");
}
}
note.Append('\n');
CrashReporter::AppendAppNotesToCrashReport(note);
-#endif // MOZ_CRASHREPORTER
+
MOZ_CRASH("Must not adopt a node with pre-existing style data "
"into a document with different style backend");
}
nsINode*
nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv)
{
nsINode* adoptedNode = &aAdoptedNode;
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -207,33 +207,31 @@
#include "ClearOnShutdown.h"
#include "ProcessUtils.h"
#include "URIUtils.h"
#include "nsContentUtils.h"
#include "nsIPrincipal.h"
#include "DomainPolicy.h"
#include "mozilla/dom/ipc/StructuredCloneData.h"
#include "mozilla/dom/time/DateCacheCleaner.h"
+#include "mozilla/ipc/CrashReporterClient.h"
#include "mozilla/net/NeckoMessageUtils.h"
#include "mozilla/widget/PuppetBidiKeyboard.h"
#include "mozilla/RemoteSpellCheckEngineChild.h"
#include "GMPServiceChild.h"
#include "GfxInfoBase.h"
#include "gfxPlatform.h"
#include "nscore.h" // for NS_FREE_PERMANENT_DATA
#include "VRManagerChild.h"
#include "private/pprio.h"
#include "nsString.h"
#ifdef MOZ_WIDGET_GTK
#include "nsAppRunner.h"
#endif
-#ifdef MOZ_CRASHREPORTER
-#include "mozilla/ipc/CrashReporterClient.h"
-#endif
#ifdef MOZ_CODE_COVERAGE
#include "mozilla/CodeCoverageHandler.h"
#endif
using namespace mozilla;
using namespace mozilla::docshell;
using namespace mozilla::dom::ipc;
@@ -634,19 +632,17 @@ ContentChild::Init(MessageLoop* aIOLoop,
if (!gfxPlatform::IsHeadless()) {
// Send the parent our X socket to act as a proxy reference for our X
// resources.
int xSocketFd = ConnectionNumber(DefaultXDisplay());
SendBackUpXResources(FileDescriptor(xSocketFd));
}
#endif
-#ifdef MOZ_CRASHREPORTER
CrashReporterClient::InitSingleton(this);
-#endif
mID = aChildID;
mIsForBrowser = aIsForBrowser;
#ifdef NS_PRINTING
// Force the creation of the nsPrintingProxy so that it's IPC counterpart,
// PrintingParent, is always available for printing initiated from the parent.
RefPtr<nsPrintingProxy> printingProxy = nsPrintingProxy::GetInstance();
@@ -1688,30 +1684,28 @@ ContentChild::RecvSetProcessSandbox(cons
syscallWhitelist);
}
#elif defined(XP_WIN)
mozilla::SandboxTarget::Instance()->StartSandbox();
#elif defined(XP_MACOSX)
sandboxEnabled = StartMacOSContentSandbox();
#endif
-#if defined(MOZ_CRASHREPORTER)
CrashReporter::AnnotateCrashReport(
NS_LITERAL_CSTRING("ContentSandboxEnabled"),
sandboxEnabled? NS_LITERAL_CSTRING("1") : NS_LITERAL_CSTRING("0"));
#if defined(XP_LINUX) && !defined(OS_ANDROID)
nsAutoCString flagsString;
flagsString.AppendInt(SandboxInfo::Get().AsInteger());
CrashReporter::AnnotateCrashReport(
NS_LITERAL_CSTRING("ContentSandboxCapabilities"), flagsString);
#endif /* XP_LINUX && !OS_ANDROID */
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("RemoteType"),
NS_ConvertUTF16toUTF8(GetRemoteType()));
-#endif /* MOZ_CRASHREPORTER */
#endif /* MOZ_CONTENT_SANDBOX */
return IPC_OK();
}
mozilla::ipc::IPCResult
ContentChild::RecvBidiKeyboardNotify(const bool& aIsLangRTL,
const bool& aHaveBidiKeyboards)
@@ -2336,19 +2330,18 @@ ContentChild::ActorDestroy(ActorDestroyR
nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
if (svc) {
svc->UnregisterListener(mConsoleListener);
mConsoleListener->mChild = nullptr;
}
mIsAlive = false;
-# ifdef MOZ_CRASHREPORTER
CrashReporterClient::DestroySingleton();
-# endif
+
XRE_ShutdownChildProcess();
#endif // NS_FREE_PERMANENT_DATA
}
void
ContentChild::ProcessingError(Result aCode, const char* aReason)
{
switch (aCode) {
@@ -2363,20 +2356,19 @@ ContentChild::ProcessingError(Result aCo
case MsgRouteError:
case MsgValueError:
break;
default:
MOZ_CRASH("not reached");
}
-#if defined(MOZ_CRASHREPORTER)
nsDependentCString reason(aReason);
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ipc_channel_error"), reason);
-#endif
+
MOZ_CRASH("Content child abort due to IPC error");
}
nsresult
ContentChild::AddRemoteAlertObserver(const nsString& aData,
nsIObserver* aObserver)
{
NS_ASSERTION(aObserver, "Adding a null observer?");
@@ -2939,20 +2931,19 @@ ContentChild::ForceKillTimerCallback(nsI
mozilla::ipc::IPCResult
ContentChild::RecvShutdown()
{
// If we receive the shutdown message from within a nested event loop, we want
// to wait for that event loop to finish. Otherwise we could prematurely
// terminate an "unload" or "pagehide" event handler (which might be doing a
// sync XHR, for example).
-#if defined(MOZ_CRASHREPORTER)
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCShutdownState"),
NS_LITERAL_CSTRING("RecvShutdown"));
-#endif
+
MOZ_ASSERT(NS_IsMainThread());
RefPtr<nsThread> mainThread = nsThreadManager::get().GetCurrentThread();
// Note that we only have to check the recursion count for the current
// cooperative thread. Since the Shutdown message is not labeled with a
// SchedulerGroup, there can be no other cooperative threads doing work while
// we're running.
if (mainThread && mainThread->RecursionDepth() > 1) {
// We're in a nested event loop. Let's delay for an arbitrary period of
@@ -2998,28 +2989,23 @@ ContentChild::RecvShutdown()
}
#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.
StartForceKillTimer();
-#if defined(MOZ_CRASHREPORTER)
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCShutdownState"),
NS_LITERAL_CSTRING("SendFinishShutdown (sending)"));
bool sent = SendFinishShutdown();
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCShutdownState"),
sent ? NS_LITERAL_CSTRING("SendFinishShutdown (sent)")
: NS_LITERAL_CSTRING("SendFinishShutdown (failed)"));
-#else
- // Ignore errors here. If this fails, the parent will kill us after a
- // timeout.
- Unused << SendFinishShutdown();
-#endif
+
return IPC_OK();
}
PBrowserOrId
ContentChild::GetBrowserOrId(TabChild* aTabChild)
{
if (!aTabChild ||
this == aTabChild->Manager()) {
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -60,16 +60,17 @@
#include "mozilla/dom/URLClassifierParent.h"
#include "mozilla/embedding/printingui/PrintingParent.h"
#include "mozilla/extensions/StreamFilterParent.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/gfx/GPUProcessManager.h"
#include "mozilla/hal_sandbox/PHalParent.h"
#include "mozilla/ipc/BackgroundChild.h"
#include "mozilla/ipc/BackgroundParent.h"
+#include "mozilla/ipc/CrashReporterHost.h"
#include "mozilla/ipc/FileDescriptorUtils.h"
#include "mozilla/ipc/PChildToParentStreamParent.h"
#include "mozilla/ipc/TestShellParent.h"
#include "mozilla/ipc/IPCStreamUtils.h"
#include "mozilla/intl/LocaleService.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "mozilla/layers/PAPZParent.h"
#include "mozilla/layers/CompositorThread.h"
@@ -143,16 +144,17 @@
#include "nsISupportsPrimitives.h"
#include "nsITimer.h"
#include "nsIURIFixup.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIXULWindow.h"
#include "nsIDOMChromeWindow.h"
#include "nsIWindowWatcher.h"
#include "nsPIWindowWatcher.h"
+#include "nsThread.h"
#include "nsWindowWatcher.h"
#include "nsIXULRuntime.h"
#include "mozilla/dom/nsMixedContentBlocker.h"
#include "nsMemoryInfoDumper.h"
#include "nsMemoryReporterManager.h"
#include "nsServiceManagerUtils.h"
#include "nsStyleSheetService.h"
#include "nsThreadUtils.h"
@@ -240,21 +242,16 @@
#include "nsIBrowserSearchService.h"
#endif
#ifdef XP_WIN
#include "mozilla/audio/AudioNotificationSender.h"
#include "mozilla/widget/AudioSession.h"
#endif
-#ifdef MOZ_CRASHREPORTER
-#include "nsThread.h"
-#include "mozilla/ipc/CrashReporterHost.h"
-#endif
-
#ifdef ACCESSIBILITY
#include "nsAccessibilityService.h"
#endif
#ifdef MOZ_GECKO_PROFILER
#include "nsIProfiler.h"
#include "ProfilerParent.h"
#endif
@@ -265,19 +262,17 @@
// For VP9Benchmark::sBenchmarkFpsPref
#include "Benchmark.h"
static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
using base::KillProcess;
-#ifdef MOZ_CRASHREPORTER
using namespace CrashReporter;
-#endif
using namespace mozilla::dom::power;
using namespace mozilla::media;
using namespace mozilla::embedding;
using namespace mozilla::gfx;
using namespace mozilla::gmp;
using namespace mozilla::hal;
using namespace mozilla::ipc;
using namespace mozilla::intl;
@@ -1718,34 +1713,32 @@ ContentParent::ActorDestroy(ActorDestroy
props->SetPropertyAsUint64(NS_LITERAL_STRING("childID"), mChildID);
if (AbnormalShutdown == why) {
Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT,
NS_LITERAL_CSTRING("content"), 1);
props->SetPropertyAsBool(NS_LITERAL_STRING("abnormal"), true);
-#ifdef MOZ_CRASHREPORTER
// There's a window in which child processes can crash
// after IPC is established, but before a crash reporter
// is created.
if (mCrashReporter) {
// if mCreatedPairedMinidumps is true, we've already generated
// parent/child dumps for desktop crashes.
if (!mCreatedPairedMinidumps) {
mCrashReporter->GenerateCrashReport(OtherPid());
}
nsAutoString dumpID;
if (mCrashReporter->HasMinidump()) {
dumpID = mCrashReporter->MinidumpID();
}
props->SetPropertyAsAString(NS_LITERAL_STRING("dumpID"), dumpID);
}
-#endif
}
nsAutoString cpId;
cpId.AppendInt(static_cast<uint64_t>(this->ChildID()));
obs->NotifyObservers((nsIPropertyBag2*) props, "ipc:content-shutdown", cpId.get());
}
// Remove any and all idle listeners.
nsCOMPtr<nsIIdleService> idleService =
@@ -3039,17 +3032,16 @@ ContentParent::KillHard(const char* aRea
// process handle becomes invalid on the first call, causing a second call
// to crash our process - more details in bug 890840.
if (mCalledKillHard) {
return;
}
mCalledKillHard = true;
mForceKillTimer = nullptr;
-#if defined(MOZ_CRASHREPORTER)
// We're about to kill the child process associated with this content.
// Something has gone wrong to get us here, so we generate a minidump
// of the parent and child for submission to the crash server.
if (mCrashReporter) {
// GeneratePairedMinidump creates two minidumps for us - the main
// one is for the content process we're about to kill, and the other
// one is for the main browser process. That second one is the extra
// minidump tagging along, so we have to tell the crash reporter that
@@ -3072,29 +3064,27 @@ ContentParent::KillHard(const char* aRea
// Generate the report and insert into the queue for submittal.
mCrashReporter->GenerateMinidumpAndPair(Process(),
nullptr,
NS_LITERAL_CSTRING("browser"),
Move(callback),
true);
return;
}
-#endif
+
OnGenerateMinidumpComplete(false);
}
void
ContentParent::OnGenerateMinidumpComplete(bool aDumpResult)
{
-#if defined(MOZ_CRASHREPORTER)
if (mCrashReporter && aDumpResult) {
// CrashReporterHost::GenerateMinidumpAndPair() is successful.
mCreatedPairedMinidumps = mCrashReporter->FinalizeCrashReport();
}
-#endif
Unused << aDumpResult; // Don't care about result if no minidump was requested.
ProcessHandle otherProcessHandle;
if (!base::OpenProcessHandle(OtherPid(), &otherProcessHandle)) {
NS_ERROR("Failed to open child process when attempting kill.");
return;
}
@@ -3125,22 +3115,21 @@ ContentParent::FriendlyName(nsAString& a
} else {
aName.AssignLiteral("???");
}
}
mozilla::ipc::IPCResult
ContentParent::RecvInitCrashReporter(Shmem&& aShmem, const NativeThreadId& aThreadId)
{
-#ifdef MOZ_CRASHREPORTER
mCrashReporter = MakeUnique<CrashReporterHost>(
GeckoProcessType_Content,
aShmem,
aThreadId);
-#endif
+
return IPC_OK();
}
hal_sandbox::PHalParent*
ContentParent::AllocPHalParent()
{
return hal_sandbox::CreateHalParent();
}
@@ -4915,19 +4904,17 @@ ContentParent::RecvNotifyPushSubscriptio
mozilla::ipc::IPCResult
ContentParent::RecvNotifyLowMemory()
{
MarkAsTroubled();
Telemetry::ScalarAdd(Telemetry::ScalarID::DOM_CONTENTPROCESS_TROUBLED_DUE_TO_MEMORY, 1);
-#ifdef MOZ_CRASHREPORTER
nsThread::SaveMemoryReportNearOOM(nsThread::ShouldSaveMemoryReport::kForceReport);
-#endif
return IPC_OK();
}
/* static */ void
ContentParent::BroadcastBlobURLRegistration(const nsACString& aURI,
BlobImpl* aBlobImpl,
nsIPrincipal* aPrincipal,
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -1270,19 +1270,18 @@ private:
// This hashtable is used to run GetFilesHelper objects in the parent process.
// GetFilesHelper can be aborted by receiving RecvDeleteGetFilesRequest.
nsRefPtrHashtable<nsIDHashKey, GetFilesHelper> mGetFilesPendingRequests;
nsTHashtable<nsCStringHashKey> mActivePermissionKeys;
nsTArray<nsCString> mBlobURLs;
-#ifdef MOZ_CRASHREPORTER
+
UniquePtr<mozilla::ipc::CrashReporterHost> mCrashReporter;
-#endif
static uint64_t sNextTabParentId;
static nsDataHashtable<nsUint64HashKey, TabParent*> sNextTabParents;
};
} // namespace dom
} // namespace mozilla
--- a/dom/ipc/ProcessHangMonitor.cpp
+++ b/dom/ipc/ProcessHangMonitor.cpp
@@ -19,24 +19,22 @@
#include "mozilla/dom/TabParent.h"
#include "mozilla/ipc/TaskFactory.h"
#include "mozilla/Monitor.h"
#include "mozilla/plugins/PluginBridge.h"
#include "mozilla/Preferences.h"
#include "mozilla/Unused.h"
#include "mozilla/WeakPtr.h"
+#include "nsExceptionHandler.h"
#include "nsIFrameLoader.h"
#include "nsIHangReport.h"
#include "nsITabParent.h"
#include "nsPluginHost.h"
#include "nsThreadUtils.h"
-#ifdef MOZ_CRASHREPORTER
-#include "nsExceptionHandler.h"
-#endif
#include "base/task.h"
#include "base/thread.h"
#ifdef XP_WIN
// For IsDebuggerPresent()
#include <windows.h>
#endif
@@ -606,26 +604,24 @@ HangMonitorParent::HangMonitorParent(Pro
sInited = true;
Preferences::AddBoolVarCache(&sShouldForcePaint,
"browser.tabs.remote.force-paint", true);
}
}
HangMonitorParent::~HangMonitorParent()
{
-#ifdef MOZ_CRASHREPORTER
MutexAutoLock lock(mBrowserCrashDumpHashLock);
for (auto iter = mBrowserCrashDumpIds.Iter(); !iter.Done(); iter.Next()) {
nsString crashId = iter.UserData();
if (!crashId.IsEmpty()) {
CrashReporter::DeleteMinidumpFilesForID(crashId);
}
}
-#endif
}
void
HangMonitorParent::Shutdown()
{
MOZ_RELEASE_ASSERT(NS_IsMainThread());
MonitorAutoLock lock(mMonitor);
@@ -768,33 +764,31 @@ HangMonitorParent::ClearHangNotification
// Take a minidump of the browser process if one wasn't already taken for the
// plugin that caused the hang. Return false if a dump was already available or
// true if new one has been taken.
bool
HangMonitorParent::TakeBrowserMinidump(const PluginHangData& aPhd,
nsString& aCrashId)
{
-#ifdef MOZ_CRASHREPORTER
MutexAutoLock lock(mBrowserCrashDumpHashLock);
if (!mBrowserCrashDumpIds.Get(aPhd.pluginId(), &aCrashId)) {
nsCOMPtr<nsIFile> browserDump;
if (CrashReporter::TakeMinidump(getter_AddRefs(browserDump), true)) {
if (!CrashReporter::GetIDFromMinidump(browserDump, aCrashId)
|| aCrashId.IsEmpty()) {
browserDump->Remove(false);
NS_WARNING("Failed to generate timely browser stack, "
"this is bad for plugin hang analysis!");
} else {
mBrowserCrashDumpIds.Put(aPhd.pluginId(), aCrashId);
return true;
}
}
}
-#endif // MOZ_CRASHREPORTER
return false;
}
mozilla::ipc::IPCResult
HangMonitorParent::RecvHangEvidence(const HangData& aHangData)
{
// chrome process, background thread
@@ -887,21 +881,20 @@ void
HangMonitorParent::CleanupPluginHang(uint32_t aPluginId, bool aRemoveFiles)
{
MutexAutoLock lock(mBrowserCrashDumpHashLock);
nsAutoString crashId;
if (!mBrowserCrashDumpIds.Get(aPluginId, &crashId)) {
return;
}
mBrowserCrashDumpIds.Remove(aPluginId);
-#ifdef MOZ_CRASHREPORTER
+
if (aRemoveFiles && !crashId.IsEmpty()) {
CrashReporter::DeleteMinidumpFilesForID(crashId);
}
-#endif
}
void
HangMonitorParent::UpdateMinidump(uint32_t aPluginId, const nsString& aDumpId)
{
if (aDumpId.IsEmpty()) {
return;
}
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -54,19 +54,17 @@
#include "mozilla/TouchEvents.h"
#include "mozilla/Unused.h"
#include "nsContentUtils.h"
#include "nsCSSFrameConstructor.h"
#include "nsDocShell.h"
#include "nsEmbedCID.h"
#include "nsGlobalWindow.h"
#include <algorithm>
-#ifdef MOZ_CRASHREPORTER
#include "nsExceptionHandler.h"
-#endif
#include "nsFilePickerProxy.h"
#include "mozilla/dom/Element.h"
#include "nsGlobalWindow.h"
#include "nsIBaseWindow.h"
#include "nsIBrowserDOMWindow.h"
#include "nsIDocumentInlines.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIDOMChromeWindow.h"
@@ -1166,19 +1164,17 @@ TabChild::RecvLoadURL(const nsCString& a
WebNavigation()->LoadURI(NS_ConvertUTF8toUTF16(aURI).get(),
nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL,
nullptr, nullptr, nullptr, nsContentUtils::GetSystemPrincipal());
if (NS_FAILED(rv)) {
NS_WARNING("WebNavigation()->LoadURI failed. Eating exception, what else can I do?");
}
-#ifdef MOZ_CRASHREPORTER
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("URL"), aURI);
-#endif
return IPC_OK();
}
void
TabChild::DoFakeShow(const TextureFactoryIdentifier& aTextureFactoryIdentifier,
const uint64_t& aLayersId,
const CompositorOptions& aCompositorOptions,
--- a/dom/ipc/TabMessageUtils.h
+++ b/dom/ipc/TabMessageUtils.h
@@ -3,41 +3,33 @@
/* 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/. */
#ifndef TABMESSAGE_UTILS_H
#define TABMESSAGE_UTILS_H
#include "ipc/IPCMessageUtils.h"
+#include "nsExceptionHandler.h"
#include "nsIDOMEvent.h"
#include "nsPIDOMWindow.h"
#include "nsCOMPtr.h"
-#ifdef MOZ_CRASHREPORTER
-#include "nsExceptionHandler.h"
-#endif
-
namespace mozilla {
namespace dom {
struct RemoteDOMEvent
{
// Make sure to set the owner after deserializing.
nsCOMPtr<nsIDOMEvent> mEvent;
};
bool ReadRemoteEvent(const IPC::Message* aMsg, PickleIterator* aIter,
mozilla::dom::RemoteDOMEvent* aResult);
-#ifdef MOZ_CRASHREPORTER
typedef CrashReporter::ThreadId NativeThreadId;
-#else
-// unused in this case
-typedef int32_t NativeThreadId;
-#endif
} // namespace dom
} // namespace mozilla
namespace IPC {
template<>
struct ParamTraits<mozilla::dom::RemoteDOMEvent>
--- a/dom/media/gmp/GMPChild.cpp
+++ b/dom/media/gmp/GMPChild.cpp
@@ -241,19 +241,17 @@ GMPChild::Init(const nsAString& aPluginP
IPC::Channel* aChannel)
{
LOGD("%s pluginPath=%s", __FUNCTION__, NS_ConvertUTF16toUTF8(aPluginPath).get());
if (NS_WARN_IF(!Open(aChannel, aParentPid, aIOLoop))) {
return false;
}
-#ifdef MOZ_CRASHREPORTER
CrashReporterClient::InitSingleton(this);
-#endif
mPluginPath = aPluginPath;
return true;
}
GMPErr
GMPChild::GetAPI(const char* aAPIName,
@@ -612,19 +610,18 @@ GMPChild::ActorDestroy(ActorDestroyReaso
if (mGMPLoader) {
mGMPLoader->Shutdown();
}
if (AbnormalShutdown == aWhy) {
NS_WARNING("Abnormal shutdown of GMP process!");
ProcessChild::QuickExit();
}
-#ifdef MOZ_CRASHREPORTER
CrashReporterClient::DestroySingleton();
-#endif
+
XRE_ShutdownChildProcess();
}
void
GMPChild::ProcessingError(Result aCode, const char* aReason)
{
switch (aCode) {
case MsgDropped:
--- a/dom/media/gmp/GMPParent.cpp
+++ b/dom/media/gmp/GMPParent.cpp
@@ -2,43 +2,41 @@
/* 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 "GMPParent.h"
#include "mozilla/Logging.h"
#include "nsComponentManagerUtils.h"
#include "nsComponentManagerUtils.h"
+#include "nsPrintfCString.h"
#include "nsThreadUtils.h"
#include "nsIRunnable.h"
#include "nsIWritablePropertyBag2.h"
#include "mozIGeckoMediaPluginService.h"
#include "mozilla/AbstractThread.h"
+#include "mozilla/ipc/CrashReporterHost.h"
#include "mozilla/ipc/GeckoChildProcessHost.h"
#include "mozilla/SSE.h"
#include "mozilla/SyncRunnable.h"
#include "mozilla/Unused.h"
#include "nsIObserverService.h"
#include "GMPTimerParent.h"
#include "runnable_utils.h"
#if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
#include "mozilla/SandboxInfo.h"
#endif
#include "GMPContentParent.h"
#include "MediaPrefs.h"
#include "VideoUtils.h"
using mozilla::ipc::GeckoChildProcessHost;
-#ifdef MOZ_CRASHREPORTER
-#include "nsPrintfCString.h"
-#include "mozilla/ipc/CrashReporterHost.h"
using CrashReporter::AnnotationTable;
using CrashReporter::GetIDFromMinidump;
-#endif
#include "mozilla/Telemetry.h"
#ifdef XP_WIN
#include "WMFDecoderModule.h"
#endif
#include "mozilla/dom/WidevineCDMManifestBinding.h"
@@ -447,17 +445,16 @@ GMPParent::EnsureProcessLoaded()
return false;
}
nsresult rv = LoadProcess();
return NS_SUCCEEDED(rv);
}
-#ifdef MOZ_CRASHREPORTER
void
GMPParent::WriteExtraDataForMinidump()
{
mCrashReporter->AddNote(NS_LITERAL_CSTRING("GMPPlugin"), NS_LITERAL_CSTRING("1"));
mCrashReporter->AddNote(NS_LITERAL_CSTRING("PluginFilename"), NS_ConvertUTF16toUTF8(mName));
mCrashReporter->AddNote(NS_LITERAL_CSTRING("PluginName"), mDisplayName);
mCrashReporter->AddNote(NS_LITERAL_CSTRING("PluginVersion"), mVersion);
}
@@ -492,39 +489,39 @@ GMPNotifyObservers(const uint32_t aPlugi
}
RefPtr<gmp::GeckoMediaPluginService> service =
gmp::GeckoMediaPluginService::GetGeckoMediaPluginService();
if (service) {
service->RunPluginCrashCallbacks(aPluginID, aPluginName);
}
}
-#endif
+
void
GMPParent::ActorDestroy(ActorDestroyReason aWhy)
{
LOGD("%s: (%d)", __FUNCTION__, (int)aWhy);
-#ifdef MOZ_CRASHREPORTER
+
if (AbnormalShutdown == aWhy) {
Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT,
NS_LITERAL_CSTRING("gmplugin"), 1);
nsString dumpID;
if (!GetCrashID(dumpID)) {
NS_WARNING("GMP crash without crash report");
dumpID = mName;
dumpID += '-';
AppendUTF8toUTF16(mVersion, dumpID);
}
// NotifyObservers is mainthread-only
nsCOMPtr<nsIRunnable> r = WrapRunnableNM(
&GMPNotifyObservers, mPluginId, mDisplayName, dumpID);
mMainThread->Dispatch(r.forget());
}
-#endif
+
// warn us off trying to close again
mState = GMPStateClosing;
mAbnormalShutdownInProgress = true;
CloseActive(false);
// Normal Shutdown() will delete the process on unwind.
if (AbnormalShutdown == aWhy) {
RefPtr<GMPParent> self(this);
@@ -535,22 +532,21 @@ GMPParent::ActorDestroy(ActorDestroyReas
// Note: final destruction will be Dispatched to ourself
mService->ReAddOnGMPThread(self);
}
}
mozilla::ipc::IPCResult
GMPParent::RecvInitCrashReporter(Shmem&& aShmem, const NativeThreadId& aThreadId)
{
-#ifdef MOZ_CRASHREPORTER
mCrashReporter = MakeUnique<ipc::CrashReporterHost>(
GeckoProcessType_GMPlugin,
aShmem,
aThreadId);
-#endif
+
return IPC_OK();
}
PGMPStorageParent*
GMPParent::AllocPGMPStorageParent()
{
GMPStorageParent* p = new GMPStorageParent(mNodeId, this);
mStorage.AppendElement(p); // Addrefs, released in DeallocPGMPStorageParent.
--- a/dom/media/gmp/GMPParent.h
+++ b/dom/media/gmp/GMPParent.h
@@ -148,20 +148,18 @@ private:
~GMPParent();
RefPtr<GeckoMediaPluginServiceParent> mService;
bool EnsureProcessLoaded();
RefPtr<GenericPromise> ReadGMPMetaData();
RefPtr<GenericPromise> ReadGMPInfoFile(nsIFile* aFile);
RefPtr<GenericPromise> ParseChromiumManifest(const nsAString& aJSON); // Main thread.
RefPtr<GenericPromise> ReadChromiumManifestFile(nsIFile* aFile); // GMP thread.
-#ifdef MOZ_CRASHREPORTER
void WriteExtraDataForMinidump();
bool GetCrashID(nsString& aResult);
-#endif
void ActorDestroy(ActorDestroyReason aWhy) override;
mozilla::ipc::IPCResult RecvInitCrashReporter(Shmem&& shmem, const NativeThreadId& aThreadId) override;
mozilla::ipc::IPCResult RecvPGMPStorageConstructor(PGMPStorageParent* actor) override;
PGMPStorageParent* AllocPGMPStorageParent() override;
bool DeallocPGMPStorageParent(PGMPStorageParent* aActor) override;
@@ -212,19 +210,17 @@ private:
int mChildPid;
// We hold a self reference to ourself while the child process is alive.
// This ensures that if the GMPService tries to shut us down and drops
// its reference to us, we stay alive long enough for the child process
// to terminate gracefully.
bool mHoldingSelfRef;
-#ifdef MOZ_CRASHREPORTER
UniquePtr<ipc::CrashReporterHost> mCrashReporter;
-#endif
const RefPtr<AbstractThread> mMainThread;
};
} // namespace gmp
} // namespace mozilla
#endif // GMPParent_h_
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -6,16 +6,17 @@
/* nsPluginHost.cpp - top-level plugin management code */
#include "nscore.h"
#include "nsPluginHost.h"
#include <cstdlib>
#include <stdio.h>
#include "prio.h"
+#include "nsExceptionHandler.h"
#include "nsNPAPIPlugin.h"
#include "nsNPAPIPluginStreamListener.h"
#include "nsNPAPIPluginInstance.h"
#include "nsPluginInstanceOwner.h"
#include "nsObjectLoadingContent.h"
#include "nsIHTTPHeaderListener.h"
#include "nsIHttpHeaderVisitor.h"
#include "nsIObserverService.h"
@@ -98,20 +99,16 @@
#if defined(XP_WIN)
#include "nsIWindowMediator.h"
#include "nsIBaseWindow.h"
#include "windows.h"
#include "winbase.h"
#endif
-#if MOZ_CRASHREPORTER
-#include "nsExceptionHandler.h"
-#endif
-
#include "npapi.h"
using namespace mozilla;
using mozilla::TimeStamp;
using mozilla::plugins::FakePluginTag;
using mozilla::plugins::PluginTag;
using mozilla::dom::FakePluginTagInit;
using mozilla::dom::FakePluginMimeEntry;
--- a/dom/plugins/base/nsPluginsDirDarwin.cpp
+++ b/dom/plugins/base/nsPluginsDirDarwin.cpp
@@ -21,19 +21,17 @@
#include "nsPluginsDir.h"
#include "nsNPAPIPlugin.h"
#include "nsPluginsDirUtils.h"
#include "nsILocalFileMac.h"
#include "mozilla/UniquePtr.h"
#include "nsCocoaFeatures.h"
-#if defined(MOZ_CRASHREPORTER)
#include "nsExceptionHandler.h"
-#endif
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <Carbon/Carbon.h>
#include <CoreServices/CoreServices.h>
@@ -419,41 +417,40 @@ nsresult nsPluginFile::GetPluginInfo(nsP
if (fileName.EqualsLiteral("fbplugin") ||
StringBeginsWith(fileName, NS_LITERAL_CSTRING("fbplugin_"))) {
nsAutoCString msg;
msg.AppendPrintf("Preventing load of %s (see bug 1086977)",
fileName.get());
NS_WARNING(msg.get());
return NS_ERROR_FAILURE;
}
-#if defined(MOZ_CRASHREPORTER)
+
// The block above assumes that "fbplugin" is the filename of the plugin
// to be blocked, or that the filename starts with "fbplugin_". But we
// don't yet know for sure if this is always true. So for the time being
// record extra information in our crash logs.
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Bug_1086977"),
fileName);
-#endif
}
// It's possible that our plugin has 2 entry points that'll give us mime type
// info. Quicktime does this to get around the need of having admin rights to
// change mime info in the resource fork. We need to use this info instead of
// the resource. See bug 113464.
// Sadly we have to load the library for this to work.
rv = LoadPlugin(outLibrary);
-#if defined(MOZ_CRASHREPORTER)
+
if (nsCocoaFeatures::OnYosemiteOrLater()) {
// If we didn't crash in LoadPlugin(), change the previous annotation so we
// don't sow confusion.
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Bug_1086977"),
NS_LITERAL_CSTRING("Didn't crash, please ignore"));
}
-#endif
+
if (NS_FAILED(rv))
return rv;
// Try to get data from NP_GetMIMEDescription
if (pLibrary) {
NP_GETMIMEDESCRIPTION pfnGetMimeDesc = (NP_GETMIMEDESCRIPTION)PR_FindFunctionSymbol(pLibrary, NP_GETMIMEDESCRIPTION_NAME);
if (pfnGetMimeDesc)
ParsePluginMimeDescription(pfnGetMimeDesc(), info);
--- a/dom/plugins/ipc/PluginMessageUtils.h
+++ b/dom/plugins/ipc/PluginMessageUtils.h
@@ -17,20 +17,19 @@
#include "gfxipc/ShadowLayerUtils.h"
#include "npapi.h"
#include "npruntime.h"
#include "npfunctions.h"
#include "nsString.h"
#include "nsTArray.h"
#include "mozilla/Logging.h"
+#include "nsExceptionHandler.h"
#include "nsHashKeys.h"
-#ifdef MOZ_CRASHREPORTER
-# include "nsExceptionHandler.h"
-#endif
+
#ifdef XP_MACOSX
#include "PluginInterposeOSX.h"
#else
namespace mac_plugin_interposing { class NSCursorInfo { }; }
#endif
using mac_plugin_interposing::NSCursorInfo;
#ifdef XP_WIN
#include "commdlg.h"
--- a/dom/plugins/ipc/PluginModuleChild.cpp
+++ b/dom/plugins/ipc/PluginModuleChild.cpp
@@ -22,16 +22,18 @@
#include "nsCOMPtr.h"
#include "nsPluginsDir.h"
#include "nsXULAppAPI.h"
#ifdef MOZ_X11
# include "nsX11ErrorHandler.h"
# include "mozilla/X11Util.h"
#endif
+
+#include "mozilla/ipc/CrashReporterClient.h"
#include "mozilla/ipc/ProcessChild.h"
#include "mozilla/plugins/PluginInstanceChild.h"
#include "mozilla/plugins/StreamNotifyChild.h"
#include "mozilla/plugins/BrowserStreamChild.h"
#include "mozilla/Sprintf.h"
#include "mozilla/Unused.h"
#include "nsNPAPIPlugin.h"
@@ -43,20 +45,16 @@
#include <shlobj.h>
#endif
#ifdef MOZ_WIDGET_COCOA
#include "PluginInterposeOSX.h"
#include "PluginUtilsOSX.h"
#endif
-#ifdef MOZ_CRASHREPORTER
-#include "mozilla/ipc/CrashReporterClient.h"
-#endif
-
#ifdef MOZ_GECKO_PROFILER
#include "ChildProfilerController.h"
#endif
using namespace mozilla;
using namespace mozilla::ipc;
using namespace mozilla::plugins;
using namespace mozilla::widget;
@@ -748,20 +746,19 @@ PluginModuleChild::RecvInitPluginModuleC
}
return IPC_OK();
}
mozilla::ipc::IPCResult
PluginModuleChild::AnswerInitCrashReporter(Shmem&& aShmem, mozilla::dom::NativeThreadId* aOutId)
{
-#ifdef MOZ_CRASHREPORTER
CrashReporterClient::InitSingletonWithShmem(aShmem);
*aOutId = CrashReporter::CurrentThreadId();
-#endif
+
return IPC_OK();
}
void
PluginModuleChild::ActorDestroy(ActorDestroyReason why)
{
#ifdef MOZ_GECKO_PROFILER
if (mProfilerController) {
@@ -790,19 +787,18 @@ PluginModuleChild::ActorDestroy(ActorDes
if (!mHasShutdown) {
MOZ_ASSERT(gChromeInstance == this);
NP_Shutdown();
}
// doesn't matter why we're being destroyed; it's up to us to
// initiate (clean) shutdown
-#ifdef MOZ_CRASHREPORTER
CrashReporterClient::DestroySingleton();
-#endif
+
XRE_ShutdownChildProcess();
}
void
PluginModuleChild::CleanUp()
{
}
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -5,16 +5,18 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/plugins/PluginModuleParent.h"
#include "base/process_util.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/ContentChild.h"
+#include "mozilla/ipc/CrashReporterClient.h"
+#include "mozilla/ipc/CrashReporterHost.h"
#include "mozilla/ipc/GeckoChildProcessHost.h"
#include "mozilla/ipc/MessageChannel.h"
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/plugins/BrowserStreamParent.h"
#include "mozilla/plugins/PluginBridge.h"
#include "mozilla/plugins/PluginInstanceParent.h"
#include "mozilla/Preferences.h"
#include "mozilla/ProcessHangMonitor.h"
@@ -60,22 +62,17 @@ using base::KillProcess;
using mozilla::PluginLibrary;
using mozilla::ipc::MessageChannel;
using mozilla::ipc::GeckoChildProcessHost;
using namespace mozilla;
using namespace mozilla::plugins;
using namespace mozilla::plugins::parent;
-#ifdef MOZ_CRASHREPORTER
-#include "mozilla/ipc/CrashReporterClient.h"
-#include "mozilla/ipc/CrashReporterHost.h"
-
using namespace CrashReporter;
-#endif
static const char kContentTimeoutPref[] = "dom.ipc.plugins.contentTimeoutSecs";
static const char kChildTimeoutPref[] = "dom.ipc.plugins.timeoutSecs";
static const char kParentTimeoutPref[] = "dom.ipc.plugins.parentTimeoutSecs";
static const char kLaunchTimeoutPref[] = "dom.ipc.plugins.processLaunchTimeoutSecs";
#ifdef XP_WIN
static const char kHangUITimeoutPref[] = "dom.ipc.plugins.hangUITimeoutSecs";
static const char kHangUIMinDisplayPref[] = "dom.ipc.plugins.hangUIMinDisplaySecs";
@@ -520,25 +517,23 @@ PluginModuleChromeParent::OnProcessLaunc
Preferences::RegisterCallback(TimeoutChanged, kParentTimeoutPref, this);
#ifdef XP_WIN
Preferences::RegisterCallback(TimeoutChanged, kHangUITimeoutPref, this);
Preferences::RegisterCallback(TimeoutChanged, kHangUIMinDisplayPref, this);
#endif
RegisterSettingsCallbacks();
-#ifdef MOZ_CRASHREPORTER
// If this fails, we're having IPC troubles, and we're doomed anyways.
if (!InitCrashReporter()) {
mShutdown = true;
Close();
OnInitFailure();
return;
}
-#endif
#if defined(XP_WIN) && defined(_X86_)
// Protected mode only applies to Windows and only to x86.
if (!mIsBlocklisted && mIsFlashPlugin &&
(Preferences::GetBool("dom.ipc.plugins.flash.disable-protected-mode", false) ||
mSandboxLevel >= 2)) {
Unused << SendDisableFlashProtectedMode();
}
@@ -547,17 +542,16 @@ PluginModuleChromeParent::OnProcessLaunc
#ifdef MOZ_GECKO_PROFILER
Unused << SendInitProfiler(ProfilerParent::CreateForProcess(OtherPid()));
#endif
}
bool
PluginModuleChromeParent::InitCrashReporter()
{
-#ifdef MOZ_CRASHREPORTER
ipc::Shmem shmem;
if (!ipc::CrashReporterClient::AllocShmem(this, &shmem)) {
return false;
}
NativeThreadId threadId;
if (!CallInitCrashReporter(shmem, &threadId)) {
return false;
@@ -565,17 +559,16 @@ PluginModuleChromeParent::InitCrashRepor
{
mozilla::MutexAutoLock lock(mCrashReporterMutex);
mCrashReporter = MakeUnique<ipc::CrashReporterHost>(
GeckoProcessType_Plugin,
shmem,
threadId);
}
-#endif
return true;
}
PluginModuleParent::PluginModuleParent(bool aIsChrome)
: mQuirks(QUIRKS_NOT_INITIALIZED)
, mIsChrome(aIsChrome)
, mShutdown(false)
@@ -583,19 +576,17 @@ PluginModuleParent::PluginModuleParent(b
, mClearSiteDataSupported(false)
, mGetSitesWithDataSupported(false)
, mNPNIface(nullptr)
, mNPPIface(nullptr)
, mPlugin(nullptr)
, mTaskFactory(this)
, mSandboxLevel(0)
, mIsFlashPlugin(false)
-#ifdef MOZ_CRASHREPORTER
, mCrashReporterMutex("PluginModuleChromeParent::mCrashReporterMutex")
-#endif
{
}
PluginModuleParent::~PluginModuleParent()
{
if (!OkToCleanup()) {
MOZ_CRASH("unsafe destruction");
}
@@ -697,17 +688,16 @@ PluginModuleChromeParent::~PluginModuleC
delete mHangUIParent;
mHangUIParent = nullptr;
}
#endif
mozilla::HangMonitor::UnregisterAnnotator(*this);
}
-#ifdef MOZ_CRASHREPORTER
void
PluginModuleChromeParent::WriteExtraDataForMinidump()
{
// mCrashReporterMutex is already held by the caller
mCrashReporterMutex.AssertCurrentThreadOwns();
typedef nsDependentCString CS;
@@ -739,17 +729,16 @@ PluginModuleChromeParent::WriteExtraData
tempStr.AppendFloat(std::ceil(mPluginCpuUsageOnHang[i] * 100) / 100);
mCrashReporter->AddNote(nsPrintfCString("CpuUsageFlashProcess%d", i), tempStr);
}
#endif
}
#endif
}
}
-#endif // MOZ_CRASHREPORTER
void
PluginModuleParent::SetChildTimeout(const int32_t aChildTimeout)
{
int32_t timeoutMs = (aChildTimeout > 0) ? (1000 * aChildTimeout) :
MessageChannel::kNoTimeout;
SetReplyTimeoutMs(timeoutMs);
}
@@ -995,29 +984,27 @@ PluginModuleChromeParent::AnnotateHang(m
true);
}
aAnnotations.AddAnnotation(NS_LITERAL_STRING("pluginName"), mPluginName);
aAnnotations.AddAnnotation(NS_LITERAL_STRING("pluginVersion"),
mPluginVersion);
}
}
-#ifdef MOZ_CRASHREPORTER
static bool
CreatePluginMinidump(base::ProcessId processId, ThreadId childThread,
nsIFile* parentMinidump, const nsACString& name)
{
mozilla::ipc::ScopedProcessHandle handle;
if (processId == 0 ||
!base::OpenPrivilegedProcessHandle(processId, &handle.rwget())) {
return false;
}
return CreateAdditionalChildMinidump(handle, 0, parentMinidump, name);
}
-#endif
bool
PluginModuleChromeParent::ShouldContinueFromReplyTimeout()
{
if (mIsFlashPlugin) {
MessageLoop::current()->PostTask(
mTaskFactory.NewRunnableMethod(
&PluginModuleChromeParent::NotifyFlashHang));
@@ -1062,17 +1049,16 @@ PluginModuleContentParent::OnExitedSyncS
}
void
PluginModuleChromeParent::TakeFullMinidump(base::ProcessId aContentPid,
const nsAString& aBrowserDumpId,
std::function<void(nsString)>&& aCallback,
bool aAsync)
{
-#ifdef MOZ_CRASHREPORTER
mozilla::MutexAutoLock lock(mCrashReporterMutex);
if (!mCrashReporter || !mTakeFullMinidumpCallback.IsEmpty()) {
aCallback(EmptyString());
return;
}
mTakeFullMinidumpCallback.Init(Move(aCallback), aAsync);
@@ -1106,22 +1092,18 @@ PluginModuleChromeParent::TakeFullMinidu
// We have a single browser report, generate a new plugin process parent
// report and pair it up with the browser report handed in.
mCrashReporter->GenerateMinidumpAndPair(Process(), mBrowserDumpFile,
NS_LITERAL_CSTRING("browser"),
Move(callback), aAsync);
} else {
TakeBrowserAndPluginMinidumps(false, aContentPid, browserDumpId, aAsync);
}
-#else // MOZ_CRASHREPORTER
- aCallback(NS_LITERAL_STRING(""));
-#endif
}
-#ifdef MOZ_CRASHREPORTER
void
PluginModuleChromeParent::RetainPluginRef()
{
if (!mPlugin) {
return;
}
if (NS_IsMainThread()) {
@@ -1230,33 +1212,30 @@ PluginModuleChromeParent::OnTakeFullMini
mTakeFullMinidumpCallback.Invoke(mCrashReporter->MinidumpID());
} else {
mTakeFullMinidumpCallback.Invoke(EmptyString());
NS_WARNING("failed to capture paired minidumps from hang");
}
}
-#endif // MOZ_CRASHREPORTER
-
void
PluginModuleChromeParent::TerminateChildProcess(MessageLoop* aMsgLoop,
base::ProcessId aContentPid,
const nsCString& aMonitorDescription,
const nsAString& aDumpId,
std::function<void(bool)>&& aCallback,
bool aAsync)
{
if (!mTerminateChildProcessCallback.IsEmpty()) {
aCallback(false);
return;
}
mTerminateChildProcessCallback.Init(Move(aCallback), aAsync);
-#ifdef MOZ_CRASHREPORTER
// Start by taking a full minidump if necessary, this is done early
// because it also needs to lock the mCrashReporterMutex and Mutex doesn't
// support recursive locking.
if (aDumpId.IsEmpty()) {
RetainPluginRef();
std::function<void(nsString)> callback =
[this, aMsgLoop, aMonitorDescription, aAsync](nsString aResult) {
@@ -1271,27 +1250,22 @@ PluginModuleChromeParent::TerminateChild
this->ReleasePluginRef();
};
TakeFullMinidump(aContentPid, EmptyString(), Move(callback), aAsync);
} else {
TerminateChildProcessOnDumpComplete(aMsgLoop, aMonitorDescription);
}
-
-#else
- TerminateChildProcessOnDumpComplete(aMsgLoop, aMonitorDescription);
-#endif
}
void
PluginModuleChromeParent::TerminateChildProcessOnDumpComplete(MessageLoop* aMsgLoop,
const nsCString& aMonitorDescription)
{
-#ifdef MOZ_CRASHREPORTER
mCrashReporterMutex.AssertCurrentThreadOwns();
if (!mCrashReporter) {
// If mCrashReporter is null then the hang has ended, the plugin module
// is shutting down. There's nothing to do here.
mTerminateChildProcessCallback.Invoke(true);
return;
}
@@ -1305,17 +1279,16 @@ PluginModuleChromeParent::TerminateChild
if (hangUIDuration) {
nsPrintfCString strHangUIDuration("%u", hangUIDuration);
mCrashReporter->AddNote(
NS_LITERAL_CSTRING("PluginHangUIDuration"),
strHangUIDuration);
}
}
#endif // XP_WIN
-#endif // MOZ_CRASHREPORTER
mozilla::ipc::ScopedProcessHandle geckoChildProcess;
bool childOpened = base::OpenProcessHandle(OtherPid(),
&geckoChildProcess.rwget());
#ifdef XP_WIN
// collect cpu usage for plugin processes
@@ -1336,17 +1309,17 @@ PluginModuleChromeParent::TerminateChild
base::OpenProcessHandle(mFlashProcess2, &flashSandboxProcess.rwget())) {
processHandles.AppendElement(flashSandboxProcess);
}
#endif
if (!GetProcessCpuUsage(processHandles, mPluginCpuUsageOnHang)) {
mPluginCpuUsageOnHang.Clear();
}
-#endif // MOZ_CRASHREPORTER
+#endif
// this must run before the error notification from the channel,
// or not at all
bool isFromHangUI = aMsgLoop != MessageLoop::current();
aMsgLoop->PostTask(
mChromeTaskFactory.NewRunnableMethod(
&PluginModuleChromeParent::CleanupFromTimeout, isFromHangUI));
@@ -1481,17 +1454,16 @@ PluginModuleChromeParent::FinishHangUI()
void
PluginModuleChromeParent::OnHangUIContinue()
{
mHangAnnotationFlags |= kHangUIContinued;
}
#endif // XP_WIN
-#ifdef MOZ_CRASHREPORTER
#ifdef MOZ_CRASHREPORTER_INJECTOR
static void
RemoveMinidump(nsIFile* minidump)
{
if (!minidump)
return;
minidump->Remove(false);
@@ -1573,17 +1545,16 @@ PluginModuleChromeParent::ProcessFirstMi
PLUGIN_LOG_DEBUG(("got child minidump: %s",
NS_ConvertUTF16toUTF8(mCrashReporter->MinidumpID()).get()));
if (!flashProcessType.IsEmpty()) {
mCrashReporter->AddNote(NS_LITERAL_CSTRING("FlashProcessDump"), flashProcessType);
}
mCrashReporter->FinalizeCrashReport();
}
-#endif
void
PluginModuleParent::ActorDestroy(ActorDestroyReason why)
{
switch (why) {
case AbnormalShutdown: {
mShutdown = true;
// Defer the PluginCrashed method so that we don't re-enter
@@ -1612,19 +1583,17 @@ PluginModuleParent::GetRunID(uint32_t* a
*aRunID = mRunID;
return NS_OK;
}
void
PluginModuleChromeParent::ActorDestroy(ActorDestroyReason why)
{
if (why == AbnormalShutdown) {
-#ifdef MOZ_CRASHREPORTER
ProcessFirstMinidump();
-#endif
Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT,
NS_LITERAL_CSTRING("plugin"), 1);
}
// We can't broadcast settings changes anymore.
UnregisterSettingsCallbacks();
PluginModuleParent::ActorDestroy(why);
@@ -1651,21 +1620,21 @@ PluginModuleParent::NotifyPluginCrashed(
}
if (!mPlugin) {
return;
}
nsString dumpID;
nsString browserDumpID;
-#ifdef MOZ_CRASHREPORTER
+
if (mCrashReporter && mCrashReporter->HasMinidump()) {
dumpID = mCrashReporter->MinidumpID();
}
-#endif
+
mPlugin->PluginCrashed(dumpID, browserDumpID);
}
PPluginInstanceParent*
PluginModuleParent::AllocPPluginInstanceParent(const nsCString& aMimeType,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues)
{
--- a/dom/plugins/ipc/PluginModuleParent.h
+++ b/dom/plugins/ipc/PluginModuleParent.h
@@ -16,30 +16,27 @@
#include "mozilla/plugins/PPluginModuleParent.h"
#include "mozilla/plugins/PluginMessageUtils.h"
#include "mozilla/plugins/PluginTypes.h"
#include "mozilla/ipc/TaskFactory.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/Unused.h"
#include "npapi.h"
#include "npfunctions.h"
+#include "nsExceptionHandler.h"
#include "nsDataHashtable.h"
#include "nsHashKeys.h"
#include "nsIObserver.h"
#ifdef XP_WIN
#include "nsWindowsHelpers.h"
#if defined(MOZ_SANDBOX)
#include "sandboxPermissions.h"
#endif
#endif
-#ifdef MOZ_CRASHREPORTER
-#include "nsExceptionHandler.h"
-#endif
-
class nsPluginTag;
namespace mozilla {
namespace layers {
class TextureClientRecycleAllocator;
} // namespace layers
@@ -329,26 +326,24 @@ protected:
bool
GetPluginDetails();
uint32_t mRunID;
RefPtr<layers::TextureClientRecycleAllocator> mTextureAllocatorForDirectBitmap;
RefPtr<layers::TextureClientRecycleAllocator> mTextureAllocatorForDXGISurface;
-#ifdef MOZ_CRASHREPORTER
/**
* This mutex protects the crash reporter when the Plugin Hang UI event
* handler is executing off main thread. It is intended to protect both
* the mCrashReporter variable in addition to the CrashReporterHost object
* that mCrashReporter refers to.
*/
mozilla::Mutex mCrashReporterMutex;
UniquePtr<ipc::CrashReporterHost> mCrashReporter;
-#endif // MOZ_CRASHREPORTER
};
class PluginModuleContentParent : public PluginModuleParent
{
public:
explicit PluginModuleContentParent();
static PluginLibrary* LoadModule(uint32_t aPluginId, nsPluginTag* aPluginTag);
@@ -453,28 +448,27 @@ class PluginModuleChromeParent
*/
template<typename T>
static std::function<void(T)> DummyCallback()
{
return std::function<void(T)>([](T aResult) { });
}
private:
-#ifdef MOZ_CRASHREPORTER
// The following methods are callbacks invoked after calling
// TakeFullMinidump(). The methods are invoked in the following order:
void TakeBrowserAndPluginMinidumps(bool aReportsReady,
base::ProcessId aContentPid,
const nsAString& aBrowserDumpId,
bool aAsync);
void OnTakeFullMinidumpComplete(bool aReportsReady,
base::ProcessId aContentPid,
const nsAString& aBrowserDumpId);
-#endif
+
// The following method is the callback invoked after calling
// TerminateChidlProcess().
void TerminateChildProcessOnDumpComplete(MessageLoop* aMsgLoop,
const nsCString& aMonitorDescription);
public:
#ifdef XP_WIN
/**
@@ -513,22 +507,20 @@ private:
mozilla::ipc::IProtocol* GetInvokingProtocol();
PluginInstanceParent* GetManagingInstance(mozilla::ipc::IProtocol* aProtocol);
virtual void
AnnotateHang(mozilla::HangMonitor::HangAnnotations& aAnnotations) override;
virtual bool ShouldContinueFromReplyTimeout() override;
-#ifdef MOZ_CRASHREPORTER
void ProcessFirstMinidump();
void WriteExtraDataForMinidump();
void RetainPluginRef();
void ReleasePluginRef();
-#endif
PluginProcessParent* Process() const { return mSubprocess; }
base::ProcessHandle ChildProcessHandle() { return mSubprocess->GetChildProcessHandle(); }
#if defined(XP_UNIX) && !defined(XP_MACOSX)
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) override;
#else
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) override;
@@ -636,19 +628,18 @@ private:
friend class LaunchedTask;
nsCOMPtr<nsIObserver> mPluginOfflineObserver;
bool mIsBlocklisted;
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
mozilla::SandboxPermissions mSandboxPermissions;
#endif
-#ifdef MOZ_CRASHREPORTER
nsCOMPtr<nsIFile> mBrowserDumpFile;
TakeFullMinidumpCallback mTakeFullMinidumpCallback;
-#endif
+
TerminateChildProcessCallback mTerminateChildProcessCallback;
};
} // namespace plugins
} // namespace mozilla
#endif // mozilla_plugins_PluginModuleParent_h