Bug 1784482 - Implement method for single script loading; r=asuth

This will be used by child modules. This is currently not used, but it will be in modules. I can
move this over to the other bug, if necessary.

Depends on D147325

Differential Revision: https://phabricator.services.mozilla.com/D147321
This commit is contained in:
Yulia Startsev 2022-09-07 09:37:40 +00:00
Родитель 02db260709
Коммит 8c7b1e9f2d
2 изменённых файлов: 21 добавлений и 0 удалений

Просмотреть файл

@ -481,6 +481,25 @@ already_AddRefed<ScriptLoadRequest> WorkerScriptLoader::CreateScriptLoadRequest(
return request.forget();
}
bool WorkerScriptLoader::DispatchLoadScript(ScriptLoadRequest* aRequest) {
mWorkerRef->Private()->AssertIsOnWorkerThread();
nsTArray<WorkerLoadContext*> scriptLoadList;
scriptLoadList.AppendElement(aRequest->GetWorkerLoadContext());
nsresult rv =
NS_DispatchToMainThread(NewRunnableMethod<nsTArray<WorkerLoadContext*>&&>(
"WorkerScriptLoader::LoadScripts", this,
&WorkerScriptLoader::LoadScripts, std::move(scriptLoadList)));
if (NS_FAILED(rv)) {
NS_ERROR("Failed to dispatch!");
mRv.Throw(NS_ERROR_FAILURE);
return false;
}
return true;
}
bool WorkerScriptLoader::DispatchLoadScripts() {
mWorkerRef->Private()->AssertIsOnWorkerThread();

Просмотреть файл

@ -160,6 +160,8 @@ class WorkerScriptLoader final : public nsINamed {
const nsString& aScriptURL, const mozilla::Encoding* aDocumentEncoding,
bool aIsMainScript);
bool DispatchLoadScript(ScriptLoadRequest* aRequest);
bool DispatchLoadScripts();
protected: