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/Modulator.h" | |
9 #include "platform/weborigin/KURL.h" | |
10 #include "platform/weborigin/KURLHash.h" | |
11 #include "wtf/HashSet.h" | |
12 | |
13 namespace blink { | |
14 | |
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 KURL&, | |
dominicc (has gone to gerrit)
2017/01/11 06:57:15
WDYT about not coupling the ModuleTreeLinker and M
kouhei (in TOK)
2017/01/17 05:26:13
Would you give more background on why you prefer t
| |
28 const KURL& baseURL, | |
29 HashSet<KURL> ancestorList, | |
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(HashSet<KURL> 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 KURL&, const KURL& baseURL); | |
60 // Implements SingleModuleClient | |
61 void notifyFinishedSingleModule(ModuleScript*) override; | |
62 | |
63 void fetchDescendants(); | |
64 void notifyOneDescendantFinished(bool wasSuccess); | |
dominicc (has gone to gerrit)
2017/01/11 06:57:15
In general enums and not bools are more readable a
kouhei (in TOK)
2017/01/17 05:26:13
Done.
| |
65 | |
66 void instantiate(); | |
67 HeapHashSet<Member<ModuleScript>> uninstantiatedInclusiveDescendants(); | |
68 | |
69 class DependencyModuleClient; | |
70 friend class DependencyModuleClient; | |
71 | |
72 Member<Modulator> m_modulator; | |
73 Member<ModuleTreeLinkerRegistry> m_registry; | |
74 Member<ModuleTreeClient> m_client; | |
75 HashSet<KURL> m_ancestorListWithUrl; | |
76 State m_state = State::Initial; | |
77 Member<ModuleScript> m_moduleScript; | |
78 size_t m_numIncompleteDescendants = 0; | |
79 HeapHashSet<Member<DependencyModuleClient>> m_dependencyClients; | |
80 }; | |
81 | |
82 } // namespace blink | |
83 | |
84 #endif | |
OLD | NEW |