Index: third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.h |
diff --git a/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.h b/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..45bd9434a79e6ca2b1ba1f57e5eecfa08dabe2a6 |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.h |
@@ -0,0 +1,85 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef ModuleTreeLinker_h |
+#define ModuleTreeLinker_h |
+ |
+#include "core/dom/AncestorList.h" |
+#include "core/dom/Modulator.h" |
+ |
+namespace blink { |
+ |
+class ModuleScriptFetchRequest; |
+enum class ModuleGraphLevel; |
+class ModuleTreeLinkerRegistry; |
+ |
+// A ModuleTreeLinker is responsible for running and keeping intermediate states |
+// for "internal module script graph fetching procedure" for a module graph tree |
+// node. |
+// https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-script-graph-fetching-procedure |
+class ModuleTreeLinker final |
+ : public GarbageCollectedFinalized<ModuleTreeLinker>, |
+ public SingleModuleClient { |
+ USING_GARBAGE_COLLECTED_MIXIN(ModuleTreeLinker); |
+ |
+ public: |
+ static ModuleTreeLinker* fetch(const ModuleScriptFetchRequest&, |
+ const AncestorList&, |
+ ModuleGraphLevel, |
+ Modulator*, |
+ ModuleTreeLinkerRegistry*, |
+ ModuleTreeClient*); |
+ virtual ~ModuleTreeLinker() = default; |
+ DECLARE_TRACE(); |
+ |
+ bool isFetching() const { |
+ return State::FetchingSelf <= m_state && m_state < State::Finished; |
+ } |
+ bool hasFinished() const { return m_state == State::Finished; } |
+ |
+ private: |
+ ModuleTreeLinker(const AncestorList& ancestorListWithUrl, |
+ Modulator*, |
+ ModuleTreeLinkerRegistry*, |
+ ModuleTreeClient*); |
+ |
+ enum class State { |
+ Initial, |
+ // Running fetch of the module script corresponding to the target node. |
+ FetchingSelf, |
+ // Running fetch of descendants of the target node. |
+ FetchingDependencies, |
+ // Instantiating m_moduleScript and the node descendants. |
+ Instantiating, |
+ Finished, |
+ }; |
+ void advanceState(State); |
+ |
+ void fetchSelf(const ModuleScriptFetchRequest&, ModuleGraphLevel); |
+ // Implements SingleModuleClient |
+ void notifyModuleLoadFinished(ModuleScript*) override; |
+ |
+ void fetchDescendants(); |
+ enum class DescendantLoad { Failed, Success }; |
+ void notifyOneDescendantFinished(DescendantLoad wasSuccess); |
+ |
+ void instantiate(); |
+ HeapHashSet<Member<ModuleScript>> uninstantiatedInclusiveDescendants(); |
+ |
+ class DependencyModuleClient; |
+ friend class DependencyModuleClient; |
+ |
+ Member<Modulator> m_modulator; |
+ Member<ModuleTreeLinkerRegistry> m_registry; |
+ Member<ModuleTreeClient> m_client; |
+ HashSet<KURL> m_ancestorListWithUrl; |
+ State m_state = State::Initial; |
+ Member<ModuleScript> m_moduleScript; |
+ size_t m_numIncompleteDescendants = 0; |
+ HeapHashSet<Member<DependencyModuleClient>> m_dependencyClients; |
+}; |
+ |
+} // namespace blink |
+ |
+#endif |