зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1761432 - Part 3: Add script load request cancelled state r=smaug
Previously a separate field, this makes more sense as a state in its own right. Differential Revision: https://phabricator.services.mozilla.com/D142043
This commit is contained in:
Родитель
0d945e360c
Коммит
2fedd636c1
|
@ -69,7 +69,6 @@ ModuleLoadRequest::ModuleLoadRequest(
|
|||
void ModuleLoadRequest::Cancel() {
|
||||
ScriptLoadRequest::Cancel();
|
||||
mModuleScript = nullptr;
|
||||
mState = ScriptLoadRequest::State::Ready;
|
||||
CancelImports();
|
||||
mReady.RejectIfExists(NS_ERROR_DOM_ABORT_ERR, __func__);
|
||||
}
|
||||
|
|
|
@ -82,7 +82,6 @@ ScriptLoadRequest::ScriptLoadRequest(ScriptKind aKind, nsIURI* aURI,
|
|||
nsIURI* aReferrer,
|
||||
mozilla::dom::ScriptLoadContext* aContext)
|
||||
: mKind(aKind),
|
||||
mIsCanceled(false),
|
||||
mState(State::Fetching),
|
||||
mFetchSourceOnly(false),
|
||||
mDataType(DataType::eUnknown),
|
||||
|
@ -109,12 +108,12 @@ ScriptLoadRequest::~ScriptLoadRequest() {
|
|||
}
|
||||
|
||||
void ScriptLoadRequest::SetReady() {
|
||||
MOZ_ASSERT(mState != State::Ready);
|
||||
MOZ_ASSERT(!IsReadyToRun());
|
||||
mState = State::Ready;
|
||||
}
|
||||
|
||||
void ScriptLoadRequest::Cancel() {
|
||||
mIsCanceled = true;
|
||||
mState = State::Canceled;
|
||||
if (HasLoadContext()) {
|
||||
GetLoadContext()->MaybeCancelOffThreadScript();
|
||||
}
|
||||
|
|
|
@ -180,18 +180,26 @@ class ScriptLoadRequest
|
|||
|
||||
virtual void Cancel();
|
||||
|
||||
bool IsCanceled() const { return mIsCanceled; }
|
||||
|
||||
virtual void SetReady();
|
||||
|
||||
enum class State : uint8_t { Fetching, Compiling, LoadingImports, Ready };
|
||||
enum class State : uint8_t {
|
||||
Fetching,
|
||||
Compiling,
|
||||
LoadingImports,
|
||||
Ready,
|
||||
Canceled
|
||||
};
|
||||
|
||||
bool IsReadyToRun() const { return mState == State::Ready; }
|
||||
bool IsReadyToRun() const {
|
||||
return mState == State::Ready || mState == State::Canceled;
|
||||
}
|
||||
|
||||
bool IsLoading() const { return mState == State::Fetching; }
|
||||
|
||||
bool InCompilingStage() const { return mState == State::Compiling; }
|
||||
|
||||
bool IsCanceled() const { return mState == State::Canceled; }
|
||||
|
||||
// Type of data provided by the nsChannel.
|
||||
enum class DataType : uint8_t { eUnknown, eTextSource, eBytecode };
|
||||
|
||||
|
@ -286,10 +294,9 @@ class ScriptLoadRequest
|
|||
const ScriptKind mKind; // Whether this is a classic script or a module
|
||||
// script.
|
||||
|
||||
bool mIsCanceled; // True if we have been explicitly canceled.
|
||||
State mState; // Are we still waiting for a load to complete?
|
||||
State mState; // Are we still waiting for a load to complete?
|
||||
bool mFetchSourceOnly; // Request source, not cached bytecode.
|
||||
DataType mDataType; // Does this contain Source or Bytecode?
|
||||
DataType mDataType; // Does this contain Source or Bytecode?
|
||||
RefPtr<ScriptFetchOptions> mFetchOptions;
|
||||
const SRIMetadata mIntegrity;
|
||||
const nsCOMPtr<nsIURI> mReferrer;
|
||||
|
|
Загрузка…
Ссылка в новой задаче