Bug 1213150 - Part 3: Remove nsIInterceptedChannel.isNavigation; r=jdm a=lizzard
☠☠ backed out by 72703ed7364a ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 06 Oct 2015 22:52:43 -0400
changeset 296412 ac129c8e6dfbdc727076c6117b9a28787e86f09e
parent 296411 274255b2f25bce2f54b692b33f8fdc9a14a14ae8
child 296413 6ee2ce4e485f5ffcebd2573531cabe9d08c16b25
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm, lizzard
bugs1213150
milestone43.0a2
Bug 1213150 - Part 3: Remove nsIInterceptedChannel.isNavigation; r=jdm a=lizzard
modules/libjar/InterceptedJARChannel.cpp
modules/libjar/InterceptedJARChannel.h
modules/libjar/nsJARChannel.cpp
netwerk/base/nsINetworkInterceptController.idl
netwerk/protocol/http/InterceptedChannel.cpp
netwerk/protocol/http/InterceptedChannel.h
--- a/modules/libjar/InterceptedJARChannel.cpp
+++ b/modules/libjar/InterceptedJARChannel.cpp
@@ -8,35 +8,38 @@
 #include "nsIPipe.h"
 #include "mozilla/dom/ChannelInfo.h"
 
 using namespace mozilla::net;
 
 NS_IMPL_ISUPPORTS(InterceptedJARChannel, nsIInterceptedChannel)
 
 InterceptedJARChannel::InterceptedJARChannel(nsJARChannel* aChannel,
-                                             nsINetworkInterceptController* aController,
-                                             bool aIsNavigation)
+                                             nsINetworkInterceptController* aController)
 : mController(aController)
 , mChannel(aChannel)
-, mIsNavigation(aIsNavigation)
 {
 }
 
 NS_IMETHODIMP
 InterceptedJARChannel::GetResponseBody(nsIOutputStream** aStream)
 {
   NS_IF_ADDREF(*aStream = mResponseBody);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-InterceptedJARChannel::GetIsNavigation(bool* aIsNavigation)
+InterceptedJARChannel::GetInternalContentPolicyType(nsContentPolicyType* aPolicyType)
 {
-  *aIsNavigation = mIsNavigation;
+  NS_ENSURE_ARG(aPolicyType);
+  nsCOMPtr<nsILoadInfo> loadInfo;
+  nsresult rv = mChannel->GetLoadInfo(getter_AddRefs(loadInfo));
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  *aPolicyType = loadInfo->InternalContentPolicyType();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 InterceptedJARChannel::GetChannel(nsIChannel** aChannel)
 {
   NS_IF_ADDREF(*aChannel = mChannel);
   return NS_OK;
--- a/modules/libjar/InterceptedJARChannel.h
+++ b/modules/libjar/InterceptedJARChannel.h
@@ -39,24 +39,20 @@ class InterceptedJARChannel : public nsI
   nsCOMPtr<nsIInputStream> mSynthesizedInput;
 
   // The stream to write the body of the synthesized response.
   nsCOMPtr<nsIOutputStream> mResponseBody;
 
   // The content type of the synthesized response.
   nsCString mContentType;
 
-  // Wether this intercepted channel was performing a navigation.
-  bool mIsNavigation;
-
   virtual ~InterceptedJARChannel() {};
 public:
   InterceptedJARChannel(nsJARChannel* aChannel,
-                        nsINetworkInterceptController* aController,
-                        bool aIsNavigation);
+                        nsINetworkInterceptController* aController);
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIINTERCEPTEDCHANNEL
 
   void NotifyController();
 };
 
 } // namespace net
--- a/modules/libjar/nsJARChannel.cpp
+++ b/modules/libjar/nsJARChannel.cpp
@@ -963,19 +963,18 @@ nsJARChannel::AsyncOpen(nsIStreamListene
     // Check if this channel should intercept the network request and prepare
     // for a possible synthesized response instead.
     if (ShouldIntercept()) {
       nsCOMPtr<nsINetworkInterceptController> controller;
       NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup,
                                     NS_GET_IID(nsINetworkInterceptController),
                                     getter_AddRefs(controller));
 
-      bool isNavigation = mLoadFlags & LOAD_DOCUMENT_URI;
       nsRefPtr<InterceptedJARChannel> intercepted =
-        new InterceptedJARChannel(this, controller, isNavigation);
+        new InterceptedJARChannel(this, controller);
       intercepted->NotifyController();
 
       // We get the JAREntry so we can infer the content type later in case
       // that it isn't provided along with the synthesized response.
       nsresult rv = mJarURI->GetJAREntry(mJarEntry);
       if (NS_FAILED(rv)) {
           return rv;
       }
--- a/netwerk/base/nsINetworkInterceptController.idl
+++ b/netwerk/base/nsINetworkInterceptController.idl
@@ -21,17 +21,17 @@ class ChannelInfo;
 
 /**
  * Interface to allow implementors of nsINetworkInterceptController to control the behaviour
  * of intercepted channels without tying implementation details of the interception to
  * the actual channel. nsIInterceptedChannel is expected to be implemented by objects
  * which do not implement nsIChannel.
  */
 
-[scriptable, uuid(1062c96a-d73c-4ad5-beb7-6e803e414973)]
+[scriptable, uuid(6be00c37-2e85-42ee-b53c-e6508ce4cef0)]
 interface nsIInterceptedChannel : nsISupports
 {
     /**
      * Instruct a channel that has been intercepted to continue with the original
      * network request.
      */
     void resetInterception();
 
@@ -67,21 +67,16 @@ interface nsIInterceptedChannel : nsISup
     readonly attribute nsIOutputStream responseBody;
 
     /**
      * The underlying channel object that was intercepted.
      */
     readonly attribute nsIChannel channel;
 
     /**
-     * True if the underlying request was caused by a navigation attempt.
-     */
-    readonly attribute bool isNavigation;
-
-    /**
      * This method allows to override the channel info for the channel.
      */
     [noscript]
     void setChannelInfo(in ChannelInfo channelInfo);
 };
 
 /**
  * Interface to allow consumers to attach themselves to a channel's
--- a/netwerk/protocol/http/InterceptedChannel.cpp
+++ b/netwerk/protocol/http/InterceptedChannel.cpp
@@ -25,20 +25,18 @@ extern nsresult
 DoAddCacheEntryHeaders(nsHttpChannel *self,
                        nsICacheEntry *entry,
                        nsHttpRequestHead *requestHead,
                        nsHttpResponseHead *responseHead,
                        nsISupports *securityInfo);
 
 NS_IMPL_ISUPPORTS(InterceptedChannelBase, nsIInterceptedChannel)
 
-InterceptedChannelBase::InterceptedChannelBase(nsINetworkInterceptController* aController,
-                                               bool aIsNavigation)
+InterceptedChannelBase::InterceptedChannelBase(nsINetworkInterceptController* aController)
 : mController(aController)
-, mIsNavigation(aIsNavigation)
 {
 }
 
 InterceptedChannelBase::~InterceptedChannelBase()
 {
 }
 
 NS_IMETHODIMP
@@ -62,23 +60,16 @@ InterceptedChannelBase::DoNotifyControll
     nsresult rv = mController->ChannelIntercepted(this);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       rv = ResetInterception();
       NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to resume intercepted network request");
     }
     mController = nullptr;
 }
 
-NS_IMETHODIMP
-InterceptedChannelBase::GetIsNavigation(bool* aIsNavigation)
-{
-  *aIsNavigation = mIsNavigation;
-  return NS_OK;
-}
-
 nsresult
 InterceptedChannelBase::DoSynthesizeStatus(uint16_t aStatus, const nsACString& aReason)
 {
     EnsureSynthesizedResponse();
 
     // Always assume HTTP 1.1 for synthesized responses.
     nsAutoCString statusLine;
     statusLine.AppendLiteral("HTTP/1.1 ");
@@ -100,17 +91,17 @@ InterceptedChannelBase::DoSynthesizeHead
     nsresult rv = (*mSynthesizedResponseHead)->ParseHeaderLine(header.get());
     NS_ENSURE_SUCCESS(rv, rv);
     return NS_OK;
 }
 
 InterceptedChannelChrome::InterceptedChannelChrome(nsHttpChannel* aChannel,
                                                    nsINetworkInterceptController* aController,
                                                    nsICacheEntry* aEntry)
-: InterceptedChannelBase(aController, aChannel->IsNavigation())
+: InterceptedChannelBase(aController)
 , mChannel(aChannel)
 , mSynthesizedCacheEntry(aEntry)
 {
   nsresult rv = mChannel->GetApplyConversion(&mOldApplyConversion);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     mOldApplyConversion = false;
   }
 }
@@ -253,17 +244,17 @@ InterceptedChannelChrome::SetChannelInfo
   }
 
   return aChannelInfo->ResurrectInfoOnChannel(mChannel);
 }
 
 InterceptedChannelContent::InterceptedChannelContent(HttpChannelChild* aChannel,
                                                      nsINetworkInterceptController* aController,
                                                      nsIStreamListener* aListener)
-: InterceptedChannelBase(aController, aChannel->IsNavigation())
+: InterceptedChannelBase(aController)
 , mChannel(aChannel)
 , mStreamListener(aListener)
 {
 }
 
 void
 InterceptedChannelContent::NotifyController()
 {
--- a/netwerk/protocol/http/InterceptedChannel.h
+++ b/netwerk/protocol/http/InterceptedChannel.h
@@ -30,37 +30,32 @@ protected:
   nsCOMPtr<nsINetworkInterceptController> mController;
 
   // The stream to write the body of the synthesized response
   nsCOMPtr<nsIOutputStream> mResponseBody;
 
   // Response head for use when synthesizing
   Maybe<nsAutoPtr<nsHttpResponseHead>> mSynthesizedResponseHead;
 
-  // Whether this intercepted channel was performing a navigation.
-  bool mIsNavigation;
-
   void EnsureSynthesizedResponse();
   void DoNotifyController();
   nsresult DoSynthesizeStatus(uint16_t aStatus, const nsACString& aReason);
   nsresult DoSynthesizeHeader(const nsACString& aName, const nsACString& aValue);
 
   virtual ~InterceptedChannelBase();
 public:
-  InterceptedChannelBase(nsINetworkInterceptController* aController,
-                         bool aIsNavigation);
+  explicit InterceptedChannelBase(nsINetworkInterceptController* aController);
 
   // Notify the interception controller that the channel has been intercepted
   // and prepare the response body output stream.
   virtual void NotifyController() = 0;
 
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD GetResponseBody(nsIOutputStream** aOutput) override;
-  NS_IMETHOD GetIsNavigation(bool* aIsNavigation) override;
 };
 
 class InterceptedChannelChrome : public InterceptedChannelBase
 {
   // The actual channel being intercepted.
   nsRefPtr<nsHttpChannel> mChannel;
 
   // Writeable cache entry for use when synthesizing a response in a parent process