Bug 1274886 - Don't send any more IPC messages after calling PHttpChannelParent::SendDeleteSelf() r=jduell
authorValentin Gosu <valentin.gosu@gmail.com>
Tue, 14 Jun 2016 13:49:52 +0100
changeset 301748 c109d0b45e8aa440b588c1a862b0ca5b83ee050e
parent 301747 017c7d55f22fc67346a9ef2ec45bd33ae88d8c46
child 301749 085bacd46edf878ae2f23d98cfdddda49ffa0dc6
push id78438
push uservalentin.gosu@gmail.com
push dateTue, 14 Jun 2016 12:50:13 +0000
treeherdermozilla-inbound@c109d0b45e8a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjduell
bugs1274886
milestone50.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 1274886 - Don't send any more IPC messages after calling PHttpChannelParent::SendDeleteSelf() r=jduell MozReview-Commit-ID: 4EE91hvErM7
netwerk/protocol/http/HttpChannelParent.cpp
netwerk/protocol/http/HttpChannelParent.h
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -1242,17 +1242,17 @@ HttpChannelParent::NotifyTrackingProtect
     Unused << SendNotifyTrackingProtectionDisabled();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HttpChannelParent::Delete()
 {
   if (!mIPCClosed)
-    Unused << SendDeleteSelf();
+    Unused << DoSendDeleteSelf();
 
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 // HttpChannelParent::nsIParentRedirectingChannel
 //-----------------------------------------------------------------------------
 
@@ -1412,17 +1412,17 @@ HttpChannelParent::ResumeForDiversion()
     nsresult rv = mChannel->ResumeInternal();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       FailDiversion(NS_ERROR_UNEXPECTED, true);
       return rv;
     }
     mSuspendedForDiversion = false;
   }
 
-  if (NS_WARN_IF(mIPCClosed || !SendDeleteSelf())) {
+  if (NS_WARN_IF(mIPCClosed || !DoSendDeleteSelf())) {
     FailDiversion(NS_ERROR_UNEXPECTED);
     return NS_ERROR_UNEXPECTED;
   }
   return NS_OK;
 }
 
 void
 HttpChannelParent::DivertTo(nsIStreamListener *aListener)
@@ -1586,17 +1586,17 @@ HttpChannelParent::NotifyDiversionFailed
   // it here.
   if (!isPending) {
     mParentListener->OnStopRequest(mChannel, nullptr, aErrorCode);
   }
   mParentListener = nullptr;
   mChannel = nullptr;
 
   if (!mIPCClosed) {
-    Unused << SendDeleteSelf();
+    Unused << DoSendDeleteSelf();
   }
 }
 
 void
 HttpChannelParent::OfflineDisconnect()
 {
   if (mChannel) {
     mChannel->Cancel(NS_ERROR_OFFLINE);
@@ -1633,16 +1633,24 @@ HttpChannelParent::UpdateAndSerializeSec
     mAssociatedContentSecurity = do_QueryInterface(secInfoSupp);
     nsCOMPtr<nsISerializable> secInfoSer = do_QueryInterface(secInfoSupp);
     if (secInfoSer) {
       NS_SerializeToString(secInfoSer, aSerializedSecurityInfoOut);
     }
   }
 }
 
+bool
+HttpChannelParent::DoSendDeleteSelf()
+{
+  bool rv = SendDeleteSelf();
+  mIPCClosed = true;
+  return rv;
+}
+
 //-----------------------------------------------------------------------------
 // HttpChannelSecurityWarningReporter
 //-----------------------------------------------------------------------------
 
 nsresult
 HttpChannelParent::ReportSecurityMessage(const nsAString& aMessageTag,
                                          const nsAString& aMessageCategory)
 {
--- a/netwerk/protocol/http/HttpChannelParent.h
+++ b/netwerk/protocol/http/HttpChannelParent.h
@@ -176,16 +176,20 @@ protected:
   RefPtr<mozilla::dom::TabParent> mTabParent;
 
   void OfflineDisconnect() override;
   uint32_t GetAppId() override;
 
   nsresult ReportSecurityMessage(const nsAString& aMessageTag,
                                  const nsAString& aMessageCategory) override;
 
+  // Calls SendDeleteSelf and sets mIPCClosed to true because we should not
+  // send any more messages after that. Bug 1274886
+  bool DoSendDeleteSelf();
+
 private:
   void UpdateAndSerializeSecurityInfo(nsACString& aSerializedSecurityInfoOut);
 
   void DivertOnDataAvailable(const nsCString& data,
                              const uint64_t& offset,
                              const uint32_t& count);
   void DivertOnStopRequest(const nsresult& statusCode);
   void DivertComplete();