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

Unified 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: rebased Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.h
diff --git a/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.h b/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.h
new file mode 100644
index 0000000000000000000000000000000000000000..45bd9434a79e6ca2b1ba1f57e5eecfa08dabe2a6
--- /dev/null
+++ b/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.h
@@ -0,0 +1,85 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ModuleTreeLinker_h
+#define ModuleTreeLinker_h
+
+#include "core/dom/AncestorList.h"
+#include "core/dom/Modulator.h"
+
+namespace blink {
+
+class ModuleScriptFetchRequest;
+enum class ModuleGraphLevel;
+class ModuleTreeLinkerRegistry;
+
+// A ModuleTreeLinker is responsible for running and keeping intermediate states
+// for "internal module script graph fetching procedure" for a module graph tree
+// node.
+// https://html.spec.whatwg.org/multipage/webappapis.html#internal-module-script-graph-fetching-procedure
+class ModuleTreeLinker final
+ : public GarbageCollectedFinalized<ModuleTreeLinker>,
+ public SingleModuleClient {
+ USING_GARBAGE_COLLECTED_MIXIN(ModuleTreeLinker);
+
+ public:
+ static ModuleTreeLinker* fetch(const ModuleScriptFetchRequest&,
+ const AncestorList&,
+ ModuleGraphLevel,
+ Modulator*,
+ ModuleTreeLinkerRegistry*,
+ ModuleTreeClient*);
+ virtual ~ModuleTreeLinker() = default;
+ DECLARE_TRACE();
+
+ bool isFetching() const {
+ return State::FetchingSelf <= m_state && m_state < State::Finished;
+ }
+ bool hasFinished() const { return m_state == State::Finished; }
+
+ private:
+ ModuleTreeLinker(const AncestorList& ancestorListWithUrl,
+ Modulator*,
+ ModuleTreeLinkerRegistry*,
+ ModuleTreeClient*);
+
+ enum class State {
+ Initial,
+ // Running fetch of the module script corresponding to the target node.
+ FetchingSelf,
+ // Running fetch of descendants of the target node.
+ FetchingDependencies,
+ // Instantiating m_moduleScript and the node descendants.
+ Instantiating,
+ Finished,
+ };
+ void advanceState(State);
+
+ void fetchSelf(const ModuleScriptFetchRequest&, ModuleGraphLevel);
+ // Implements SingleModuleClient
+ void notifyModuleLoadFinished(ModuleScript*) override;
+
+ void fetchDescendants();
+ enum class DescendantLoad { Failed, Success };
+ void notifyOneDescendantFinished(DescendantLoad wasSuccess);
+
+ void instantiate();
+ HeapHashSet<Member<ModuleScript>> uninstantiatedInclusiveDescendants();
+
+ class DependencyModuleClient;
+ friend class DependencyModuleClient;
+
+ Member<Modulator> m_modulator;
+ Member<ModuleTreeLinkerRegistry> m_registry;
+ Member<ModuleTreeClient> m_client;
+ HashSet<KURL> m_ancestorListWithUrl;
+ State m_state = State::Initial;
+ Member<ModuleScript> m_moduleScript;
+ size_t m_numIncompleteDescendants = 0;
+ HeapHashSet<Member<DependencyModuleClient>> m_dependencyClients;
+};
+
+} // namespace blink
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698