From ccc885658724770e9dbdd4b4dafe298353b37ba6 Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Mon, 28 Oct 2013 04:53:00 +0000 Subject: [PATCH] Bug 929297 - Part 2: Avoid calling amIAddonManager in reporters off the main process. r=njn --- dom/base/nsWindowMemoryReporter.cpp | 7 +++++-- dom/workers/WorkerPrivate.cpp | 5 +++++ js/xpconnect/src/XPCJSRuntime.cpp | 14 ++++++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/dom/base/nsWindowMemoryReporter.cpp b/dom/base/nsWindowMemoryReporter.cpp index 087c2aefa9ba..e60754f4c726 100644 --- a/dom/base/nsWindowMemoryReporter.cpp +++ b/dom/base/nsWindowMemoryReporter.cpp @@ -484,8 +484,11 @@ nsWindowMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb, // Collect window memory usage. nsWindowSizes windowTotalSizes(NULL); - nsCOMPtr addonManager = - do_GetService("@mozilla.org/addons/integration;1"); + nsCOMPtr addonManager; + if (XRE_GetProcessType() == GeckoProcessType_Default) { + // Only try to access the service from the main process. + addonManager = do_GetService("@mozilla.org/addons/integration;1"); + } for (uint32_t i = 0; i < windows.Length(); i++) { rv = CollectWindowReports(windows[i], addonManager, &windowTotalSizes, &ghostWindows, diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 1957081c1413..1d6c2a34cd6c 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -1990,6 +1990,11 @@ private: mAlreadyMappedToAddon = true; + if (XRE_GetProcessType() != GeckoProcessType_Default) { + // Only try to access the service from the main process. + return; + } + nsAutoCString addonId; bool ok; nsCOMPtr addonManager = diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index d961782c4380..e3b61f4bec95 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -2366,8 +2366,11 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats, nsIMemoryReporterCallback *cb, nsISupports *closure, size_t *rtTotalOut) { - nsCOMPtr am = - do_GetService("@mozilla.org/addons/integration;1"); + nsCOMPtr am; + if (XRE_GetProcessType() == GeckoProcessType_Default) { + // Only try to access the service from the main process. + am = do_GetService("@mozilla.org/addons/integration;1"); + } return ReportJSRuntimeExplicitTreeStats(rtStats, rtPath, am.get(), cb, closure, rtTotalOut); } @@ -2604,8 +2607,11 @@ JSReporter::CollectReports(WindowPaths *windowPaths, // callback may be a JS function, and executing JS while getting these // stats seems like a bad idea. - nsCOMPtr addonManager = - do_GetService("@mozilla.org/addons/integration;1"); + nsCOMPtr addonManager; + if (XRE_GetProcessType() == GeckoProcessType_Default) { + // Only try to access the service from the main process. + addonManager = do_GetService("@mozilla.org/addons/integration;1"); + } bool getLocations = !!addonManager; XPCJSRuntimeStats rtStats(windowPaths, topWindowPaths, getLocations); OrphanReporter orphanReporter(XPCConvert::GetISupportsFromJSObject);