Bug 1130101 - Part 1: Store the value of the Service-Worker-Allowed header in the CompareManager object; r=nsm
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 06 May 2015 01:14:50 -0400
changeset 274274 7409a86dcf4147520fae67a94999182cbfd7aab2
parent 274273 d322cc152e81c1ea636d5a5e1eaa1f826c359525
child 274275 78224d2bdde4cbadc3607d9b7ed50c0ca43db873
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnsm
bugs1130101
milestone40.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 1130101 - Part 1: Store the value of the Service-Worker-Allowed header in the CompareManager object; r=nsm
dom/workers/ServiceWorkerScriptCache.cpp
netwerk/protocol/http/nsHttpAtomList.h
--- a/dom/workers/ServiceWorkerScriptCache.cpp
+++ b/dom/workers/ServiceWorkerScriptCache.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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 "ServiceWorkerScriptCache.h"
+#include "mozilla/unused.h"
 #include "mozilla/dom/CacheBinding.h"
 #include "mozilla/dom/cache/CacheStorage.h"
 #include "mozilla/dom/cache/Cache.h"
 #include "nsIThreadRetargetableRequest.h"
 #include "nsSerializationHelper.h"
 
 #include "nsIPrincipal.h"
 #include "Workers.h"
@@ -317,16 +318,23 @@ public:
   const nsAString&
   URL() const
   {
     AssertIsOnMainThread();
     return mURL;
   }
 
   void
+  SetMaxScope(const nsACString& aMaxScope)
+  {
+    MOZ_ASSERT(!mNetworkFinished);
+    mMaxScope = aMaxScope;
+  }
+
+  void
   NetworkFinished(nsresult aStatus)
   {
     AssertIsOnMainThread();
 
     mNetworkFinished = true;
 
     if (NS_FAILED(aStatus)) {
       if (mCC) {
@@ -564,16 +572,18 @@ private:
   nsRefPtr<CompareCache> mCC;
 
   nsString mURL;
   // Only used if the network script has changed and needs to be cached.
   nsString mNewCacheName;
 
   nsCString mSecurityInfo;
 
+  nsCString mMaxScope;
+
   enum {
     WaitingForOpen,
     WaitingForPut
   } mState;
 
   bool mNetworkFinished;
   bool mCacheFinished;
   bool mInCache;
@@ -643,16 +653,24 @@ CompareNetwork::OnStreamComplete(nsIStre
       mManager->NetworkFinished(rv);
       return NS_OK;
     }
 
     if (!requestSucceeded) {
       mManager->NetworkFinished(NS_ERROR_FAILURE);
       return NS_OK;
     }
+
+    nsAutoCString maxScope;
+    // Note: we explicitly don't check for the return value here, because the
+    // absense of the header is not an error condition.
+    unused << httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Service-Worker-Allowed"),
+                                             maxScope);
+
+    mManager->SetMaxScope(maxScope);
   }
   else {
     // The only supported request schemes are http, https, and app.
     // Above, we check to ensure that the request is http or https
     // based on the channel qi.  Here we test the scheme to ensure
     // that it is app.  Otherwise, bail.
     nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
     if (NS_WARN_IF(!channel)) {
--- a/netwerk/protocol/http/nsHttpAtomList.h
+++ b/netwerk/protocol/http/nsHttpAtomList.h
@@ -67,16 +67,17 @@ HTTP_ATOM(Pragma,                    "Pr
 HTTP_ATOM(Prefer,                    "Prefer")
 HTTP_ATOM(Proxy_Authenticate,        "Proxy-Authenticate")
 HTTP_ATOM(Proxy_Authorization,       "Proxy-Authorization")
 HTTP_ATOM(Proxy_Connection,          "Proxy-Connection")
 HTTP_ATOM(Range,                     "Range")
 HTTP_ATOM(Referer,                   "Referer")
 HTTP_ATOM(Retry_After,               "Retry-After")
 HTTP_ATOM(Server,                    "Server")
+HTTP_ATOM(Service_Worker_Allowed,    "Service-Worker-Allowed")
 HTTP_ATOM(Set_Cookie,                "Set-Cookie")
 HTTP_ATOM(Set_Cookie2,               "Set-Cookie2")
 HTTP_ATOM(Status_URI,                "Status-URI")
 HTTP_ATOM(TE,                        "TE")
 HTTP_ATOM(Title,                     "Title")
 HTTP_ATOM(Timeout,                   "Timeout")
 HTTP_ATOM(Trailer,                   "Trailer")
 HTTP_ATOM(Transfer_Encoding,         "Transfer-Encoding")