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