From 4a0dd8ce9d992d5ff4d0453997851cddbe3d060b Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Thu, 11 Jan 2018 14:14:09 -0800 Subject: [PATCH] Bug 1429945 - Make ghost window unlinker e10s compatible. r=smaug Content processes can contain ghost windows, so the debug-only ghost window unlinker needs to send a message to child processes to get them to run it, too. MozReview-Commit-ID: 9Ffc3SDNDJB --HG-- extra : rebase_source : 875891e9332cf41c4157d246b71c2c361cab4aa6 --- dom/ipc/ContentChild.cpp | 10 ++++++++++ dom/ipc/ContentChild.h | 1 + dom/ipc/ContentParent.cpp | 4 ++++ dom/ipc/PContent.ipdl | 1 + js/xpconnect/src/XPCComponents.cpp | 8 ++++++++ 5 files changed, 24 insertions(+) diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 27e825e8f210..0972c6cd5989 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -137,6 +137,7 @@ #ifdef NS_PRINTING #include "nsPrintingProxy.h" #endif +#include "nsWindowMemoryReporter.h" #include "IHistory.h" #include "nsNetUtil.h" @@ -2654,6 +2655,15 @@ ContentChild::RecvCycleCollect() return IPC_OK(); } +mozilla::ipc::IPCResult +ContentChild::RecvUnlinkGhosts() +{ +#ifdef DEBUG + nsWindowMemoryReporter::UnlinkGhostWindows(); +#endif + return IPC_OK(); +} + mozilla::ipc::IPCResult ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID, const nsCString& name, const nsCString& UAName, diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index 9c9978a1f682..086ed3daa529 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -410,6 +410,7 @@ public: virtual mozilla::ipc::IPCResult RecvGarbageCollect() override; virtual mozilla::ipc::IPCResult RecvCycleCollect() override; + virtual mozilla::ipc::IPCResult RecvUnlinkGhosts() override; virtual mozilla::ipc::IPCResult RecvAppInfo(const nsCString& version, const nsCString& buildID, const nsCString& name, const nsCString& UAName, diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 7a6a3d3e8e39..f193b0cb98ce 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -578,6 +578,7 @@ static const char* sObserverTopics[] = { "child-gc-request", "child-cc-request", "child-mmu-request", + "child-ghost-request", "last-pb-context-exited", "file-watcher-update", #ifdef ACCESSIBILITY @@ -2848,6 +2849,9 @@ ContentParent::Observe(nsISupports* aSubject, else if (!strcmp(aTopic, "child-mmu-request")){ Unused << SendMinimizeMemoryUsage(); } + else if (!strcmp(aTopic, "child-ghost-request")){ + Unused << SendUnlinkGhosts(); + } else if (!strcmp(aTopic, "last-pb-context-exited")) { Unused << SendLastPrivateDocShellDestroyed(); } diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 433a89e00180..62107c785f04 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -455,6 +455,7 @@ child: async GarbageCollect(); async CycleCollect(); + async UnlinkGhosts(); /** * Start accessibility engine in content process. diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index c467df15f236..2e97840fe9ae 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -2457,6 +2457,14 @@ nsXPCComponents_Utils::UnlinkGhostWindows() { #ifdef DEBUG nsWindowMemoryReporter::UnlinkGhostWindows(); + + if (XRE_IsParentProcess()) { + nsCOMPtr obsvc = services::GetObserverService(); + if (obsvc) { + obsvc->NotifyObservers(nullptr, "child-ghost-request", nullptr); + } + } + return NS_OK; #else return NS_ERROR_NOT_IMPLEMENTED;