Bug 1213150 - Part 2: Rework ShouldPrepareForIntercept() in terms of subresource requests; r=jdm
☠☠ backed out by 72703ed7364a ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 06 Oct 2015 22:40:36 -0400
changeset 296411 274255b2f25bce2f54b692b33f8fdc9a14a14ae8
parent 296410 64af6c22c6b7070a695d33d06fc01e66630c6702
child 296412 ac129c8e6dfbdc727076c6117b9a28787e86f09e
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
bugs1213150
milestone43.0a2
Bug 1213150 - Part 2: Rework ShouldPrepareForIntercept() in terms of subresource requests; r=jdm
docshell/base/nsDocShell.cpp
modules/libjar/nsJARChannel.cpp
netwerk/base/nsINetworkInterceptController.idl
netwerk/protocol/http/HttpBaseChannel.cpp
netwerk/protocol/http/HttpChannelParent.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -13841,17 +13841,17 @@ nsDocShell::MaybeNotifyKeywordSearchLoad
         obsSvc->NotifyObservers(searchEngine, "keyword-search", aKeyword.get());
       }
     }
   }
 #endif
 }
 
 NS_IMETHODIMP
-nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate,
+nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNonSubresourceRequest,
                                       bool* aShouldIntercept)
 {
   *aShouldIntercept = false;
   // Preffed off.
   if (!nsContentUtils::ServiceWorkerInterceptionEnabled()) {
     return NS_OK;
   }
 
@@ -13894,17 +13894,17 @@ nsDocShell::ShouldPrepareForIntercept(ns
           (Preferences::GetInt("network.cookie.cookieBehavior",
                                nsICookieService::BEHAVIOR_ACCEPT) ==
                                nsICookieService::BEHAVIOR_REJECT_FOREIGN)) {
         return NS_OK;
       }
     }
   }
 
-  if (aIsNavigate) {
+  if (aIsNonSubresourceRequest) {
     OriginAttributes attrs(GetAppId(), GetIsInBrowserElement());
     *aShouldIntercept = swm->IsAvailable(attrs, aURI);
     return NS_OK;
   }
 
   nsCOMPtr<nsIDocument> doc = GetDocument();
   if (!doc) {
     return NS_ERROR_NOT_AVAILABLE;
--- a/modules/libjar/nsJARChannel.cpp
+++ b/modules/libjar/nsJARChannel.cpp
@@ -878,19 +878,18 @@ nsJARChannel::ShouldIntercept()
     }
 
     nsCOMPtr<nsINetworkInterceptController> controller;
     NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup,
                                   NS_GET_IID(nsINetworkInterceptController),
                                   getter_AddRefs(controller));
     bool shouldIntercept = false;
     if (controller && !BypassServiceWorker() && mLoadInfo) {
-      bool isNavigation = mLoadFlags & LOAD_DOCUMENT_URI;
       nsresult rv = controller->ShouldPrepareForIntercept(mAppURI,
-                                                          isNavigation,
+                                                          nsContentUtils::IsNonSubresourceRequest(this),
                                                           &shouldIntercept);
       NS_ENSURE_SUCCESS(rv, false);
     }
 
     return shouldIntercept;
 }
 
 void nsJARChannel::ResetInterception()
--- a/netwerk/base/nsINetworkInterceptController.idl
+++ b/netwerk/base/nsINetworkInterceptController.idl
@@ -84,27 +84,27 @@ interface nsIInterceptedChannel : nsISup
 };
 
 /**
  * Interface to allow consumers to attach themselves to a channel's
  * notification callbacks/loadgroup and determine if a given channel
  * request should be intercepted before any network request is initiated.
  */
 
-[scriptable, uuid(69150b77-b561-43a2-bfba-7301dd5a35d0)]
+[scriptable, uuid(49eb1997-90fb-49d6-a25d-41f51c7c99e8)]
 interface nsINetworkInterceptController : nsISupports
 {
     /**
      * Returns true if a channel should avoid initiating any network
      * requests until specifically instructed to do so.
      *
      * @param aURI the URI being requested by a channel
      * @param aIsNavigate True if the request is for a navigation, false for a fetch.
      */
-    bool shouldPrepareForIntercept(in nsIURI aURI, in bool aIsNavigate);
+    bool shouldPrepareForIntercept(in nsIURI aURI, in bool aIsNonSubresourceRequest);
 
     /**
      * Notification when a given intercepted channel is prepared to accept a synthesized
      * response via the provided stream.
      *
      * @param aChannel the controlling interface for a channel that has been intercepted
      */
     void channelIntercepted(in nsIInterceptedChannel aChannel);
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -2223,17 +2223,17 @@ HttpBaseChannel::BypassServiceWorker() c
 bool
 HttpBaseChannel::ShouldIntercept()
 {
   nsCOMPtr<nsINetworkInterceptController> controller;
   GetCallback(controller);
   bool shouldIntercept = false;
   if (controller && !BypassServiceWorker() && mLoadInfo) {
     nsresult rv = controller->ShouldPrepareForIntercept(mURI,
-                                                        IsNavigation(),
+                                                        nsContentUtils::IsNonSubresourceRequest(this),
                                                         &shouldIntercept);
     if (NS_FAILED(rv)) {
       return false;
     }
   }
   return shouldIntercept;
 }
 
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -150,17 +150,19 @@ NS_IMPL_ISUPPORTS(HttpChannelParent,
                   nsIRequestObserver,
                   nsIStreamListener,
                   nsIParentChannel,
                   nsIAuthPromptProvider,
                   nsIParentRedirectingChannel,
                   nsINetworkInterceptController)
 
 NS_IMETHODIMP
-HttpChannelParent::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate, bool* aShouldIntercept)
+HttpChannelParent::ShouldPrepareForIntercept(nsIURI* aURI,
+                                             bool aIsNonSubresourceRequest,
+                                             bool* aShouldIntercept)
 {
   *aShouldIntercept = mShouldIntercept;
   return NS_OK;
 }
 
 class HeaderVisitor final : public nsIHttpHeaderVisitor
 {
   nsCOMPtr<nsIInterceptedChannel> mChannel;