Bug 1210941 P3 Make jar channels use LOAD_BYPASS_SERVICE_WORKER internally. r=jduell
authorBen Kelly <ben@wanderview.com>
Tue, 06 Oct 2015 06:37:06 -0700
changeset 266265 9525edea379d7986d13001b4fc7c30917e853042
parent 266264 8b44bb42ae5c4b4b055b710824ac1db1e869698e
child 266266 b51bece75129d014624ed3e49e644c4153ebb807
push id66154
push userbkelly@mozilla.com
push dateTue, 06 Oct 2015 13:37:16 +0000
treeherdermozilla-inbound@89416f2918ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjduell
bugs1210941
milestone44.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 1210941 P3 Make jar channels use LOAD_BYPASS_SERVICE_WORKER internally. r=jduell
modules/libjar/nsJARChannel.cpp
modules/libjar/nsJARChannel.h
--- a/modules/libjar/nsJARChannel.cpp
+++ b/modules/libjar/nsJARChannel.cpp
@@ -198,17 +198,16 @@ nsJARChannel::nsJARChannel()
     , mAppURI(nullptr)
     , mContentLength(-1)
     , mLoadFlags(LOAD_NORMAL)
     , mStatus(NS_OK)
     , mIsPending(false)
     , mIsUnsafe(true)
     , mOpeningRemote(false)
     , mSynthesizedStreamLength(0)
-    , mForceNoIntercept(false)
     , mBlockRemoteFiles(false)
 {
     if (!gJarProtocolLog)
         gJarProtocolLog = PR_NewLogModule("nsJarProtocol");
 
     mBlockRemoteFiles = Preferences::GetBool("network.jar.block-remote-files", false);
 
     // hold an owning reference to the jar handler
@@ -859,30 +858,36 @@ nsJARChannel::Open2(nsIInputStream** aSt
 {
     nsCOMPtr<nsIStreamListener> listener;
     nsresult rv = nsContentSecurityManager::doContentSecurityCheck(this, listener);
     NS_ENSURE_SUCCESS(rv, rv);
     return Open(aStream);
 }
 
 bool
+nsJARChannel::BypassServiceWorker() const
+{
+  return mLoadFlags & LOAD_BYPASS_SERVICE_WORKER;
+}
+
+bool
 nsJARChannel::ShouldIntercept()
 {
     LOG(("nsJARChannel::ShouldIntercept [this=%x]\n", this));
     // We only intercept app:// requests
     if (!mAppURI) {
       return false;
     }
 
     nsCOMPtr<nsINetworkInterceptController> controller;
     NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup,
                                   NS_GET_IID(nsINetworkInterceptController),
                                   getter_AddRefs(controller));
     bool shouldIntercept = false;
-    if (controller && !mForceNoIntercept && mLoadInfo) {
+    if (controller && !BypassServiceWorker() && mLoadInfo) {
       bool isNavigation = mLoadFlags & LOAD_DOCUMENT_URI;
       nsContentPolicyType type = mLoadInfo->InternalContentPolicyType();
       nsresult rv = controller->ShouldPrepareForIntercept(mAppURI,
                                                           isNavigation,
                                                           type,
                                                           &shouldIntercept);
       NS_ENSURE_SUCCESS(rv, false);
     }
@@ -1119,17 +1124,17 @@ nsJARChannel::GetZipEntry(nsIZipEntry **
         return rv;
 
     return reader->GetEntry(mJarEntry, aZipEntry);
 }
 
 NS_IMETHODIMP
 nsJARChannel::ForceNoIntercept()
 {
-    mForceNoIntercept = true;
+    mLoadFlags |= LOAD_BYPASS_SERVICE_WORKER;
     return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 // mozilla::net::MemoryDownloader::IObserver
 //-----------------------------------------------------------------------------
 
 void
--- a/modules/libjar/nsJARChannel.h
+++ b/modules/libjar/nsJARChannel.h
@@ -75,16 +75,18 @@ private:
     nsresult SetRemoteNSPRFileDesc(PRFileDesc *fd);
     virtual void OnDownloadComplete(mozilla::net::MemoryDownloader* aDownloader,
                                     nsIRequest* aRequest,
                                     nsISupports* aCtxt,
                                     nsresult aStatus,
                                     mozilla::net::MemoryDownloader::Data aData)
         override;
 
+    bool BypassServiceWorker() const;
+
     // Returns true if this channel should intercept the network request and
     // prepare for a possible synthesized response instead.
     bool ShouldIntercept();
 
     nsresult ContinueAsyncOpen();
     void FinishAsyncOpen();
 
     // Discard the prior interception and continue with the original network
@@ -131,17 +133,14 @@ private:
     nsCOMPtr<nsIFile>               mJarFile;
     nsCOMPtr<nsIURI>                mJarBaseURI;
     nsCString                       mJarEntry;
     nsCString                       mInnerJarEntry;
 
     nsRefPtr<nsInputStreamPump>     mSynthesizedResponsePump;
     int64_t                         mSynthesizedStreamLength;
 
-    // True if this channel should skip any interception checks.
-    bool                            mForceNoIntercept;
-
     // True if this channel should not download any remote files.
     bool                            mBlockRemoteFiles;
     friend class mozilla::net::InterceptedJARChannel;
 };
 
 #endif // nsJARChannel_h__