OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ModuleTreeLinker_h |
| 6 #define ModuleTreeLinker_h |
| 7 |
| 8 #include "core/dom/AncestorList.h" |
| 9 #include "core/dom/Modulator.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 class ModuleScriptFetchRequest; |
| 14 enum class ModuleGraphLevel; |
| 15 class ModuleTreeLinkerRegistry; |
| 16 |
| 17 // A ModuleTreeLinker is responsible for running and keeping intermediate states |
| 18 // for "internal module script graph fetching procedure" for a module graph tree |
| 19 // node. |
| 20 // https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-script
-graph-fetching-procedure |
| 21 class ModuleTreeLinker final |
| 22 : public GarbageCollectedFinalized<ModuleTreeLinker>, |
| 23 public SingleModuleClient { |
| 24 USING_GARBAGE_COLLECTED_MIXIN(ModuleTreeLinker); |
| 25 |
| 26 public: |
| 27 static ModuleTreeLinker* fetch(const ModuleScriptFetchRequest&, |
| 28 const AncestorList&, |
| 29 ModuleGraphLevel, |
| 30 Modulator*, |
| 31 ModuleTreeLinkerRegistry*, |
| 32 ModuleTreeClient*); |
| 33 virtual ~ModuleTreeLinker() = default; |
| 34 DECLARE_TRACE(); |
| 35 |
| 36 bool isFetching() const { |
| 37 return State::FetchingSelf <= m_state && m_state < State::Finished; |
| 38 } |
| 39 bool hasFinished() const { return m_state == State::Finished; } |
| 40 |
| 41 private: |
| 42 ModuleTreeLinker(const AncestorList& ancestorListWithUrl, |
| 43 Modulator*, |
| 44 ModuleTreeLinkerRegistry*, |
| 45 ModuleTreeClient*); |
| 46 |
| 47 enum class State { |
| 48 Initial, |
| 49 // Running fetch of the module script corresponding to the target node. |
| 50 FetchingSelf, |
| 51 // Running fetch of descendants of the target node. |
| 52 FetchingDependencies, |
| 53 // Instantiating m_moduleScript and the node descendants. |
| 54 Instantiating, |
| 55 Finished, |
| 56 }; |
| 57 void advanceState(State); |
| 58 |
| 59 void fetchSelf(const ModuleScriptFetchRequest&, ModuleGraphLevel); |
| 60 // Implements SingleModuleClient |
| 61 void notifyModuleLoadFinished(ModuleScript*) override; |
| 62 |
| 63 void fetchDescendants(); |
| 64 enum class DescendantLoad { Failed, Success }; |
| 65 void notifyOneDescendantFinished(DescendantLoad wasSuccess); |
| 66 |
| 67 void instantiate(); |
| 68 HeapHashSet<Member<ModuleScript>> uninstantiatedInclusiveDescendants(); |
| 69 |
| 70 class DependencyModuleClient; |
| 71 friend class DependencyModuleClient; |
| 72 |
| 73 Member<Modulator> m_modulator; |
| 74 Member<ModuleTreeLinkerRegistry> m_registry; |
| 75 Member<ModuleTreeClient> m_client; |
| 76 HashSet<KURL> m_ancestorListWithUrl; |
| 77 State m_state = State::Initial; |
| 78 Member<ModuleScript> m_moduleScript; |
| 79 size_t m_numIncompleteDescendants = 0; |
| 80 HeapHashSet<Member<DependencyModuleClient>> m_dependencyClients; |
| 81 }; |
| 82 |
| 83 } // namespace blink |
| 84 |
| 85 #endif |
OLD | NEW |