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

Unified Diff: third_party/WebKit/Source/core/dom/ModulatorImpl.cpp

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/dom/ModulatorImpl.cpp
diff --git a/third_party/WebKit/Source/core/dom/ModulatorImpl.cpp b/third_party/WebKit/Source/core/dom/ModulatorImpl.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..981837a18302ac31d58467d620b9f5f20323156f
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/ModulatorImpl.cpp
@@ -0,0 +1,95 @@
+// 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.
+
+#include "core/dom/ModulatorImpl.h"
+
+#include "bindings/core/v8/ModuleController.h"
+#include "core/dom/ExecutionContext.h"
+#include "core/dom/ModuleMap.h"
+#include "core/dom/ModuleScript.h"
+#include "core/dom/ScriptModuleResolverImpl.h"
+#include "core/dom/TaskRunnerHelper.h"
+#include "core/fetch/ResourceFetcher.h"
+#include "core/loader/modulescript/ModuleScriptLoaderRegistry.h"
+#include "core/loader/modulescript/ModuleTreeLinkerRegistry.h"
+
+namespace blink {
+
+ModulatorImpl::ModulatorImpl(ExecutionContext* executionContext,
+ ModuleController* moduleController,
+ ResourceFetcher* fetcher)
+ : m_map(ModuleMap::create(this)),
+ m_executionContext(executionContext),
+ m_moduleController(moduleController),
+ m_fetcher(fetcher),
+ m_loaderRegistry(ModuleScriptLoaderRegistry::create()),
+ m_treeLinkerRegistry(ModuleTreeLinkerRegistry::create()) {
+ DCHECK(m_executionContext);
+ DCHECK(m_moduleController);
+ DCHECK(m_fetcher);
+}
+
+ModulatorImpl::~ModulatorImpl() {}
+
+ScriptModuleResolver* ModulatorImpl::scriptModuleResolver() {
+ if (!m_scriptModuleResolver) {
+ m_scriptModuleResolver = ScriptModuleResolverImpl::create(this);
+ }
+
+ return m_scriptModuleResolver.get();
+}
+
+WebTaskRunner* ModulatorImpl::taskRunner() {
+ return TaskRunnerHelper::get(TaskType::Networking, m_executionContext.get());
+}
+
+void ModulatorImpl::fetchTree(const KURL& url,
+ const KURL& baseURL,
+ ModuleTreeClient* client) {
+ // Step 1. Perform the internal module script graph fetching procedure given
+ // url, settings object, destination, cryptographic nonce, parser state,
+ // credentials mode, settings object, a new empty list, "client", and with the
+ // top-level module fetch flag set. If the caller of this algorithm specified
+ // custom perform the fetch steps, pass those along as well.
+ fetchTreeInternal(url, baseURL, client);
+
+ // Step 2. When the internal module script graph fetching procedure
+ // asynchronously completes with result, asynchronously complete this
+ // algorithm with result.
+}
+
+void ModulatorImpl::fetchSingle(const KURL& url,
+ const KURL& baseURL,
+ SingleModuleClient* client) {
+ m_map->retrieveAndFetchIfNeeded(url, baseURL, client);
+}
+
+void ModulatorImpl::fetchNewSingleModule(const KURL& url,
+ const KURL& baseURL,
+ ModuleScriptLoaderClient* client) {
+ m_loaderRegistry->fetch(url, baseURL, m_moduleController.get(),
+ m_fetcher.get(), client);
+}
+
+void ModulatorImpl::fetchTreeInternal(const KURL& url,
+ const KURL& baseURL,
+ ModuleTreeClient* client) {
+ m_treeLinkerRegistry->fetch(url, baseURL, this, client);
+}
+
+ModuleScript* ModulatorImpl::retrieveFetchedModuleScript(const KURL& url) {
+ return m_map->retrieveFetchedModuleScript(url);
+}
+
+DEFINE_TRACE(ModulatorImpl) {
+ visitor->trace(m_map);
+ visitor->trace(m_scriptModuleResolver);
+ visitor->trace(m_executionContext);
+ visitor->trace(m_moduleController);
+ visitor->trace(m_fetcher);
+ visitor->trace(m_loaderRegistry);
+ visitor->trace(m_treeLinkerRegistry);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698