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

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

Issue 2799323002: [local; kouhei 2] kouhei's giant CL https://codereview.chromium.org/2555653002 (Closed)
Patch Set: Rebase Created 3 years, 8 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/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::kFetchingSelf <= state_ && state_ < State::kFinished;
38 }
39 bool HasFinished() const { return state_ == State::kFinished; }
40
41 private:
42 ModuleTreeLinker(const AncestorList& ancestor_list_with_url,
43 Modulator*,
44 ModuleTreeLinkerRegistry*,
45 ModuleTreeClient*);
46
47 enum class State {
48 kInitial,
49 // Running fetch of the module script corresponding to the target node.
50 kFetchingSelf,
51 // Running fetch of descendants of the target node.
52 kFetchingDependencies,
53 // Instantiating m_moduleScript and the node descendants.
54 kInstantiating,
55 kFinished,
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 { kFailed, kSuccess };
65 void NotifyOneDescendantFinished(DescendantLoad was_success);
66
67 void Instantiate();
68 HeapHashSet<Member<ModuleScript>> UninstantiatedInclusiveDescendants();
69
70 class DependencyModuleClient;
71 friend class DependencyModuleClient;
72
73 Member<Modulator> modulator_;
74 Member<ModuleTreeLinkerRegistry> registry_;
75 Member<ModuleTreeClient> client_;
76 HashSet<KURL> ancestor_list_with_url_;
77 State state_ = State::kInitial;
78 Member<ModuleScript> module_script_;
79 size_t num_incomplete_descendants_ = 0;
80 HeapHashSet<Member<DependencyModuleClient>> dependency_clients_;
81 };
82
83 } // namespace blink
84
85 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698