Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.h

Issue 2555653002: [WIP Prototype] ES6 https://html.spec.whatwg.org/#fetch-a-single-module-script implementation (Closed)
Patch Set: ModuleScriptLoaderTest Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "wtf/HashSet.h"
10
11 namespace blink {
12
13 class ModuleTreeLinkerRegistry;
14
15 // A ModuleTreeLinker is esponsible for running and keeping intermediate states
yhirano 2017/01/06 07:27:01 responsible
kouhei (in TOK) 2017/01/11 01:41:58 Done.
16 // for "internal module script graph fetching procedure" for a module graph tree
17 // node.
18 // https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-script -graph-fetching-procedure
19 class ModuleTreeLinker final
20 : public GarbageCollectedFinalized<ModuleTreeLinker>,
21 public SingleModuleClient {
22 USING_GARBAGE_COLLECTED_MIXIN(ModuleTreeLinker);
23
24 public:
25 static ModuleTreeLinker* fetch(const KURL&,
26 const KURL& baseURL,
27 Modulator*,
28 ModuleTreeLinkerRegistry*,
29 ModuleTreeClient*);
30 virtual ~ModuleTreeLinker() = default;
31 DECLARE_TRACE();
32
33 bool isFetching() const {
34 return State::FetchingSelf <= m_state && m_state < State::Finished;
35 }
36 bool hasFinished() const { return m_state == State::Finished; }
37
38 private:
39 ModuleTreeLinker(Modulator*, ModuleTreeLinkerRegistry*, ModuleTreeClient*);
40
41 enum class State {
42 Initial,
43 // Running fetch of the module script corresponding to the target node.
44 FetchingSelf,
45 // Running fetch of descendants of the target node.
46 FetchingDependencies,
47 // Instantiating m_moduleScript and the node descendants.
48 Instantiating,
yhirano 2017/01/06 07:27:01 Not used
kouhei (in TOK) 2017/01/11 01:41:58 Fixed.
49 Finished,
50 };
51 void advanceState(State);
52
53 void fetchSelf(const KURL&, const KURL& baseURL);
54 // Implements SingleModuleClient
55 void notifyFinishedSingleModule(ModuleScript*) override;
56
57 void fetchDescendants();
58 void notifyOneDescendantFinished(bool wasSuccess);
59
60 void instantiate();
61 HeapHashSet<Member<ModuleScript>> uninstantiatedInclusiveDescendants();
62
63 class DependencyModuleClient;
64 friend class DependencyModuleClient;
65
66 Member<Modulator> m_modulator;
67 Member<ModuleTreeLinkerRegistry> m_registry;
68 Member<ModuleTreeClient> m_client;
69 State m_state = State::Initial;
70 Member<ModuleScript> m_moduleScript;
71 size_t m_numIncompleteDescendants = 0;
72 HeapHashSet<Member<DependencyModuleClient>> m_dependencyClients;
73 };
74
75 } // namespace blink
76
77 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698