Bug 929297 - Part 2: Avoid calling amIAddonManager in reporters off the main process. r=njn

This commit is contained in:
Nils Maier 2013-10-28 04:53:00 +00:00
parent a6699d7288
commit ccc8856587
3 changed files with 20 additions and 6 deletions

View File

@ -484,8 +484,11 @@ nsWindowMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
// Collect window memory usage. // Collect window memory usage.
nsWindowSizes windowTotalSizes(NULL); nsWindowSizes windowTotalSizes(NULL);
nsCOMPtr<amIAddonManager> addonManager = nsCOMPtr<amIAddonManager> addonManager;
do_GetService("@mozilla.org/addons/integration;1"); 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++) { for (uint32_t i = 0; i < windows.Length(); i++) {
rv = CollectWindowReports(windows[i], addonManager, rv = CollectWindowReports(windows[i], addonManager,
&windowTotalSizes, &ghostWindows, &windowTotalSizes, &ghostWindows,

View File

@ -1990,6 +1990,11 @@ private:
mAlreadyMappedToAddon = true; mAlreadyMappedToAddon = true;
if (XRE_GetProcessType() != GeckoProcessType_Default) {
// Only try to access the service from the main process.
return;
}
nsAutoCString addonId; nsAutoCString addonId;
bool ok; bool ok;
nsCOMPtr<amIAddonManager> addonManager = nsCOMPtr<amIAddonManager> addonManager =

View File

@ -2366,8 +2366,11 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats,
nsIMemoryReporterCallback *cb, nsIMemoryReporterCallback *cb,
nsISupports *closure, size_t *rtTotalOut) nsISupports *closure, size_t *rtTotalOut)
{ {
nsCOMPtr<amIAddonManager> am = nsCOMPtr<amIAddonManager> am;
do_GetService("@mozilla.org/addons/integration;1"); 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, return ReportJSRuntimeExplicitTreeStats(rtStats, rtPath, am.get(), cb,
closure, rtTotalOut); closure, rtTotalOut);
} }
@ -2604,8 +2607,11 @@ JSReporter::CollectReports(WindowPaths *windowPaths,
// callback may be a JS function, and executing JS while getting these // callback may be a JS function, and executing JS while getting these
// stats seems like a bad idea. // stats seems like a bad idea.
nsCOMPtr<amIAddonManager> addonManager = nsCOMPtr<amIAddonManager> addonManager;
do_GetService("@mozilla.org/addons/integration;1"); 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; bool getLocations = !!addonManager;
XPCJSRuntimeStats rtStats(windowPaths, topWindowPaths, getLocations); XPCJSRuntimeStats rtStats(windowPaths, topWindowPaths, getLocations);
OrphanReporter orphanReporter(XPCConvert::GetISupportsFromJSObject); OrphanReporter orphanReporter(XPCConvert::GetISupportsFromJSObject);