diff options
author | Gaming4JC <g4jc@hyperbola.info> | 2020-08-02 12:46:52 -0400 |
---|---|---|
committer | Gaming4JC <g4jc@hyperbola.info> | 2020-08-04 10:25:32 -0400 |
commit | 7e673b1dbe5c0130e4a227a5a2db1fe7b91f0026 (patch) | |
tree | e4e7cf8368cb21990a958e51b2dbde6002329a74 | |
parent | 501b29a5df925f2de3c0a1343290982e5ff6f829 (diff) | |
download | UXP-7e673b1dbe5c0130e4a227a5a2db1fe7b91f0026.tar UXP-7e673b1dbe5c0130e4a227a5a2db1fe7b91f0026.tar.gz UXP-7e673b1dbe5c0130e4a227a5a2db1fe7b91f0026.tar.lz UXP-7e673b1dbe5c0130e4a227a5a2db1fe7b91f0026.tar.xz UXP-7e673b1dbe5c0130e4a227a5a2db1fe7b91f0026.zip |
Issue #618 - Simplify module map interface
Ref: BZ 1365187
-rw-r--r-- | dom/script/ScriptLoader.cpp | 24 | ||||
-rw-r--r-- | dom/script/ScriptLoader.h | 4 |
2 files changed, 14 insertions, 14 deletions
diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index 4050caada..7d5a19faf 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -388,12 +388,12 @@ ScriptLoader::ModuleScriptsEnabled() } bool -ScriptLoader::ModuleMapContainsModule(ModuleLoadRequest *aRequest) const +ScriptLoader::ModuleMapContainsURL(nsIURI* aURL) const { // Returns whether we have fetched, or are currently fetching, a module script - // for the request's URL. - return mFetchingModules.Contains(aRequest->mURI) || - mFetchedModules.Contains(aRequest->mURI); + // for a URL. + return mFetchingModules.Contains(aURL) || + mFetchedModules.Contains(aURL); } bool @@ -410,7 +410,7 @@ ScriptLoader::SetModuleFetchStarted(ModuleLoadRequest *aRequest) // Update the module map to indicate that a module is currently being fetched. MOZ_ASSERT(aRequest->IsLoading()); - MOZ_ASSERT(!ModuleMapContainsModule(aRequest)); + MOZ_ASSERT(!ModuleMapContainsURL(aRequest->mURI)); mFetchingModules.Put(aRequest->mURI, nullptr); } @@ -443,21 +443,21 @@ ScriptLoader::SetModuleFetchFinishedAndResumeWaitingRequests(ModuleLoadRequest * } RefPtr<GenericPromise> -ScriptLoader::WaitForModuleFetch(ModuleLoadRequest *aRequest) +ScriptLoader::WaitForModuleFetch(nsIURI* aURL) { - MOZ_ASSERT(ModuleMapContainsModule(aRequest)); + MOZ_ASSERT(ModuleMapContainsURL(aURL)); RefPtr<GenericPromise::Private> promise; - if (mFetchingModules.Get(aRequest->mURI, getter_AddRefs(promise))) { + if (mFetchingModules.Get(aURL, getter_AddRefs(promise))) { if (!promise) { promise = new GenericPromise::Private(__func__); - mFetchingModules.Put(aRequest->mURI, promise); + mFetchingModules.Put(aURL, promise); } return promise; } RefPtr<ModuleScript> ms; - MOZ_ALWAYS_TRUE(mFetchedModules.Get(aRequest->mURI, getter_AddRefs(ms))); + MOZ_ALWAYS_TRUE(mFetchedModules.Get(aURL, getter_AddRefs(ms))); if (!ms) { return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__); } @@ -984,8 +984,8 @@ ScriptLoader::StartLoad(ScriptLoadRequest *aRequest, const nsAString &aType, // Check whether the module has been fetched or is currently being fetched, // and if so wait for it. ModuleLoadRequest* request = aRequest->AsModuleRequest(); - if (ModuleMapContainsModule(request)) { - WaitForModuleFetch(request) + if (ModuleMapContainsURL(request->mURI)) { + WaitForModuleFetch(request->mURI) ->Then(AbstractThread::GetCurrent(), __func__, request, &ModuleLoadRequest::ModuleLoaded, &ModuleLoadRequest::LoadFailed); diff --git a/dom/script/ScriptLoader.h b/dom/script/ScriptLoader.h index db2eeed31..955ac2cb7 100644 --- a/dom/script/ScriptLoader.h +++ b/dom/script/ScriptLoader.h @@ -572,8 +572,8 @@ private: bool IsFetchingModule(ModuleLoadRequest *aRequest) const; - bool ModuleMapContainsModule(ModuleLoadRequest *aRequest) const; - RefPtr<mozilla::GenericPromise> WaitForModuleFetch(ModuleLoadRequest *aRequest); + bool ModuleMapContainsURL(nsIURI* aURL) const; + RefPtr<mozilla::GenericPromise> WaitForModuleFetch(nsIURI* aURL); ModuleScript* GetFetchedModule(nsIURI* aURL) const; friend bool |