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

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: 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 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..c2c4a10af68e5968ecd9b151d053d4f9a9eaef72
--- /dev/null
+++ b/third_party/WebKit/Source/core/loader/modulescript/ModuleTreeLinker.h
@@ -0,0 +1,77 @@
+// 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/Modulator.h"
+#include "wtf/HashSet.h"
+
+namespace blink {
+
+class ModuleTreeLinkerRegistry;
+
+// 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.
+// 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 KURL&,
+ const KURL& baseURL,
+ 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(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,
yhirano 2017/01/06 07:27:01 Not used
kouhei (in TOK) 2017/01/11 01:41:58 Fixed.
+ Finished,
+ };
+ void advanceState(State);
+
+ void fetchSelf(const KURL&, const KURL& baseURL);
+ // Implements SingleModuleClient
+ void notifyFinishedSingleModule(ModuleScript*) override;
+
+ void fetchDescendants();
+ void notifyOneDescendantFinished(bool wasSuccess);
+
+ void instantiate();
+ HeapHashSet<Member<ModuleScript>> uninstantiatedInclusiveDescendants();
+
+ class DependencyModuleClient;
+ friend class DependencyModuleClient;
+
+ Member<Modulator> m_modulator;
+ Member<ModuleTreeLinkerRegistry> m_registry;
+ Member<ModuleTreeClient> m_client;
+ 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