Bug 1594432 - Remove aContext from nsIChildChannel.completeRedirectSetup r=valentin
authorsonakshi <sonakshisaxena1@gmail.com>
Thu, 26 Mar 2020 11:07:10 +0000
changeset 520575 0cd0ef64e4260a81ac372bfd7a053a0784cf56e1
parent 520574 11a006e5dfc6a708ff73268186afae8361fb2949
child 520576 61ce9056af73886aa28135d9d9cdac5b2e8f8550
push id37253
push usernerli@mozilla.com
push dateThu, 26 Mar 2020 21:36:52 +0000
treeherdermozilla-central@c644dd16e2cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1594432
milestone76.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 1594432 - Remove aContext from nsIChildChannel.completeRedirectSetup r=valentin Differential Revision: https://phabricator.services.mozilla.com/D68177
netwerk/base/SimpleChannel.cpp
netwerk/base/nsIChildChannel.idl
netwerk/ipc/DocumentChannelChild.cpp
netwerk/protocol/data/DataChannelChild.cpp
netwerk/protocol/file/FileChannelChild.cpp
netwerk/protocol/ftp/FTPChannelChild.cpp
netwerk/protocol/http/HttpChannelChild.cpp
netwerk/protocol/http/HttpChannelChild.h
netwerk/protocol/viewsource/nsViewSourceChannel.cpp
uriloader/base/nsURILoader.cpp
uriloader/exthandler/nsExternalProtocolHandler.cpp
--- a/netwerk/base/SimpleChannel.cpp
+++ b/netwerk/base/SimpleChannel.cpp
@@ -75,24 +75,22 @@ SimpleChannelChild::ConnectParent(uint32
                                                   aId)) {
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-SimpleChannelChild::CompleteRedirectSetup(nsIStreamListener* aListener,
-                                          nsISupports* aContext) {
+SimpleChannelChild::CompleteRedirectSetup(nsIStreamListener* aListener) {
   if (CanSend()) {
     MOZ_ASSERT(NS_IsMainThread());
   }
 
   nsresult rv;
-  MOZ_ASSERT(!aContext, "aContext should be null!");
   rv = AsyncOpen(aListener);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (CanSend()) {
     Unused << Send__delete__(this);
   }
--- a/netwerk/base/nsIChildChannel.idl
+++ b/netwerk/base/nsIChildChannel.idl
@@ -25,11 +25,10 @@ interface nsIChildChannel : nsISupports
    */
   void connectParent(in uint32_t registrarId);
 
   /**
    * As AsyncOpen is called on the chrome process for redirect target channels,
    * we have to inform the child side of the protocol of that fact by a special
    * method.
    */
-  void completeRedirectSetup(in nsIStreamListener aListener,
-                             in nsISupports aContext);
+  void completeRedirectSetup(in nsIStreamListener aListener);
 };
--- a/netwerk/ipc/DocumentChannelChild.cpp
+++ b/netwerk/ipc/DocumentChannelChild.cpp
@@ -318,17 +318,17 @@ DocumentChannelChild::OnRedirectVerifyCa
     redirectResolver(aStatusCode);
     return NS_OK;
   }
 
   nsresult rv = aStatusCode;
   if (NS_SUCCEEDED(rv)) {
     if (nsCOMPtr<nsIChildChannel> childChannel =
             do_QueryInterface(redirectChannel)) {
-      rv = childChannel->CompleteRedirectSetup(mListener, nullptr);
+      rv = childChannel->CompleteRedirectSetup(mListener);
     } else {
       rv = redirectChannel->AsyncOpen(mListener);
     }
   } else {
     redirectChannel->SetNotificationCallbacks(nullptr);
   }
 
   redirectResolver(rv);
--- a/netwerk/protocol/data/DataChannelChild.cpp
+++ b/netwerk/protocol/data/DataChannelChild.cpp
@@ -31,20 +31,18 @@ DataChannelChild::ConnectParent(uint32_t
   }
 
   // IPC now has a ref to us.
   mIPCOpen = true;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-DataChannelChild::CompleteRedirectSetup(nsIStreamListener* aListener,
-                                        nsISupports* aContext) {
+DataChannelChild::CompleteRedirectSetup(nsIStreamListener* aListener) {
   nsresult rv;
-  MOZ_ASSERT(!aContext, "aContext should be null!");
   rv = AsyncOpen(aListener);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (mIPCOpen) {
     Unused << Send__delete__(this);
   }
--- a/netwerk/protocol/file/FileChannelChild.cpp
+++ b/netwerk/protocol/file/FileChannelChild.cpp
@@ -27,18 +27,17 @@ FileChannelChild::ConnectParent(uint32_t
 
   if (!gNeckoChild->SendPFileChannelConstructor(this, id)) {
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-FileChannelChild::CompleteRedirectSetup(nsIStreamListener* listener,
-                                        nsISupports* ctx) {
+FileChannelChild::CompleteRedirectSetup(nsIStreamListener* listener) {
   nsresult rv;
 
   rv = AsyncOpen(listener);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
--- a/netwerk/protocol/ftp/FTPChannelChild.cpp
+++ b/netwerk/protocol/ftp/FTPChannelChild.cpp
@@ -618,18 +618,17 @@ FTPChannelChild::ConnectParent(uint32_t 
           this, browserChild, IPC::SerializedLoadContext(this), connectArgs)) {
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-FTPChannelChild::CompleteRedirectSetup(nsIStreamListener* aListener,
-                                       nsISupports* aContext) {
+FTPChannelChild::CompleteRedirectSetup(nsIStreamListener* aListener) {
   LOG(("FTPChannelChild::CompleteRedirectSetup [this=%p]\n", this));
 
   NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
   NS_ENSURE_TRUE(!mWasOpened, NS_ERROR_ALREADY_OPENED);
 
   mIsPending = true;
   mWasOpened = true;
   mListener = aListener;
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -218,17 +218,16 @@ void HttpChannelChild::ReleaseMainThread
   nsTArray<nsCOMPtr<nsISupports>> arrayToRelease;
   arrayToRelease.AppendElement(mRedirectChannelChild.forget());
 
   // To solve multiple inheritence of nsISupports in InterceptStreamListener
   nsCOMPtr<nsIStreamListener> listener = std::move(mInterceptListener);
   arrayToRelease.AppendElement(listener.forget());
 
   arrayToRelease.AppendElement(mInterceptedRedirectListener.forget());
-  arrayToRelease.AppendElement(mInterceptedRedirectContext.forget());
 
   NS_DispatchToMainThread(new ProxyReleaseRunnable(std::move(arrayToRelease)));
 }
 //-----------------------------------------------------------------------------
 // HttpChannelChild::nsISupports
 //-----------------------------------------------------------------------------
 
 NS_IMPL_ADDREF(HttpChannelChild)
@@ -1536,21 +1535,19 @@ void HttpChannelChild::ContinueDoNotifyL
       mLoadInfo->GetLoadingDocument(getter_AddRefs(doc));
       FlushConsoleReports(doc);
     }
   }
 }
 
 void HttpChannelChild::FinishInterceptedRedirect() {
   nsresult rv;
-  MOZ_ASSERT(!mInterceptedRedirectContext, "the context should be null!");
   rv = AsyncOpen(mInterceptedRedirectListener);
 
   mInterceptedRedirectListener = nullptr;
-  mInterceptedRedirectContext = nullptr;
 
   if (mInterceptingChannel) {
     mInterceptingChannel->CleanupRedirectingChannel(rv);
     mInterceptingChannel = nullptr;
   }
 
   if (mOverrideRunnable) {
     mOverrideRunnable->OverrideWithSynthesizedResponse();
@@ -1941,17 +1938,17 @@ bool HttpChannelChild::Redirect3Complete
   RefPtr<HttpChannelChild> httpChannelChild =
       static_cast<HttpChannelChild*>(chan.get());
   // Chrome channel has been AsyncOpen'd.  Reflect this in child.
   if (mRedirectChannelChild) {
     if (httpChannelChild) {
       httpChannelChild->mOverrideRunnable = aRunnable;
       httpChannelChild->mInterceptingChannel = this;
     }
-    rv = mRedirectChannelChild->CompleteRedirectSetup(mListener, nullptr);
+    rv = mRedirectChannelChild->CompleteRedirectSetup(mListener);
   }
 
   if (!httpChannelChild || !httpChannelChild->mShouldParentIntercept) {
     // The redirect channel either isn't a HttpChannelChild, or the interception
     // logic wasn't triggered, so we can clean it up right here.
     CleanupRedirectingChannel(rv);
     if (httpChannelChild) {
       httpChannelChild->mOverrideRunnable = nullptr;
@@ -2071,18 +2068,17 @@ HttpChannelChild::ConnectParent(uint32_t
 
     mBgChild = std::move(bgChild);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-HttpChannelChild::CompleteRedirectSetup(nsIStreamListener* aListener,
-                                        nsISupports* aContext) {
+HttpChannelChild::CompleteRedirectSetup(nsIStreamListener* aListener) {
   LOG(("HttpChannelChild::FinishRedirectSetup [this=%p]\n", this));
   MOZ_ASSERT(NS_IsMainThread());
 
   NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
   NS_ENSURE_TRUE(!mWasOpened, NS_ERROR_ALREADY_OPENED);
 
   if (mShouldParentIntercept) {
     // This is a redirected channel, and the corresponding parent channel has
@@ -2094,18 +2090,16 @@ HttpChannelChild::CompleteRedirectSetup(
     // called from either OnRedirectVerifyCallback via OverrideRunnable, or from
     // RecvRedirect3Complete. The order of events must always be:
     //  1. Teardown the IPDL connection
     //  2. AsyncOpen the connection again
     //  3. Cleanup the redirecting channel (the one calling Redirect3Complete)
     //  4. [optional] Call OverrideWithSynthesizedResponse on the redirected
     //  channel if the call came from OverrideRunnable.
     mInterceptedRedirectListener = aListener;
-    mInterceptedRedirectContext = aContext;
-
     // This will send a message to the parent notifying it that we are closing
     // down. After closing the IPC channel, we will proceed to execute
     // FinishInterceptedRedirect() which AsyncOpen's the channel again.
     SendFinishInterceptedRedirect();
 
     // XXX valentin: The interception logic should be rewritten to avoid
     // calling AsyncOpen on the channel _after_ we call Send__delete__()
     return NS_OK;
--- a/netwerk/protocol/http/HttpChannelChild.h
+++ b/netwerk/protocol/http/HttpChannelChild.h
@@ -347,17 +347,16 @@ class HttpChannelChild final : public PH
 
  private:
   // this section is for main-thread-only object
   // all the references need to be proxy released on main thread.
   nsCOMPtr<nsIChildChannel> mRedirectChannelChild;
   RefPtr<InterceptStreamListener> mInterceptListener;
   // Needed to call AsyncOpen in FinishInterceptedRedirect
   nsCOMPtr<nsIStreamListener> mInterceptedRedirectListener;
-  nsCOMPtr<nsISupports> mInterceptedRedirectContext;
 
   // Proxy release all members above on main thread.
   void ReleaseMainThreadOnlyReferences();
 
  private:
   nsCString mCachedCharset;
   nsCString mProtocolVersion;
 
--- a/netwerk/protocol/viewsource/nsViewSourceChannel.cpp
+++ b/netwerk/protocol/viewsource/nsViewSourceChannel.cpp
@@ -1069,18 +1069,17 @@ void nsViewSourceChannel::SetHasNonEmpty
 NS_IMETHODIMP
 nsViewSourceChannel::ConnectParent(uint32_t aRegistarId) {
   NS_ENSURE_TRUE(mChildChannel, NS_ERROR_NULL_POINTER);
 
   return mChildChannel->ConnectParent(aRegistarId);
 }
 
 NS_IMETHODIMP
-nsViewSourceChannel::CompleteRedirectSetup(nsIStreamListener* aListener,
-                                           nsISupports* aContext) {
+nsViewSourceChannel::CompleteRedirectSetup(nsIStreamListener* aListener) {
   NS_ENSURE_TRUE(mChildChannel, NS_ERROR_NULL_POINTER);
 
   mListener = aListener;
 
   /*
    * We want to add ourselves to the loadgroup before opening
    * mChannel, since we want to make sure we're in the loadgroup
    * when mChannel finishes and fires OnStopRequest()
@@ -1088,17 +1087,17 @@ nsViewSourceChannel::CompleteRedirectSet
 
   nsCOMPtr<nsILoadGroup> loadGroup;
   mChannel->GetLoadGroup(getter_AddRefs(loadGroup));
   if (loadGroup) {
     loadGroup->AddRequest(static_cast<nsIViewSourceChannel*>(this), nullptr);
   }
 
   nsresult rv = NS_OK;
-  rv = mChildChannel->CompleteRedirectSetup(this, aContext);
+  rv = mChildChannel->CompleteRedirectSetup(this);
 
   if (NS_FAILED(rv) && loadGroup) {
     loadGroup->RemoveRequest(static_cast<nsIViewSourceChannel*>(this), nullptr,
                              rv);
   }
 
   if (NS_SUCCEEDED(rv)) {
     mOpened = true;
--- a/uriloader/base/nsURILoader.cpp
+++ b/uriloader/base/nsURILoader.cpp
@@ -722,17 +722,17 @@ NS_IMETHODIMP nsURILoader::OpenURI(nsICh
     }
   }
 
   if (aFlags & nsIURILoader::REDIRECTED_CHANNEL) {
     // Our channel was redirected from another process, so doesn't need to
     // be opened again. However, it does need its listener hooked up
     // correctly.
     if (nsCOMPtr<nsIChildChannel> childChannel = do_QueryInterface(channel)) {
-      return childChannel->CompleteRedirectSetup(loader, nullptr);
+      return childChannel->CompleteRedirectSetup(loader);
     }
 
     // It's possible for the redirected channel to not implement
     // nsIChildChannel and be entirely local (like srcdoc). In that case we
     // can just open the local instance and it will work.
   }
 
   // This method is not complete. Eventually, we should first go
--- a/uriloader/exthandler/nsExternalProtocolHandler.cpp
+++ b/uriloader/exthandler/nsExternalProtocolHandler.cpp
@@ -369,17 +369,17 @@ NS_IMETHODIMP nsExtProtocolChannel::Resu
 
 NS_IMETHODIMP nsExtProtocolChannel::ConnectParent(uint32_t registrarId) {
   mozilla::dom::ContentChild::GetSingleton()
       ->SendExtProtocolChannelConnectParent(registrarId);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsExtProtocolChannel::CompleteRedirectSetup(
-    nsIStreamListener* listener, nsISupports* context) {
+    nsIStreamListener* listener) {
   // For redirects to external protocols we AsyncOpen on the child
   // (not the parent) because child channel has the right docshell
   // (which is needed for the select dialog).
   return AsyncOpen(listener);
 }
 
 ///////////////////////////////////////////////////////////////////////
 // From nsIParentChannel (derives from nsIStreamListener)