Index: third_party/WebKit/Source/core/dom/ModulePendingScript.h |
diff --git a/third_party/WebKit/Source/core/dom/ModulePendingScript.h b/third_party/WebKit/Source/core/dom/ModulePendingScript.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0db433cb1f01467f84c0ecd29b58f0b4c3a4fc43 |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/dom/ModulePendingScript.h |
@@ -0,0 +1,92 @@ |
+#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.
|
+#define ModulePendingScript_h |
+ |
+#include "bindings/core/v8/TraceWrapperMember.h" |
+#include "core/dom/Modulator.h" |
+#include "core/dom/ModuleScript.h" |
+#include "core/dom/PendingScript.h" |
+ |
+namespace blink { |
+ |
+class ModulePendingScript; |
+ |
+// ModulePendingScriptTreeClient is used to connect from Modulator::FetchTree() |
+// to ModulePendingScript. Because ModulePendingScript is created after |
+// Modulator::FetchTree() is called, ModulePendingScriptTreeClient is |
+// registered as ModuleTreeClient to FetchTree() first, and later |
+// ModulePendingScript is supplied to ModulePendingScriptTreeClient via |
+// SetPendingScript() and is notified of module tree load finish. |
+class ModulePendingScriptTreeClient final |
+ : public GarbageCollectedFinalized<ModulePendingScriptTreeClient>, |
+ 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
|
+ public ModuleTreeClient { |
+ USING_GARBAGE_COLLECTED_MIXIN(ModulePendingScriptTreeClient); |
+ |
+ public: |
+ static ModulePendingScriptTreeClient* Create() { |
+ return new ModulePendingScriptTreeClient(); |
+ } |
+ virtual ~ModulePendingScriptTreeClient() = default; |
+ |
+ void SetPendingScript(ModulePendingScript* client); |
+ |
+ ModuleScript* GetModuleScript() const { return module_script_; } |
+ |
+ DECLARE_TRACE(); |
+ DECLARE_TRACE_WRAPPERS(); |
+ |
+ private: |
+ ModulePendingScriptTreeClient(); |
+ |
+ // Implements ModuleTreeClient |
+ void NotifyModuleTreeLoadFinished(ModuleScript*) override; |
+ |
+ bool finished_ = false; |
+ TraceWrapperMember<ModuleScript> module_script_; |
+ TraceWrapperMember<ModulePendingScript> pending_script_; |
kouhei (in TOK)
2017/04/13 02:25:24
Ditto
hiroshige
2017/04/13 17:53:56
Done.
|
+}; |
+ |
+class CORE_EXPORT ModulePendingScript : public PendingScript { |
+ public: |
+ static ModulePendingScript* Create(ScriptElementBase* element, |
+ ModulePendingScriptTreeClient* client) { |
+ return new ModulePendingScript(element, client); |
+ } |
+ |
+ ~ModulePendingScript() override; |
+ |
+ void NotifyModuleTreeLoadFinished(); |
+ |
+ ModuleScript* GetModuleScript() const { |
+ return module_tree_client_->GetModuleScript(); |
+ } |
+ |
+ DECLARE_TRACE(); |
+ DECLARE_TRACE_WRAPPERS(); |
kouhei (in TOK)
2017/04/13 02:25:24
Ditto
hiroshige
2017/04/13 17:53:56
Done.
|
+ |
+ private: |
+ ModulePendingScript(ScriptElementBase*, ModulePendingScriptTreeClient*); |
+ |
+ // PendingScript |
+ ScriptType GetScriptType() const override { return ScriptType::kModule; } |
+ Script* GetSource(const KURL& document_url, |
+ bool& error_occurred) const override; |
+ bool IsReady() const override; |
+ KURL Url() const override; |
+ bool IsExternal() const override { return true; } |
+ bool ErrorOccurred() const override; |
+ bool WasCanceled() const override; |
+ void StartStreamingIfPossible(Document*, ScriptStreamer::Type) override; |
+ void DisposeInternal() override; |
+ void RemoveFromMemoryCache() override { NOTREACHED(); } |
+ |
+ // FOXME: state check? |
+ void CheckState() const override {} |
+ |
+ TraceWrapperMember<ModulePendingScriptTreeClient> module_tree_client_; |
+ bool finished_ = false; |
+}; |
+ |
+} // namespace blink |
+ |
+#endif // ModulePendingScript_h |