Bug 1842798 - Part 2: Remove use of MozPromise to wait for module imports to load r=smaug

This replaces the use of a promise to wait for all imports of a module to load
with a counter of reminaing imports in the parent and a pointer to the parent
that is waiting in the child. The parent request is updated immediately rather
than by dispatching a runnable.

Differential Revision: https://phabricator.services.mozilla.com/D183273
This commit is contained in:
Jon Coppeard
2023-08-03 08:15:29 +00:00
parent 19180ae3dd
commit 1e096c450d
5 changed files with 79 additions and 47 deletions

View File

@@ -23,7 +23,6 @@
#include "mozilla/CORSMode.h"
#include "mozilla/dom/JSExecutionContext.h"
#include "mozilla/MaybeOneOf.h"
#include "mozilla/MozPromise.h"
#include "mozilla/UniquePtr.h"
#include "ResolveResult.h"
@@ -163,8 +162,6 @@ class ScriptLoaderInterface : public nsISupports {
* 10. The client calls EvaluateModule() to execute the top-level module.
*/
class ModuleLoaderBase : public nsISupports {
using GenericPromise = mozilla::GenericPromise;
/*
* The set of requests that are waiting for an ongoing fetch to complete.
*/
@@ -193,8 +190,8 @@ class ModuleLoaderBase : public nsISupports {
bool mImportMapsAllowed = true;
protected:
// Event handler used to process MozPromise actions, used internally to wait
// for fetches to finish and for imports to become avilable.
// Event handler used to dispatch runnables, used internally to wait for
// fetches to finish and for imports to become avilable.
nsCOMPtr<nsISerialEventTarget> mEventTarget;
RefPtr<ScriptLoaderInterface> mLoader;
@@ -388,8 +385,8 @@ class ModuleLoaderBase : public nsISupports {
void StartFetchingModuleDependencies(ModuleLoadRequest* aRequest);
RefPtr<GenericPromise> StartFetchingModuleAndDependencies(
ModuleLoadRequest* aParent, nsIURI* aURI);
void StartFetchingModuleAndDependencies(ModuleLoadRequest* aParent,
nsIURI* aURI);
/**
* Shorthand Wrapper for JSAPI FinishDynamicImport function for the reject