Bug 1521189 - Asynchronously destroy WindowGlobalChild, r=farre
☠☠ backed out by 69a279908152 ☠ ☠
authorNika Layzell <nika@thelayzells.com>
Tue, 22 Jan 2019 18:23:23 +0000
changeset 514852 36b36b5cdab6c75c1cfd7e0e7c4784c297c2efa2
parent 514851 b2066b96bd8fcda814e7438c81880b59615bde1e
child 514853 89875cd4d9422dd0f7a169184ac2633a6669a196
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfarre
bugs1521189
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1521189 - Asynchronously destroy WindowGlobalChild, r=farre Differential Revision: https://phabricator.services.mozilla.com/D17030
dom/base/nsGlobalWindowInner.cpp
dom/ipc/PWindowGlobal.ipdl
dom/ipc/WindowGlobalChild.h
dom/ipc/WindowGlobalParent.cpp
dom/ipc/WindowGlobalParent.h
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -1269,17 +1269,17 @@ void nsGlobalWindowInner::FreeInnerObjec
   if (mCleanMessageManager) {
     MOZ_ASSERT(mIsChrome, "only chrome should have msg manager cleaned");
     if (mChromeFields.mMessageManager) {
       mChromeFields.mMessageManager->Disconnect();
     }
   }
 
   if (mWindowGlobalChild && !mWindowGlobalChild->IsClosed()) {
-    mWindowGlobalChild->Send__delete__(mWindowGlobalChild);
+    mWindowGlobalChild->Destroy();
   }
   mWindowGlobalChild = nullptr;
 
   mIntlUtils = nullptr;
 }
 
 //*****************************************************************************
 // nsGlobalWindowInner::nsISupports
--- a/dom/ipc/PWindowGlobal.ipdl
+++ b/dom/ipc/PWindowGlobal.ipdl
@@ -18,20 +18,23 @@ namespace dom {
  * specifically a |nsGlobalWindowInner|. These actors will form a parent/child
  * link either between the chrome/content process, or will be in-process, for
  * documents which are loaded in the chrome process.
  */
 async protocol PWindowGlobal
 {
   manager PBrowser or PInProcess;
 
+child:
+  async __delete__();
+
 parent:
   /// Update the URI of the document in this WindowGlobal.
   async UpdateDocumentURI(nsIURI aUri);
 
   /// Notify the parent that this PWindowGlobal is now the current global.
   async BecomeCurrentWindowGlobal();
 
-  async __delete__();
+  async Destroy();
 };
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/ipc/WindowGlobalChild.h
+++ b/dom/ipc/WindowGlobalChild.h
@@ -37,16 +37,20 @@ class WindowGlobalChild : public nsWrapp
     return GetByInnerWindowId(aInnerWindowId);
   }
 
   dom::BrowsingContext* BrowsingContext() { return mBrowsingContext; }
   nsGlobalWindowInner* WindowGlobal() { return mWindowGlobal; }
 
   // Has this actor been shut down
   bool IsClosed() { return mIPCClosed; }
+  void Destroy() {
+    mIPCClosed = true;
+    SendDestroy();
+  }
 
   // Check if this actor is managed by PInProcess, as-in the document is loaded
   // in the chrome process.
   bool IsInProcess() { return XRE_IsParentProcess(); }
 
   // The Window ID for this WindowGlobal
   uint64_t InnerWindowId() { return mInnerWindowId; }
   uint64_t OuterWindowId() { return mOuterWindowId; }
--- a/dom/ipc/WindowGlobalParent.cpp
+++ b/dom/ipc/WindowGlobalParent.cpp
@@ -123,16 +123,23 @@ IPCResult WindowGlobalParent::RecvUpdate
   return IPC_OK();
 }
 
 IPCResult WindowGlobalParent::RecvBecomeCurrentWindowGlobal() {
   mBrowsingContext->SetCurrentWindowGlobal(this);
   return IPC_OK();
 }
 
+IPCResult WindowGlobalParent::RecvDestroy() {
+  if (!mIPCClosed) {
+    Unused << Send__delete__(this);
+  }
+  return IPC_OK();
+}
+
 bool WindowGlobalParent::IsCurrentGlobal() {
   return !mIPCClosed && mBrowsingContext->GetCurrentWindowGlobal() == this;
 }
 
 void WindowGlobalParent::ActorDestroy(ActorDestroyReason aWhy) {
   mIPCClosed = true;
   gWindowGlobalParentsById->Remove(mInnerWindowId);
   mBrowsingContext->UnregisterWindowGlobal(this);
--- a/dom/ipc/WindowGlobalParent.h
+++ b/dom/ipc/WindowGlobalParent.h
@@ -85,16 +85,17 @@ class WindowGlobalParent final : public 
   nsISupports* GetParentObject();
   JSObject* WrapObject(JSContext* aCx,
                        JS::Handle<JSObject*> aGivenProto) override;
 
  protected:
   // IPC messages
   mozilla::ipc::IPCResult RecvUpdateDocumentURI(nsIURI* aURI) override;
   mozilla::ipc::IPCResult RecvBecomeCurrentWindowGlobal() override;
+  mozilla::ipc::IPCResult RecvDestroy() override;
 
   void ActorDestroy(ActorDestroyReason aWhy) override;
 
  private:
   ~WindowGlobalParent();
 
   // NOTE: This document principal doesn't reflect possible |document.domain|
   // mutations which may have been made in the actual document.