OLD | NEW |
---|---|
(Empty) | |
1 #ifndef ModulePendingScript_h | |
kouhei (in TOK)
2017/04/13 02:25:24
missing the copyright 2017 comment
hiroshige
2017/04/13 17:53:56
Done.
| |
2 #define ModulePendingScript_h | |
3 | |
4 #include "bindings/core/v8/TraceWrapperMember.h" | |
5 #include "core/dom/Modulator.h" | |
6 #include "core/dom/ModuleScript.h" | |
7 #include "core/dom/PendingScript.h" | |
8 | |
9 namespace blink { | |
10 | |
11 class ModulePendingScript; | |
12 | |
13 // ModulePendingScriptTreeClient is used to connect from Modulator::FetchTree() | |
14 // to ModulePendingScript. Because ModulePendingScript is created after | |
15 // Modulator::FetchTree() is called, ModulePendingScriptTreeClient is | |
16 // registered as ModuleTreeClient to FetchTree() first, and later | |
17 // ModulePendingScript is supplied to ModulePendingScriptTreeClient via | |
18 // SetPendingScript() and is notified of module tree load finish. | |
19 class ModulePendingScriptTreeClient final | |
20 : public GarbageCollectedFinalized<ModulePendingScriptTreeClient>, | |
21 public TraceWrapperBase, | |
kouhei (in TOK)
2017/04/13 02:25:24
This doesn't have to be a TraceWrapperBase as disc
hiroshige
2017/04/13 02:55:37
So, we can avoid TraceWrapperMember<> and TraceWra
hiroshige
2017/04/13 17:53:56
Done.
Also created a separate CL for adding commen
| |
22 public ModuleTreeClient { | |
23 USING_GARBAGE_COLLECTED_MIXIN(ModulePendingScriptTreeClient); | |
24 | |
25 public: | |
26 static ModulePendingScriptTreeClient* Create() { | |
27 return new ModulePendingScriptTreeClient(); | |
28 } | |
29 virtual ~ModulePendingScriptTreeClient() = default; | |
30 | |
31 void SetPendingScript(ModulePendingScript* client); | |
32 | |
33 ModuleScript* GetModuleScript() const { return module_script_; } | |
34 | |
35 DECLARE_TRACE(); | |
36 DECLARE_TRACE_WRAPPERS(); | |
37 | |
38 private: | |
39 ModulePendingScriptTreeClient(); | |
40 | |
41 // Implements ModuleTreeClient | |
42 void NotifyModuleTreeLoadFinished(ModuleScript*) override; | |
43 | |
44 bool finished_ = false; | |
45 TraceWrapperMember<ModuleScript> module_script_; | |
46 TraceWrapperMember<ModulePendingScript> pending_script_; | |
kouhei (in TOK)
2017/04/13 02:25:24
Ditto
hiroshige
2017/04/13 17:53:56
Done.
| |
47 }; | |
48 | |
49 class CORE_EXPORT ModulePendingScript : public PendingScript { | |
50 public: | |
51 static ModulePendingScript* Create(ScriptElementBase* element, | |
52 ModulePendingScriptTreeClient* client) { | |
53 return new ModulePendingScript(element, client); | |
54 } | |
55 | |
56 ~ModulePendingScript() override; | |
57 | |
58 void NotifyModuleTreeLoadFinished(); | |
59 | |
60 ModuleScript* GetModuleScript() const { | |
61 return module_tree_client_->GetModuleScript(); | |
62 } | |
63 | |
64 DECLARE_TRACE(); | |
65 DECLARE_TRACE_WRAPPERS(); | |
kouhei (in TOK)
2017/04/13 02:25:24
Ditto
hiroshige
2017/04/13 17:53:56
Done.
| |
66 | |
67 private: | |
68 ModulePendingScript(ScriptElementBase*, ModulePendingScriptTreeClient*); | |
69 | |
70 // PendingScript | |
71 ScriptType GetScriptType() const override { return ScriptType::kModule; } | |
72 Script* GetSource(const KURL& document_url, | |
73 bool& error_occurred) const override; | |
74 bool IsReady() const override; | |
75 KURL Url() const override; | |
76 bool IsExternal() const override { return true; } | |
77 bool ErrorOccurred() const override; | |
78 bool WasCanceled() const override; | |
79 void StartStreamingIfPossible(Document*, ScriptStreamer::Type) override; | |
80 void DisposeInternal() override; | |
81 void RemoveFromMemoryCache() override { NOTREACHED(); } | |
82 | |
83 // FOXME: state check? | |
84 void CheckState() const override {} | |
85 | |
86 TraceWrapperMember<ModulePendingScriptTreeClient> module_tree_client_; | |
87 bool finished_ = false; | |
88 }; | |
89 | |
90 } // namespace blink | |
91 | |
92 #endif // ModulePendingScript_h | |
OLD | NEW |