Backed out changeset 901f0df29f8f (bug 1337543) draft
authorSebastian Hengst <archaeopteryx@coole-files.de>
Mon, 13 Feb 2017 18:59:44 +0100
changeset 485876 2f48db94ca47fddb30e2e7861af583cb89ab365c
parent 485875 7002f4b5be972a6b6f0fa792a5d88b5e29b881bb
child 485877 9143c69f39ee94f304ea46b8ba258b7e92b6f1a4
push id45870
push userbmo:kechen@mozilla.com
push dateFri, 17 Feb 2017 09:36:54 +0000
bugs1337543
milestone54.0a1
backs out901f0df29f8fee6b33f7b8b5e581e6ff3a17aa6f
Backed out changeset 901f0df29f8f (bug 1337543)
dom/workers/ScriptLoader.cpp
dom/workers/ServiceWorkerScriptCache.cpp
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -666,17 +666,16 @@ private:
 
     nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
     MOZ_ASSERT(channel == loadInfo.mChannel);
 
     // We synthesize the result code, but its never exposed to content.
     RefPtr<mozilla::dom::InternalResponse> ir =
       new mozilla::dom::InternalResponse(200, NS_LITERAL_CSTRING("OK"));
     ir->SetBody(loadInfo.mCacheReadStream, InternalResponse::UNKNOWN_BODY_SIZE);
-
     // Drop our reference to the stream now that we've passed it along, so it
     // doesn't hang around once the cache is done with it and keep data alive.
     loadInfo.mCacheReadStream = nullptr;
 
     // Set the channel info of the channel on the response so that it's
     // saved in the cache.
     ir->InitChannelInfo(channel);
 
@@ -695,17 +694,16 @@ private:
     UniquePtr<PrincipalInfo> principalInfo(new PrincipalInfo());
     rv = PrincipalToPrincipalInfo(channelPrincipal, principalInfo.get());
     if (NS_WARN_IF(NS_FAILED(rv))) {
       channel->Cancel(rv);
       return rv;
     }
 
     ir->SetPrincipalInfo(Move(principalInfo));
-    ir->Headers()->FillResponseHeaders(loadInfo.mChannel);
 
     RefPtr<mozilla::dom::Response> response =
       new mozilla::dom::Response(mCacheCreator->Global(), ir);
 
     mozilla::dom::RequestOrUSVString request;
 
     MOZ_ASSERT(!loadInfo.mFullURL.IsEmpty());
     request.SetAsUSVString().Rebind(loadInfo.mFullURL.Data(),
--- a/dom/workers/ServiceWorkerScriptCache.cpp
+++ b/dom/workers/ServiceWorkerScriptCache.cpp
@@ -235,17 +235,16 @@ class CompareManager final : public Prom
 {
 public:
   NS_DECL_ISUPPORTS
 
   explicit CompareManager(ServiceWorkerRegistrationInfo* aRegistration,
                           CompareCallback* aCallback)
     : mRegistration(aRegistration)
     , mCallback(aCallback)
-    , mInternalHeaders(new InternalHeaders())
     , mState(WaitingForOpen)
     , mNetworkFinished(false)
     , mCacheFinished(false)
     , mInCache(false)
   {
     AssertIsOnMainThread();
     MOZ_ASSERT(aRegistration);
   }
@@ -430,29 +429,20 @@ public:
   CacheStorage*
   CacheStorage_()
   {
     AssertIsOnMainThread();
     MOZ_ASSERT(mCacheStorage);
     return mCacheStorage;
   }
 
-  nsresult
-  OnStartRequest(nsIChannel* aChannel)
+  void
+  InitChannelInfo(nsIChannel* aChannel)
   {
-    nsresult rv = SetPrincipalInfo(aChannel);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return rv;
-    }
-
     mChannelInfo.InitFromChannel(aChannel);
-
-    mInternalHeaders->FillResponseHeaders(aChannel);
-
-    return NS_OK;
   }
 
   nsresult
   SetPrincipalInfo(nsIChannel* aChannel)
   {
     nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
     NS_ASSERTION(ssm, "Should never be null!");
 
@@ -567,19 +557,16 @@ private:
       new InternalResponse(200, NS_LITERAL_CSTRING("OK"));
     ir->SetBody(body, mCN->Buffer().Length());
 
     ir->InitChannelInfo(mChannelInfo);
     if (mPrincipalInfo) {
       ir->SetPrincipalInfo(Move(mPrincipalInfo));
     }
 
-    IgnoredErrorResult ignored;
-    ir->Headers()->Fill(*mInternalHeaders, ignored);
-
     RefPtr<Response> response = new Response(aCache->GetGlobalObject(), ir);
 
     RequestOrUSVString request;
     request.SetAsUSVString().Rebind(URL().Data(), URL().Length());
 
     // For now we have to wait until the Put Promise is fulfilled before we can
     // continue since Cache does not yet support starting a read that is being
     // written to.
@@ -602,17 +589,16 @@ private:
   RefPtr<CompareNetwork> mCN;
   RefPtr<CompareCache> mCC;
 
   nsString mURL;
   // Only used if the network script has changed and needs to be cached.
   nsString mNewCacheName;
 
   ChannelInfo mChannelInfo;
-  RefPtr<InternalHeaders> mInternalHeaders;
 
   UniquePtr<mozilla::ipc::PrincipalInfo> mPrincipalInfo;
 
   nsCString mMaxScope;
 
   enum {
     WaitingForOpen,
     WaitingForPut
@@ -702,17 +688,18 @@ CompareNetwork::OnStartRequest(nsIReques
     return NS_OK;
   }
 
 #ifdef DEBUG
   nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
   MOZ_ASSERT(channel == mChannel);
 #endif
 
-  nsresult rv = mManager->OnStartRequest(mChannel);
+  mManager->InitChannelInfo(mChannel);
+  nsresult rv = mManager->SetPrincipalInfo(mChannel);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP