Bug 1843838 - Rename ScriptLoadRequest::IsReadyToRun to IsFinished since this returns true for cancelled requests r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D183740
This commit is contained in:
@@ -128,7 +128,7 @@ nsresult ModuleLoader::StartFetch(ModuleLoadRequest* aRequest) {
|
||||
}
|
||||
|
||||
void ModuleLoader::OnModuleLoadComplete(ModuleLoadRequest* aRequest) {
|
||||
MOZ_ASSERT(aRequest->IsReadyToRun());
|
||||
MOZ_ASSERT(aRequest->IsFinished());
|
||||
|
||||
if (aRequest->IsTopLevel()) {
|
||||
if (aRequest->GetScriptLoadContext()->mIsInline &&
|
||||
|
||||
@@ -157,8 +157,7 @@ bool ScriptLoadContext::IsPreload() const {
|
||||
}
|
||||
|
||||
bool ScriptLoadContext::CompileStarted() const {
|
||||
return mRequest->IsCompiling() ||
|
||||
(mRequest->IsReadyToRun() && mWasCompiledOMT);
|
||||
return mRequest->IsCompiling() || (mRequest->IsFinished() && mWasCompiledOMT);
|
||||
}
|
||||
|
||||
nsIScriptElement* ScriptLoadContext::GetScriptElement() const {
|
||||
|
||||
@@ -1061,7 +1061,7 @@ bool ScriptLoader::ProcessExternalScript(nsIScriptElement* aElement,
|
||||
|
||||
if (request->GetScriptLoadContext()->IsAsyncScript()) {
|
||||
AddAsyncRequest(request);
|
||||
if (request->IsReadyToRun()) {
|
||||
if (request->IsFinished()) {
|
||||
// The script is available already. Run it ASAP when the event
|
||||
// loop gets a chance to spin.
|
||||
|
||||
@@ -1077,7 +1077,7 @@ bool ScriptLoader::ProcessExternalScript(nsIScriptElement* aElement,
|
||||
// http://lists.w3.org/Archives/Public/public-html/2010Oct/0088.html
|
||||
request->GetScriptLoadContext()->mIsNonAsyncScriptInserted = true;
|
||||
mNonAsyncExternalScriptInsertedRequests.AppendElement(request);
|
||||
if (request->IsReadyToRun()) {
|
||||
if (request->IsFinished()) {
|
||||
// The script is available already. Run it ASAP when the event
|
||||
// loop gets a chance to spin.
|
||||
ProcessPendingRequestsAsync();
|
||||
@@ -1107,7 +1107,7 @@ bool ScriptLoader::ProcessExternalScript(nsIScriptElement* aElement,
|
||||
"Parser-blocking scripts and XSLT scripts in the same doc!");
|
||||
request->GetScriptLoadContext()->mIsXSLT = true;
|
||||
mXSLTRequests.AppendElement(request);
|
||||
if (request->IsReadyToRun()) {
|
||||
if (request->IsFinished()) {
|
||||
// The script is available already. Run it ASAP when the event
|
||||
// loop gets a chance to spin.
|
||||
ProcessPendingRequestsAsync();
|
||||
@@ -1115,7 +1115,7 @@ bool ScriptLoader::ProcessExternalScript(nsIScriptElement* aElement,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (request->IsReadyToRun() && ReadyToExecuteParserBlockingScripts()) {
|
||||
if (request->IsFinished() && ReadyToExecuteParserBlockingScripts()) {
|
||||
// The request has already been loaded and there are no pending style
|
||||
// sheets. If the script comes from the network stream, cheat for
|
||||
// performance reasons and avoid a trip through the event loop.
|
||||
@@ -1515,7 +1515,7 @@ nsresult ScriptLoader::AttemptOffThreadScriptCompile(
|
||||
// If speculative parsing is enabled, the request may not be ready to run if
|
||||
// the element is not yet available.
|
||||
MOZ_ASSERT_IF(!SpeculativeOMTParsingEnabled() && !aRequest->IsModuleRequest(),
|
||||
aRequest->IsReadyToRun());
|
||||
aRequest->IsFinished());
|
||||
MOZ_ASSERT(!aRequest->GetScriptLoadContext()->mWasCompiledOMT);
|
||||
MOZ_ASSERT(aCouldCompileOut && !*aCouldCompileOut);
|
||||
|
||||
@@ -1801,7 +1801,7 @@ nsresult ScriptLoader::ProcessRequest(ScriptLoadRequest* aRequest) {
|
||||
|
||||
NS_ASSERTION(nsContentUtils::IsSafeToRunScript(),
|
||||
"Processing requests when running scripts is unsafe.");
|
||||
NS_ASSERTION(aRequest->IsReadyToRun(),
|
||||
NS_ASSERTION(aRequest->IsFinished(),
|
||||
"Processing a request that is not ready to run.");
|
||||
|
||||
NS_ENSURE_ARG(aRequest);
|
||||
@@ -2174,7 +2174,7 @@ static nsresult ExecuteCompiledScript(JSContext* aCx, JSExecutionContext& aExec,
|
||||
|
||||
nsresult ScriptLoader::EvaluateScriptElement(ScriptLoadRequest* aRequest) {
|
||||
using namespace mozilla::Telemetry;
|
||||
MOZ_ASSERT(aRequest->IsReadyToRun());
|
||||
MOZ_ASSERT(aRequest->IsFinished());
|
||||
|
||||
// We need a document to evaluate scripts.
|
||||
if (!mDocument) {
|
||||
@@ -2744,7 +2744,7 @@ void ScriptLoader::ProcessPendingRequestsAsync() {
|
||||
void ScriptLoader::ProcessPendingRequests() {
|
||||
RefPtr<ScriptLoadRequest> request;
|
||||
|
||||
if (mParserBlockingRequest && mParserBlockingRequest->IsReadyToRun() &&
|
||||
if (mParserBlockingRequest && mParserBlockingRequest->IsFinished() &&
|
||||
ReadyToExecuteParserBlockingScripts()) {
|
||||
request.swap(mParserBlockingRequest);
|
||||
UnblockParser(request);
|
||||
@@ -2753,7 +2753,7 @@ void ScriptLoader::ProcessPendingRequests() {
|
||||
}
|
||||
|
||||
while (ReadyToExecuteParserBlockingScripts() && !mXSLTRequests.isEmpty() &&
|
||||
mXSLTRequests.getFirst()->IsReadyToRun()) {
|
||||
mXSLTRequests.getFirst()->IsFinished()) {
|
||||
request = mXSLTRequests.StealFirst();
|
||||
ProcessRequest(request);
|
||||
}
|
||||
@@ -2769,7 +2769,7 @@ void ScriptLoader::ProcessPendingRequests() {
|
||||
|
||||
while (ReadyToExecuteScripts() &&
|
||||
!mNonAsyncExternalScriptInsertedRequests.isEmpty() &&
|
||||
mNonAsyncExternalScriptInsertedRequests.getFirst()->IsReadyToRun()) {
|
||||
mNonAsyncExternalScriptInsertedRequests.getFirst()->IsFinished()) {
|
||||
// Violate the HTML5 spec and execute these in the insertion order in
|
||||
// order to make LABjs and the "order" plug-in for RequireJS work with
|
||||
// their Gecko-sniffed code path. See
|
||||
@@ -2780,7 +2780,7 @@ void ScriptLoader::ProcessPendingRequests() {
|
||||
|
||||
if (mDeferCheckpointReached && mXSLTRequests.isEmpty()) {
|
||||
while (ReadyToExecuteScripts() && !mDeferRequests.isEmpty() &&
|
||||
mDeferRequests.getFirst()->IsReadyToRun()) {
|
||||
mDeferRequests.getFirst()->IsFinished()) {
|
||||
request = mDeferRequests.StealFirst();
|
||||
ProcessRequest(request);
|
||||
}
|
||||
@@ -3640,7 +3640,7 @@ void ScriptLoader::AddAsyncRequest(ScriptLoadRequest* aRequest) {
|
||||
MOZ_ASSERT(!aRequest->GetScriptLoadContext()->mInCompilingList);
|
||||
|
||||
aRequest->GetScriptLoadContext()->mInAsyncList = true;
|
||||
if (aRequest->IsReadyToRun()) {
|
||||
if (aRequest->IsFinished()) {
|
||||
mLoadedAsyncRequests.AppendElement(aRequest);
|
||||
} else {
|
||||
mLoadingAsyncRequests.AppendElement(aRequest);
|
||||
@@ -3648,7 +3648,7 @@ void ScriptLoader::AddAsyncRequest(ScriptLoadRequest* aRequest) {
|
||||
}
|
||||
|
||||
void ScriptLoader::MaybeMoveToLoadedList(ScriptLoadRequest* aRequest) {
|
||||
MOZ_ASSERT(aRequest->IsReadyToRun());
|
||||
MOZ_ASSERT(aRequest->IsFinished());
|
||||
MOZ_ASSERT(aRequest->IsTopLevel());
|
||||
|
||||
// If it's async, move it to the loaded list.
|
||||
|
||||
@@ -804,7 +804,7 @@ void WorkerScriptLoader::MaybeMoveToLoadedList(ScriptLoadRequest* aRequest) {
|
||||
ScriptLoadRequest* request = mLoadingRequests.getFirst();
|
||||
// We need to move requests in post order. If prior requests have not
|
||||
// completed, delay execution.
|
||||
if (!request->IsReadyToRun()) {
|
||||
if (!request->IsFinished()) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1116,7 +1116,7 @@ bool WorkerScriptLoader::EvaluateScript(JSContext* aCx,
|
||||
WorkerLoadContext* loadContext = aRequest->GetWorkerLoadContext();
|
||||
|
||||
NS_ASSERTION(!loadContext->mChannel, "Should no longer have a channel!");
|
||||
NS_ASSERTION(aRequest->IsReadyToRun(), "Should be scheduled!");
|
||||
NS_ASSERTION(aRequest->IsFinished(), "Should be scheduled!");
|
||||
|
||||
MOZ_ASSERT(!mRv.Failed(), "Who failed it and why?");
|
||||
mRv.MightThrowJSException();
|
||||
|
||||
@@ -82,7 +82,7 @@ void ModuleLoadRequest::Cancel() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsReadyToRun()) {
|
||||
if (IsFinished()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -97,13 +97,13 @@ void ModuleLoadRequest::Cancel() {
|
||||
}
|
||||
|
||||
void ModuleLoadRequest::SetReady() {
|
||||
MOZ_ASSERT(!IsReadyToRun());
|
||||
MOZ_ASSERT(!IsFinished());
|
||||
|
||||
// Mark a module as ready to execute. This means that this module and all it
|
||||
// dependencies have had their source loaded, parsed as a module and the
|
||||
// modules instantiated.
|
||||
|
||||
AssertAllImportsReady();
|
||||
AssertAllImportsFinished();
|
||||
|
||||
ScriptLoadRequest::SetReady();
|
||||
|
||||
@@ -161,13 +161,13 @@ void ModuleLoadRequest::ModuleErrored() {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!IsReadyToRun());
|
||||
MOZ_ASSERT(!IsFinished());
|
||||
|
||||
CheckModuleDependenciesLoaded();
|
||||
MOZ_ASSERT(IsErrored());
|
||||
|
||||
CancelImports();
|
||||
if (IsReadyToRun()) {
|
||||
if (IsFinished()) {
|
||||
// Cancelling an outstanding import will error this request.
|
||||
return;
|
||||
}
|
||||
@@ -234,10 +234,10 @@ void ModuleLoadRequest::ClearDynamicImport() {
|
||||
mDynamicPromise = nullptr;
|
||||
}
|
||||
|
||||
inline void ModuleLoadRequest::AssertAllImportsReady() const {
|
||||
inline void ModuleLoadRequest::AssertAllImportsFinished() const {
|
||||
#ifdef DEBUG
|
||||
for (const auto& request : mImports) {
|
||||
MOZ_ASSERT(request->IsReadyToRun());
|
||||
MOZ_ASSERT(request->IsFinished());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ class ModuleLoadRequest final : public ScriptLoadRequest {
|
||||
void CancelImports();
|
||||
void CheckModuleDependenciesLoaded();
|
||||
|
||||
void AssertAllImportsReady() const;
|
||||
void AssertAllImportsFinished() const;
|
||||
void AssertAllImportsCancelled() const;
|
||||
|
||||
public:
|
||||
|
||||
@@ -939,7 +939,7 @@ void ModuleLoadRequest::ChildLoadComplete(bool aSuccess) {
|
||||
mWaitingParentRequest = nullptr;
|
||||
parent->mAwaitingImports--;
|
||||
|
||||
if (parent->IsReadyToRun()) {
|
||||
if (parent->IsFinished()) {
|
||||
MOZ_ASSERT_IF(!aSuccess, parent->IsErrored());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ ScriptLoadRequest::ScriptLoadRequest(ScriptKind aKind, nsIURI* aURI,
|
||||
ScriptLoadRequest::~ScriptLoadRequest() { DropJSObjects(this); }
|
||||
|
||||
void ScriptLoadRequest::SetReady() {
|
||||
MOZ_ASSERT(!IsReadyToRun());
|
||||
MOZ_ASSERT(!IsFinished());
|
||||
mState = State::Ready;
|
||||
}
|
||||
|
||||
|
||||
@@ -222,13 +222,14 @@ class ScriptLoadRequest
|
||||
bool IsFetching() const { return mState == State::Fetching; }
|
||||
bool IsCompiling() const { return mState == State::Compiling; }
|
||||
bool IsLoadingImports() const { return mState == State::LoadingImports; }
|
||||
bool IsCanceled() const { return mState == State::Canceled; }
|
||||
|
||||
bool IsReadyToRun() const {
|
||||
// Return whether the request has been completed, either successfully or
|
||||
// otherwise.
|
||||
bool IsFinished() const {
|
||||
return mState == State::Ready || mState == State::Canceled;
|
||||
}
|
||||
|
||||
bool IsCanceled() const { return mState == State::Canceled; }
|
||||
|
||||
// Type of data provided by the nsChannel.
|
||||
enum class DataType : uint8_t { eUnknown, eTextSource, eBytecode };
|
||||
|
||||
|
||||
@@ -1832,7 +1832,7 @@ nsresult mozJSModuleLoader::ImportESModule(
|
||||
return rv;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(request->IsReadyToRun());
|
||||
MOZ_ASSERT(request->IsFinished());
|
||||
if (!request->mModuleScript) {
|
||||
mModuleLoader->MaybeReportLoadError(aCx);
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
Reference in New Issue
Block a user