Bug 1224113 - fix ref count issue during channel close. r=jdm
authorShih-Chiang Chien <schien@mozilla.com>
Tue, 22 Dec 2015 19:30:08 +0800
changeset 277747 6967cf4e2fd9decfa05411acad9ec90eeb152889
parent 277746 3c4555f38aad95670c2a77826ed0f3106a487ecd
child 277748 1db8e4432568ce8ea542dedd834e1d597b4312ba
push idunknown
push userunknown
push dateunknown
reviewersjdm
bugs1224113
milestone46.0a1
Bug 1224113 - fix ref count issue during channel close. r=jdm
dom/presentation/PresentationSessionInfo.cpp
dom/presentation/PresentationSessionTransport.cpp
dom/presentation/interfaces/nsIPresentationSessionTransport.idl
--- a/dom/presentation/PresentationSessionInfo.cpp
+++ b/dom/presentation/PresentationSessionInfo.cpp
@@ -366,17 +366,16 @@ PresentationSessionInfo::NotifyTransport
 
 NS_IMETHODIMP
 PresentationSessionInfo::NotifyTransportClosed(nsresult aReason)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // Nullify |mTransport| here so it won't try to re-close |mTransport| in
   // potential subsequent |Shutdown| calls.
-  mTransport->SetCallback(nullptr);
   mTransport = nullptr;
 
   if (NS_WARN_IF(!IsSessionReady())) {
     // It happens before the session is ready. Reply the callback.
     return ReplyError(NS_ERROR_DOM_OPERATION_ERR);
   }
 
   // Unset |mIsTransportReady| here so it won't affect |IsSessionReady()| above.
--- a/dom/presentation/PresentationSessionTransport.cpp
+++ b/dom/presentation/PresentationSessionTransport.cpp
@@ -286,31 +286,16 @@ PresentationSessionTransport::EnableData
   if (IsReadyToNotifyData()) {
     return CreateInputStreamPump();
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-PresentationSessionTransport::GetCallback(nsIPresentationSessionTransportCallback** aCallback)
-{
-  nsCOMPtr<nsIPresentationSessionTransportCallback> callback = mCallback;
-  callback.forget(aCallback);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-PresentationSessionTransport::SetCallback(nsIPresentationSessionTransportCallback* aCallback)
-{
-  mCallback = aCallback;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 PresentationSessionTransport::GetSelfAddress(nsINetAddr** aSelfAddress)
 {
   if (NS_WARN_IF(!mTransport)) {
     return NS_ERROR_DOM_INVALID_STATE_ERR;
   }
 
   return mTransport->GetScriptableSelfAddr(aSelfAddress);
 }
@@ -400,16 +385,17 @@ PresentationSessionTransport::SetReadySt
   mReadyState = aReadyState;
 
   if (mReadyState == OPEN && mCallback) {
     // Notify the transport channel is ready.
     NS_WARN_IF(NS_FAILED(mCallback->NotifyTransportReady()));
   } else if (mReadyState == CLOSED && mCallback) {
     // Notify the transport channel has been shut down.
     NS_WARN_IF(NS_FAILED(mCallback->NotifyTransportClosed(mCloseStatus)));
+    mCallback = nullptr;
   }
 }
 
 // nsITransportEventSink
 NS_IMETHODIMP
 PresentationSessionTransport::OnTransportStatus(nsITransport* aTransport,
                                                 nsresult aStatus,
                                                 int64_t aProgress,
--- a/dom/presentation/interfaces/nsIPresentationSessionTransport.idl
+++ b/dom/presentation/interfaces/nsIPresentationSessionTransport.idl
@@ -23,20 +23,19 @@ interface nsIPresentationSessionTranspor
   void notifyTransportReady();
   void notifyTransportClosed(in nsresult reason);
   void notifyData(in ACString data);
 };
 
 /*
  * App-to-App transport channel for the presentation session.
  */
-[scriptable, uuid(5d23ea5f-a7e5-4cf0-8fa5-6b0abd106bf2)]
+[scriptable, uuid(b6a416cf-03ae-4e74-9cda-88828e8ff418)]
 interface nsIPresentationSessionTransport : nsISupports
 {
-  attribute nsIPresentationSessionTransportCallback callback;
   readonly attribute nsINetAddr selfAddress;
 
   /*
    * Initialize the transport channel with an existent socket transport. (This
    * is primarily used at the sender side.)
    * @param transport The socket transport.
    * @param callback The callback for followup notifications.
    */