Bug 1380426 - Make nsWebRequestListener use NS_DECL_THREADSAFE_ISUPPORTS. r=kmag, a=jcristau
authorShane Caraveo <scaraveo@mozilla.com>
Wed, 19 Jul 2017 19:25:43 -0400
changeset 414398 58f05a66ec1b5baf372731a411c56cbf27d6bd44
parent 414397 2adac23ce13a1285d716f611b49d945d6f159188
child 414399 456adb45062df029c66bbdb17f3124140a454fbc
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag, jcristau
bugs1380426
milestone55.0
Bug 1380426 - Make nsWebRequestListener use NS_DECL_THREADSAFE_ISUPPORTS. r=kmag, a=jcristau
toolkit/components/extensions/webrequest/nsWebRequestListener.cpp
toolkit/components/extensions/webrequest/nsWebRequestListener.h
--- a/toolkit/components/extensions/webrequest/nsWebRequestListener.cpp
+++ b/toolkit/components/extensions/webrequest/nsWebRequestListener.cpp
@@ -27,31 +27,29 @@ nsWebRequestListener::Init(nsIStreamList
 }
 
 NS_IMETHODIMP
 nsWebRequestListener::OnStartRequest(nsIRequest *request, nsISupports * aCtxt)
 {
   MOZ_ASSERT(mTargetStreamListener, "Should have mTargetStreamListener");
   MOZ_ASSERT(mOrigStreamListener, "Should have mOrigStreamListener");
 
-  nsresult rv = mTargetStreamListener->OnStartRequest(request, aCtxt);
-  NS_ENSURE_SUCCESS(rv, rv);
+  mTargetStreamListener->OnStartRequest(request, aCtxt);
 
   return mOrigStreamListener->OnStartRequest(request, aCtxt);
 }
 
 NS_IMETHODIMP
 nsWebRequestListener::OnStopRequest(nsIRequest *request, nsISupports *aCtxt,
                                            nsresult aStatus)
 {
   MOZ_ASSERT(mOrigStreamListener, "Should have mOrigStreamListener");
   MOZ_ASSERT(mTargetStreamListener, "Should have mTargetStreamListener");
 
-  nsresult rv = mOrigStreamListener->OnStopRequest(request, aCtxt, aStatus);
-  NS_ENSURE_SUCCESS(rv, rv);
+  mOrigStreamListener->OnStopRequest(request, aCtxt, aStatus);
 
   return mTargetStreamListener->OnStopRequest(request, aCtxt, aStatus);
 }
 
 NS_IMETHODIMP
 nsWebRequestListener::OnDataAvailable(nsIRequest *request, nsISupports * aCtxt,
                                              nsIInputStream * inStr,
                                              uint64_t sourceOffset, uint32_t count)
--- a/toolkit/components/extensions/webrequest/nsWebRequestListener.h
+++ b/toolkit/components/extensions/webrequest/nsWebRequestListener.h
@@ -6,31 +6,35 @@
 #define nsWebRequestListener_h__
 
 #include "nsCOMPtr.h"
 #include "nsIWebRequestListener.h"
 #include "nsIRequestObserver.h"
 #include "nsIStreamListener.h"
 #include "nsITraceableChannel.h"
 #include "nsIThreadRetargetableStreamListener.h"
+#include "nsProxyRelease.h"
 #include "mozilla/Attributes.h"
 
 class nsWebRequestListener final : public nsIWebRequestListener
                                  , public nsIStreamListener
                                  , public nsIThreadRetargetableStreamListener
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIWEBREQUESTLISTENER
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSISTREAMLISTENER
   NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
 
   nsWebRequestListener() {}
 
 private:
-  ~nsWebRequestListener() {}
+  ~nsWebRequestListener() {
+    NS_ReleaseOnMainThreadSystemGroup("nsWebRequestListener::mTargetStreamListener",
+                                      mTargetStreamListener.forget());
+  }
   nsCOMPtr<nsIStreamListener> mOrigStreamListener;
   nsCOMPtr<nsIStreamListener> mTargetStreamListener;
 };
 
 #endif // nsWebRequestListener_h__