Bug 734057 - Make nsDOMEventTargetHelper to not have strong pointer to window, part2, r=jst
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Tue, 13 Mar 2012 02:56:20 +0200
changeset 88814 483fb2f1da11019ea8a5791c9cba384de25afa46
parent 88813 0c35057e2bb41d3440942338b5ad3c7d9c2a3345
child 88815 597d92c3064e0e050bf2dd8adf81441d4e215056
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjst
bugs734057
milestone13.0a1
Bug 734057 - Make nsDOMEventTargetHelper to not have strong pointer to window, part2, r=jst
content/base/src/nsEventSource.cpp
content/base/src/nsWebSocket.cpp
content/base/src/nsXMLHttpRequest.cpp
dom/base/nsGlobalWindow.cpp
--- a/content/base/src/nsEventSource.cpp
+++ b/content/base/src/nsEventSource.cpp
@@ -178,16 +178,17 @@ NS_IMPL_RELEASE_INHERITED(nsEventSource,
 
 void
 nsEventSource::DisconnectFromOwner()
 {
   nsDOMEventTargetHelper::DisconnectFromOwner();
   NS_DISCONNECT_EVENT_HANDLER(Open)
   NS_DISCONNECT_EVENT_HANDLER(Message)
   NS_DISCONNECT_EVENT_HANDLER(Error)
+  Close();
 }
 
 //-----------------------------------------------------------------------------
 // nsEventSource::nsIEventSource
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 nsEventSource::GetUrl(nsAString& aURL)
--- a/content/base/src/nsWebSocket.cpp
+++ b/content/base/src/nsWebSocket.cpp
@@ -539,16 +539,17 @@ NS_IMPL_RELEASE_INHERITED(nsWebSocket, n
 void
 nsWebSocket::DisconnectFromOwner()
 {
   nsDOMEventTargetHelper::DisconnectFromOwner();
   NS_DISCONNECT_EVENT_HANDLER(Open)
   NS_DISCONNECT_EVENT_HANDLER(Message)
   NS_DISCONNECT_EVENT_HANDLER(Close)
   NS_DISCONNECT_EVENT_HANDLER(Error)
+  FailConnectionQuietly();
   DontKeepAliveAnyMore();
 }
 
 //-----------------------------------------------------------------------------
 // nsWebSocket::nsIJSNativeInitializer methods:
 //-----------------------------------------------------------------------------
 
 /**
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -703,16 +703,17 @@ NS_IMPL_ADDREF_INHERITED(nsXMLHttpReques
 NS_IMPL_RELEASE_INHERITED(nsXMLHttpRequest, nsXHREventTarget)
 
 void
 nsXMLHttpRequest::DisconnectFromOwner()
 {
   nsXHREventTarget::DisconnectFromOwner();
   NS_DISCONNECT_EVENT_HANDLER(UploadProgress)
   NS_DISCONNECT_EVENT_HANDLER(Readystatechange)
+  Abort();
 }
 
 NS_IMETHODIMP
 nsXMLHttpRequest::GetOnreadystatechange(nsIDOMEventListener * *aOnreadystatechange)
 {
   return
     nsXHREventTarget::GetInnerEventListener(mOnReadystatechangeListener,
                                             aOnreadystatechange);
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -995,17 +995,18 @@ nsGlobalWindow::Init()
   sWindowsById->Init();
 #endif
 }
 
 static PLDHashOperator
 DisconnectEventTargetObjects(nsPtrHashKey<nsDOMEventTargetHelper>* aKey,
                              void* aClosure)
 {
-  aKey->GetKey()->DisconnectFromOwner();
+  nsRefPtr<nsDOMEventTargetHelper> target = aKey->GetKey();
+  target->DisconnectFromOwner();
   return PL_DHASH_NEXT;
 }
 
 nsGlobalWindow::~nsGlobalWindow()
 {
   mEventTargetObjects.EnumerateEntries(DisconnectEventTargetObjects, nsnull);
   mEventTargetObjects.Clear();