Bug 1742437 - Split ScriptLoadRequest into ScriptLoadRequest and DOMScriptLoadContext; r=jonco,smaug

Differential Revision: https://phabricator.services.mozilla.com/D134041
This commit is contained in:
Yulia Startsev
2022-02-21 15:39:04 +00:00
parent cc51a986aa
commit 55cd96e998
8 changed files with 592 additions and 393 deletions

View File

@@ -122,7 +122,7 @@ ScriptLoadHandler::OnIncrementalData(nsIIncrementalStreamLoader* aLoader,
if (!mPreloadStartNotified) {
mPreloadStartNotified = true;
mRequest->NotifyStart(channelRequest);
mRequest->mLoadContext->NotifyStart(channelRequest);
}
if (mRequest->IsCanceled()) {
@@ -222,8 +222,8 @@ bool ScriptLoadHandler::TrySetDecoder(nsIIncrementalStreamLoader* aLoader,
// Check the hint charset from the script element or preload
// request.
nsAutoString hintCharset;
if (!mRequest->IsPreload()) {
mRequest->GetScriptElement()->GetScriptCharset(hintCharset);
if (!mRequest->mLoadContext->IsPreload()) {
mRequest->mLoadContext->GetScriptElement()->GetScriptCharset(hintCharset);
} else {
nsTArray<ScriptLoader::PreloadInfo>::index_type i =
mScriptLoader->mPreloads.IndexOf(
@@ -296,7 +296,8 @@ nsresult ScriptLoadHandler::EnsureKnownDataType(
if (mRequest->IsLoadingSource()) {
mRequest->SetTextSource();
TRACE_FOR_TEST(mRequest->GetScriptElement(), "scriptloader_load_source");
TRACE_FOR_TEST(mRequest->mLoadContext->GetScriptElement(),
"scriptloader_load_source");
return NS_OK;
}
@@ -306,7 +307,7 @@ nsresult ScriptLoadHandler::EnsureKnownDataType(
cic->GetAlternativeDataType(altDataType);
if (altDataType.Equals(nsContentUtils::JSBytecodeMimeType())) {
mRequest->SetBytecode();
TRACE_FOR_TEST(mRequest->GetScriptElement(),
TRACE_FOR_TEST(mRequest->mLoadContext->GetScriptElement(),
"scriptloader_load_bytecode");
return NS_OK;
}
@@ -314,7 +315,8 @@ nsresult ScriptLoadHandler::EnsureKnownDataType(
}
mRequest->SetTextSource();
TRACE_FOR_TEST(mRequest->GetScriptElement(), "scriptloader_load_source");
TRACE_FOR_TEST(mRequest->mLoadContext->GetScriptElement(),
"scriptloader_load_source");
MOZ_ASSERT(!mRequest->IsUnknownDataType());
MOZ_ASSERT(mRequest->IsLoading());
@@ -339,11 +341,11 @@ ScriptLoadHandler::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
if (!mPreloadStartNotified) {
mPreloadStartNotified = true;
mRequest->NotifyStart(channelRequest);
mRequest->mLoadContext->NotifyStart(channelRequest);
}
auto notifyStop =
MakeScopeExit([&] { mRequest->NotifyStop(channelRequest, rv); });
auto notifyStop = MakeScopeExit(
[&] { mRequest->mLoadContext->NotifyStop(channelRequest, rv); });
if (!mRequest->IsCanceled()) {
if (mRequest->IsUnknownDataType()) {