зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1290951 - Part 2.4: Add mIsMainScript to CompareNetwork. r=bkelly
--HG-- extra : rebase_source : 7a123c23c07cb3c13777b37c41e69e7dd2b1b8a8
This commit is contained in:
Родитель
1fbf9e14ad
Коммит
27f3010bb9
|
@ -92,13 +92,17 @@ public:
|
|||
|
||||
explicit CompareNetwork(CompareManager* aManager)
|
||||
: mManager(aManager)
|
||||
, mIsMainScript(true)
|
||||
{
|
||||
MOZ_ASSERT(aManager);
|
||||
AssertIsOnMainThread();
|
||||
}
|
||||
|
||||
nsresult
|
||||
Initialize(nsIPrincipal* aPrincipal, const nsAString& aURL, nsILoadGroup* aLoadGroup);
|
||||
Initialize(nsIPrincipal* aPrincipal,
|
||||
const nsAString& aURL,
|
||||
bool aIsMainScript,
|
||||
nsILoadGroup* aLoadGroup);
|
||||
|
||||
void
|
||||
Abort();
|
||||
|
@ -118,6 +122,8 @@ private:
|
|||
RefPtr<CompareManager> mManager;
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
nsString mBuffer;
|
||||
|
||||
bool mIsMainScript;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(CompareNetwork, nsIStreamLoaderObserver,
|
||||
|
@ -387,10 +393,12 @@ private:
|
|||
Cleanup();
|
||||
|
||||
void
|
||||
FetchScript(Cache* const aCache)
|
||||
FetchScript(const nsAString& aURL,
|
||||
bool aIsMainScript,
|
||||
Cache* const aCache)
|
||||
{
|
||||
mCN = new CompareNetwork(this);
|
||||
nsresult rv = mCN->Initialize(mPrincipal, mURL, mLoadGroup);
|
||||
nsresult rv = mCN->Initialize(mPrincipal, aURL, aIsMainScript, mLoadGroup);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
Fail(rv);
|
||||
}
|
||||
|
@ -482,7 +490,7 @@ private:
|
|||
}
|
||||
|
||||
mState = WaitingForScriptOrComparisonResult;
|
||||
FetchScript(mOldCache);
|
||||
FetchScript(mURL, true /* aIsMainScript */, mOldCache);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -633,7 +641,10 @@ private:
|
|||
NS_IMPL_ISUPPORTS0(CompareManager)
|
||||
|
||||
nsresult
|
||||
CompareNetwork::Initialize(nsIPrincipal* aPrincipal, const nsAString& aURL, nsILoadGroup* aLoadGroup)
|
||||
CompareNetwork::Initialize(nsIPrincipal* aPrincipal,
|
||||
const nsAString& aURL,
|
||||
bool aIsMainScript,
|
||||
nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
AssertIsOnMainThread();
|
||||
|
@ -644,6 +655,8 @@ CompareNetwork::Initialize(nsIPrincipal* aPrincipal, const nsAString& aURL, nsIL
|
|||
return rv;
|
||||
}
|
||||
|
||||
mIsMainScript = aIsMainScript;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
rv = NS_NewLoadGroup(getter_AddRefs(loadGroup), aPrincipal);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
@ -797,13 +810,15 @@ CompareNetwork::OnStreamComplete(nsIStreamLoader* aLoader, nsISupports* aContext
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoCString maxScope;
|
||||
// Note: we explicitly don't check for the return value here, because the
|
||||
// absence of the header is not an error condition.
|
||||
Unused << httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Service-Worker-Allowed"),
|
||||
maxScope);
|
||||
if (mIsMainScript) {
|
||||
nsAutoCString maxScope;
|
||||
// Note: we explicitly don't check for the return value here, because the
|
||||
// absence of the header is not an error condition.
|
||||
Unused << httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Service-Worker-Allowed"),
|
||||
maxScope);
|
||||
|
||||
mManager->SetMaxScope(maxScope);
|
||||
mManager->SetMaxScope(maxScope);
|
||||
}
|
||||
|
||||
bool isFromCache = false;
|
||||
nsCOMPtr<nsICacheInfoChannel> cacheChannel(do_QueryInterface(httpChannel));
|
||||
|
@ -1077,7 +1092,7 @@ CompareManager::Initialize(nsIPrincipal* aPrincipal,
|
|||
|
||||
// Go fetch the script directly without comparison.
|
||||
mState = WaitingForScriptOrComparisonResult;
|
||||
FetchScript(nullptr);
|
||||
FetchScript(mURL, true /* aIsMainScript */, nullptr);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче