Bug 1389738 - Remove @deprecated nsIHttpEventSink. r?mcmanus draft
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Sat, 12 Aug 2017 18:26:23 +0900
changeset 645274 97113ca2796a1839606544f71ebabdc3ae59aec5
parent 645264 55a6e16c20dbb095a1e96f5709c391f6b05c0f35
child 725875 c7dfc6436b478195c75ddce111cfd4e1cea42ca7
push id73725
push userVYV03354@nifty.ne.jp
push dateSat, 12 Aug 2017 09:51:58 +0000
reviewersmcmanus
bugs1389738
milestone57.0a1
Bug 1389738 - Remove @deprecated nsIHttpEventSink. r?mcmanus MozReview-Commit-ID: 5TaiTc6fSLK
netwerk/base/nsBaseChannel.cpp
netwerk/protocol/http/HttpChannelParentListener.cpp
netwerk/protocol/http/moz.build
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/protocol/http/nsIHttpEventSink.idl
toolkit/components/search/nsSearchService.js
--- a/netwerk/base/nsBaseChannel.cpp
+++ b/netwerk/base/nsBaseChannel.cpp
@@ -7,17 +7,16 @@
 #include "nsBaseChannel.h"
 #include "nsContentUtils.h"
 #include "nsURLHelper.h"
 #include "nsNetCID.h"
 #include "nsMimeTypes.h"
 #include "nsIContentSniffer.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsMimeTypes.h"
-#include "nsIHttpEventSink.h"
 #include "nsIHttpChannel.h"
 #include "nsIChannelEventSink.h"
 #include "nsIStreamConverterService.h"
 #include "nsChannelClassifier.h"
 #include "nsAsyncRedirectVerifyHelper.h"
 #include "nsProxyRelease.h"
 #include "nsXULAppAPI.h"
 #include "nsContentSecurityManager.h"
@@ -126,19 +125,17 @@ nsBaseChannel::Redirect(nsIChannel *newC
 
   nsCOMPtr<nsIWritablePropertyBag> bag = ::do_QueryInterface(newChannel);
   if (bag) {
     for (auto iter = mPropertyHash.Iter(); !iter.Done(); iter.Next()) {
       bag->SetProperty(iter.Key(), iter.UserData());
     }
   }
 
-  // Notify consumer, giving chance to cancel redirect.  For backwards compat,
-  // we support nsIHttpEventSink if we are an HTTP channel and if this is not
-  // an internal redirect.
+  // Notify consumer, giving chance to cancel redirect.
 
   RefPtr<nsAsyncRedirectVerifyHelper> redirectCallbackHelper =
       new nsAsyncRedirectVerifyHelper();
 
   bool checkRedirectSynchronously = !openNewChannel;
   nsCOMPtr<nsIEventTarget> target = GetNeckoTarget();
 
   mRedirectChannel = newChannel;
@@ -153,33 +150,16 @@ nsBaseChannel::Redirect(nsIChannel *newC
     return mStatus;
 
   return NS_OK;
 }
 
 nsresult
 nsBaseChannel::ContinueRedirect()
 {
-  // Backwards compat for non-internal redirects from a HTTP channel.
-  // XXX Is our http channel implementation going to derive from nsBaseChannel?
-  //     If not, this code can be removed.
-  if (!(mRedirectFlags & nsIChannelEventSink::REDIRECT_INTERNAL)) {
-    nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface();
-    if (httpChannel) {
-      nsCOMPtr<nsIHttpEventSink> httpEventSink;
-      GetCallback(httpEventSink);
-      if (httpEventSink) {
-        nsresult rv = httpEventSink->OnRedirect(httpChannel, mRedirectChannel);
-        if (NS_FAILED(rv)) {
-          return rv;
-        }
-      }
-    }
-  }
-
   // Make sure to do this _after_ making all the OnChannelRedirect calls
   mRedirectChannel->SetOriginalURI(OriginalURI());
 
   // If we fail to open the new channel, then we want to leave this channel
   // unaffected, so we defer tearing down our channel until we have succeeded
   // with the redirect.
 
   if (mOpenRedirectChannel) {
--- a/netwerk/protocol/http/HttpChannelParentListener.cpp
+++ b/netwerk/protocol/http/HttpChannelParentListener.cpp
@@ -7,17 +7,16 @@
 // HttpLog.h should generally be included first
 #include "HttpLog.h"
 
 #include "HttpChannelParentListener.h"
 #include "mozilla/net/HttpChannelParent.h"
 #include "mozilla/Unused.h"
 #include "nsIAuthPrompt.h"
 #include "nsIAuthPrompt2.h"
-#include "nsIHttpEventSink.h"
 #include "nsIHttpHeaderVisitor.h"
 #include "nsIRedirectChannelRegistrar.h"
 #include "nsIPromptFactory.h"
 #include "nsIWindowWatcher.h"
 #include "nsQueryObject.h"
 
 using mozilla::Unused;
 
@@ -118,17 +117,16 @@ HttpChannelParentListener::OnDataAvailab
 //-----------------------------------------------------------------------------
 // HttpChannelParentListener::nsIInterfaceRequestor
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 HttpChannelParentListener::GetInterface(const nsIID& aIID, void **result)
 {
   if (aIID.Equals(NS_GET_IID(nsIChannelEventSink)) ||
-      aIID.Equals(NS_GET_IID(nsIHttpEventSink))  ||
       aIID.Equals(NS_GET_IID(nsINetworkInterceptController))  ||
       aIID.Equals(NS_GET_IID(nsIRedirectResultListener)))
   {
     return QueryInterface(aIID, result);
   }
 
   nsCOMPtr<nsIInterfaceRequestor> ir;
   if (mNextListener &&
--- a/netwerk/protocol/http/moz.build
+++ b/netwerk/protocol/http/moz.build
@@ -13,17 +13,16 @@ XPIDL_SOURCES += [
     'nsIHttpActivityObserver.idl',
     'nsIHttpAuthenticableChannel.idl',
     'nsIHttpAuthenticator.idl',
     'nsIHttpAuthManager.idl',
     'nsIHttpChannel.idl',
     'nsIHttpChannelAuthProvider.idl',
     'nsIHttpChannelChild.idl',
     'nsIHttpChannelInternal.idl',
-    'nsIHttpEventSink.idl',
     'nsIHttpHeaderVisitor.idl',
     'nsIHttpProtocolHandler.idl',
     'nsIRaceCacheWithNetwork.idl',
     'nsIWellKnownOpportunisticUtils.idl',
 ]
 
 XPIDL_MODULE = 'necko_http'
 
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -71,17 +71,16 @@
 #include "nsIWebProgressListener.h"
 #include "LoadContextInfo.h"
 #include "netCore.h"
 #include "nsHttpTransaction.h"
 #include "nsICacheEntryDescriptor.h"
 #include "nsICancelable.h"
 #include "nsIHttpChannelAuthProvider.h"
 #include "nsIHttpChannelInternal.h"
-#include "nsIHttpEventSink.h"
 #include "nsIPrompt.h"
 #include "nsInputStreamPump.h"
 #include "nsURLHelper.h"
 #include "nsISocketTransport.h"
 #include "nsIStreamConverterService.h"
 #include "nsISiteSecurityService.h"
 #include "nsString.h"
 #include "nsCRT.h"
@@ -3009,28 +3008,16 @@ nsresult
 nsHttpChannel::OpenRedirectChannel(nsresult rv)
 {
     AutoRedirectVetoNotifier notifier(this);
 
     // Make sure to do this after we received redirect veto answer,
     // i.e. after all sinks had been notified
     mRedirectChannel->SetOriginalURI(mOriginalURI);
 
-    // And now, notify observers the deprecated way
-    nsCOMPtr<nsIHttpEventSink> httpEventSink;
-    GetCallback(httpEventSink);
-    if (httpEventSink) {
-        // NOTE: nsIHttpEventSink is only used for compatibility with pre-1.8
-        // versions.
-        rv = httpEventSink->OnRedirect(this, mRedirectChannel);
-        if (NS_FAILED(rv)) {
-            return rv;
-        }
-    }
-
     // open new channel
     if (mLoadInfo && mLoadInfo->GetEnforceSecurity()) {
         MOZ_ASSERT(!mListenerContext, "mListenerContext should be null!");
         rv = mRedirectChannel->AsyncOpen2(mListener);
     }
     else {
         rv = mRedirectChannel->AsyncOpen(mListener, mListenerContext);
     }
@@ -5788,26 +5775,16 @@ nsHttpChannel::ContinueProcessRedirectio
         return rv;
 
     NS_PRECONDITION(mRedirectChannel, "No redirect channel?");
 
     // Make sure to do this after we received redirect veto answer,
     // i.e. after all sinks had been notified
     mRedirectChannel->SetOriginalURI(mOriginalURI);
 
-    // And now, the deprecated way
-    nsCOMPtr<nsIHttpEventSink> httpEventSink;
-    GetCallback(httpEventSink);
-    if (httpEventSink) {
-        // NOTE: nsIHttpEventSink is only used for compatibility with pre-1.8
-        // versions.
-        rv = httpEventSink->OnRedirect(this, mRedirectChannel);
-        if (NS_FAILED(rv))
-            return rv;
-    }
     // XXX we used to talk directly with the script security manager, but that
     // should really be handled by the event sink implementation.
 
     // begin loading the new channel
     if (mLoadInfo && mLoadInfo->GetEnforceSecurity()) {
         MOZ_ASSERT(!mListenerContext, "mListenerContext should be null!");
         rv = mRedirectChannel->AsyncOpen2(mListener);
     }
deleted file mode 100644
--- a/netwerk/protocol/http/nsIHttpEventSink.idl
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsISupports.idl"
-
-interface nsIChannel;
-interface nsIHttpChannel;
-interface nsIURI;
-
-/**
- * nsIHttpEventSink
- *
- * Implement this interface to receive control over various HTTP events.  The
- * HTTP channel will try to get this interface from its notificationCallbacks
- * attribute, and if it doesn't find it there it will look for it from its
- * loadGroup's notificationCallbacks attribute.
- *
- * These methods are called before onStartRequest, and should be handled
- * SYNCHRONOUSLY.
- *
- * @deprecated Newly written code should use nsIChannelEventSink instead of this
- * interface.
- */
-[scriptable, uuid(9475a6af-6352-4251-90f9-d65b1cd2ea15)]
-interface nsIHttpEventSink : nsISupports
-{
-    /**
-     * Called when a redirect occurs due to a HTTP response like 302.  The
-     * redirection may be to a non-http channel.
-     *
-     * @return failure cancels redirect
-     */
-    [must_use] void onRedirect(in nsIHttpChannel httpChannel,
-                               in nsIChannel newChannel);
-};
--- a/toolkit/components/search/nsSearchService.js
+++ b/toolkit/components/search/nsSearchService.js
@@ -281,18 +281,16 @@ loadListener.prototype = {
   _engine: null,
   _stream: null,
 
   QueryInterface: XPCOMUtils.generateQI([
     Ci.nsIRequestObserver,
     Ci.nsIStreamListener,
     Ci.nsIChannelEventSink,
     Ci.nsIInterfaceRequestor,
-    // See FIXME comment below.
-    Ci.nsIHttpEventSink,
     Ci.nsIProgressEventSink
   ]),
 
   // nsIRequestObserver
   onStartRequest: function SRCH_loadStartR(aRequest, aContext) {
     LOG("loadListener: Starting request: " + aRequest.name);
     this._stream = Cc["@mozilla.org/binaryinputstream;1"].
                    createInstance(Ci.nsIBinaryInputStream);
@@ -333,19 +331,16 @@ loadListener.prototype = {
     callback.onRedirectVerifyCallback(Components.results.NS_OK);
   },
 
   // nsIInterfaceRequestor
   getInterface: function SRCH_load_GI(aIID) {
     return this.QueryInterface(aIID);
   },
 
-  // FIXME: bug 253127
-  // nsIHttpEventSink
-  onRedirect(aChannel, aNewChannel) {},
   // nsIProgressEventSink
   onProgress(aRequest, aContext, aProgress, aProgressMax) {},
   onStatus(aRequest, aContext, aStatus, aStatusArg) {}
 }
 
 function isPartnerBuild() {
   try {
     let distroID = Services.prefs.getCharPref("distribution.id");