Bug 1401379 - Part 1: Make nsDocShell and nsDocLoader cycle collected, r=smaug
☠☠ backed out by abf8e429f50d ☠ ☠
authorNika Layzell <nika@thelayzells.com>
Mon, 02 Oct 2017 10:58:39 -0400
changeset 421735 e83481bd696394e7f9c74ff1ed51a496beba1297
parent 421734 3f7cbec2446bbfbf2bf819cb3502f62f421a3319
child 421736 9b5b03b2114d377ead28cffbb991b792457cb509
push idunknown
push userunknown
push dateunknown
reviewerssmaug
bugs1401379
milestone58.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 1401379 - Part 1: Make nsDocShell and nsDocLoader cycle collected, r=smaug MozReview-Commit-ID: Bui924n8Kvn
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
uriloader/base/nsDocLoader.cpp
uriloader/base/nsDocLoader.h
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -947,20 +947,25 @@ nsDocShell::DestroyChildren()
     if (shell) {
       shell->SetTreeOwner(nullptr);
     }
   }
 
   nsDocLoader::DestroyChildren();
 }
 
+NS_IMPL_CYCLE_COLLECTION_INHERITED(nsDocShell,
+                                   nsDocLoader,
+                                   mSessionStorageManager,
+                                   mScriptGlobal)
+
 NS_IMPL_ADDREF_INHERITED(nsDocShell, nsDocLoader)
 NS_IMPL_RELEASE_INHERITED(nsDocShell, nsDocLoader)
 
-NS_INTERFACE_MAP_BEGIN(nsDocShell)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDocShell)
   NS_INTERFACE_MAP_ENTRY(nsIDocShell)
   NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeItem)
   NS_INTERFACE_MAP_ENTRY(nsIWebNavigation)
   NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
   NS_INTERFACE_MAP_ENTRY(nsIScrollable)
   NS_INTERFACE_MAP_ENTRY(nsITextScroll)
   NS_INTERFACE_MAP_ENTRY(nsIDocCharset)
   NS_INTERFACE_MAP_ENTRY(nsIRefreshURI)
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -168,16 +168,17 @@ class nsDocShell final
 public:
   MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsDocShell)
 
   nsDocShell();
 
   virtual nsresult Init() override;
 
   NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDocShell, nsDocLoader)
 
   NS_DECL_NSIDOCSHELL
   NS_DECL_NSIDOCSHELLTREEITEM
   NS_DECL_NSIWEBNAVIGATION
   NS_DECL_NSIBASEWINDOW
   NS_DECL_NSISCROLLABLE
   NS_DECL_NSITEXTSCROLL
   NS_DECL_NSIDOCCHARSET
--- a/uriloader/base/nsDocLoader.cpp
+++ b/uriloader/base/nsDocLoader.cpp
@@ -160,39 +160,40 @@ nsDocLoader::~nsDocLoader()
   ClearWeakReferences();
 
   Destroy();
 
   MOZ_LOG(gDocLoaderLog, LogLevel::Debug,
          ("DocLoader:%p: deleted.\n", this));
 }
 
-
 /*
  * Implementation of ISupports methods...
  */
-NS_IMPL_ADDREF(nsDocLoader)
-NS_IMPL_RELEASE(nsDocLoader)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDocLoader)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDocLoader)
 
-NS_INTERFACE_MAP_BEGIN(nsDocLoader)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDocLoader)
    NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIRequestObserver)
    NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
    NS_INTERFACE_MAP_ENTRY(nsIDocumentLoader)
    NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
    NS_INTERFACE_MAP_ENTRY(nsIWebProgress)
    NS_INTERFACE_MAP_ENTRY(nsIProgressEventSink)
    NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
    NS_INTERFACE_MAP_ENTRY(nsIChannelEventSink)
    NS_INTERFACE_MAP_ENTRY(nsISecurityEventSink)
    NS_INTERFACE_MAP_ENTRY(nsISupportsPriority)
    if (aIID.Equals(kThisImplCID))
      foundInterface = static_cast<nsIDocumentLoader *>(this);
    else
 NS_INTERFACE_MAP_END
 
+NS_IMPL_CYCLE_COLLECTION(nsDocLoader, mChildrenInOnload)
+
 
 /*
  * Implementation of nsIInterfaceRequestor methods...
  */
 NS_IMETHODIMP nsDocLoader::GetInterface(const nsIID& aIID, void** aSink)
 {
   nsresult rv = NS_ERROR_NO_INTERFACE;
 
--- a/uriloader/base/nsDocLoader.h
+++ b/uriloader/base/nsDocLoader.h
@@ -23,16 +23,17 @@
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIChannelEventSink.h"
 #include "nsISecurityEventSink.h"
 #include "nsISupportsPriority.h"
 #include "nsCOMPtr.h"
 #include "PLDHashTable.h"
 #include "nsAutoPtr.h"
+#include "nsCycleCollectionParticipant.h"
 
 #include "mozilla/LinkedList.h"
 
 /****************************************************************************
  * nsDocLoader implementation...
  ****************************************************************************/
 
 #define NS_THIS_DOCLOADER_IMPL_CID                    \
@@ -64,17 +65,19 @@ public:
     // Needed to deal with ambiguous inheritance from nsISupports...
     static nsISupports* GetAsSupports(nsDocLoader* aDocLoader) {
         return static_cast<nsIDocumentLoader*>(aDocLoader);
     }
 
     // Add aDocLoader as a child to the docloader service.
     static MOZ_MUST_USE nsresult AddDocLoaderAsChildOfRoot(nsDocLoader* aDocLoader);
 
-    NS_DECL_ISUPPORTS
+    NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+    NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsDocLoader, nsIDocumentLoader)
+
     NS_DECL_NSIDOCUMENTLOADER
 
     // nsIProgressEventSink
     NS_DECL_NSIPROGRESSEVENTSINK
 
     NS_DECL_NSISECURITYEVENTSINK
 
     // nsIRequestObserver methods: (for observing the load group)