summaryrefslogtreecommitdiffstats
path: root/dom/script/ModuleLoadRequest.h
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2020-08-03 10:44:39 -0400
committerGaming4JC <g4jc@hyperbola.info>2020-08-04 10:25:36 -0400
commit15a7be79bd1396df9d19e15fd072bb825b0d9313 (patch)
treeb707f289d60e74b398c362e671708e5248667d2b /dom/script/ModuleLoadRequest.h
parent7e673b1dbe5c0130e4a227a5a2db1fe7b91f0026 (diff)
downloadUXP-15a7be79bd1396df9d19e15fd072bb825b0d9313.tar
UXP-15a7be79bd1396df9d19e15fd072bb825b0d9313.tar.gz
UXP-15a7be79bd1396df9d19e15fd072bb825b0d9313.tar.lz
UXP-15a7be79bd1396df9d19e15fd072bb825b0d9313.tar.xz
UXP-15a7be79bd1396df9d19e15fd072bb825b0d9313.zip
Issue #618 - Keep track of which modules in a graph have been fetched using a visited set
Ref: BZ 1365187
Diffstat (limited to 'dom/script/ModuleLoadRequest.h')
-rw-r--r--dom/script/ModuleLoadRequest.h31
1 files changed, 24 insertions, 7 deletions
diff --git a/dom/script/ModuleLoadRequest.h b/dom/script/ModuleLoadRequest.h
index 7b06dd2cf..2e9652881 100644
--- a/dom/script/ModuleLoadRequest.h
+++ b/dom/script/ModuleLoadRequest.h
@@ -8,6 +8,7 @@
#define mozilla_dom_ModuleLoadRequest_h
#include "mozilla/dom/ScriptLoader.h"
+#include "nsURIHashKey.h"
#include "mozilla/MozPromise.h"
namespace mozilla {
@@ -16,6 +17,16 @@ namespace dom {
class ModuleScript;
class ScriptLoader;
+// A reference counted set of URLs we have visited in the process of loading a
+// module graph.
+class VisitedURLSet : public nsTHashtable<nsURIHashKey>
+{
+ NS_INLINE_DECL_REFCOUNTING(VisitedURLSet)
+
+private:
+ ~VisitedURLSet() = default;
+};
+
// A load request for a module, created for every top level module script and
// every module import. Load request can share a ModuleScript if there are
// multiple imports of the same module.
@@ -31,12 +42,18 @@ public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ModuleLoadRequest, ScriptLoadRequest)
- ModuleLoadRequest(nsIScriptElement* aElement,
+ // Create a top-level module load request.
+ ModuleLoadRequest(nsIURI* aURI,
+ nsIScriptElement* aElement,
uint32_t aVersion,
CORSMode aCORSMode,
const SRIMetadata& aIntegrity,
ScriptLoader* aLoader);
+ // Create a module load request for an imported module.
+ ModuleLoadRequest(nsIURI* aURI,
+ ModuleLoadRequest* aParent);
+
bool IsTopLevel() const {
return mIsTopLevel;
}
@@ -55,7 +72,7 @@ private:
public:
// Is this a request for a top level module script or an import?
- bool mIsTopLevel;
+ const bool mIsTopLevel;
// The base URL used for resolving relative module imports.
nsCOMPtr<nsIURI> mBaseURL;
@@ -64,10 +81,6 @@ public:
// finishes.
RefPtr<ScriptLoader> mLoader;
- // The importing module, or nullptr for top level module scripts. Used to
- // implement the ancestor list checked when fetching module dependencies.
- RefPtr<ModuleLoadRequest> mParent;
-
// Set to a module script object after a successful load or nullptr on
// failure.
RefPtr<ModuleScript> mModuleScript;
@@ -79,9 +92,13 @@ public:
// Array of imported modules.
nsTArray<RefPtr<ModuleLoadRequest>> mImports;
+
+ // Set of module URLs visited while fetching the module graph this request is
+ // part of.
+ RefPtr<VisitedURLSet> mVisitedSet;
};
} // dom namespace
} // mozilla namespace
-#endif // mozilla_dom_ModuleLoadRequest_h \ No newline at end of file
+#endif // mozilla_dom_ModuleLoadRequest_h