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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/dom/ModulatorImpl.h"
6
7 #include "bindings/core/v8/ModuleController.h"
8 #include "core/dom/ExecutionContext.h"
9 #include "core/dom/ModuleMap.h"
10 #include "core/dom/ModuleScript.h"
11 #include "core/dom/ScriptModuleResolverImpl.h"
12 #include "core/dom/TaskRunnerHelper.h"
13 #include "core/fetch/ResourceFetcher.h"
14 #include "core/loader/modulescript/ModuleScriptLoaderRegistry.h"
15 #include "core/loader/modulescript/ModuleTreeLinkerRegistry.h"
16
17 namespace blink {
18
19 ModulatorImpl::ModulatorImpl(ExecutionContext* executionContext,
20 ModuleController* moduleController,
21 ResourceFetcher* fetcher)
22 : m_map(ModuleMap::create(this)),
23 m_executionContext(executionContext),
24 m_moduleController(moduleController),
25 m_fetcher(fetcher),
26 m_loaderRegistry(ModuleScriptLoaderRegistry::create()),
27 m_treeLinkerRegistry(ModuleTreeLinkerRegistry::create()) {
28 DCHECK(m_executionContext);
29 DCHECK(m_moduleController);
30 DCHECK(m_fetcher);
31 }
32
33 ModulatorImpl::~ModulatorImpl() {}
34
35 ScriptModuleResolver* ModulatorImpl::scriptModuleResolver() {
36 if (!m_scriptModuleResolver) {
37 m_scriptModuleResolver = ScriptModuleResolverImpl::create(this);
38 }
39
40 return m_scriptModuleResolver.get();
41 }
42
43 WebTaskRunner* ModulatorImpl::taskRunner() {
44 return TaskRunnerHelper::get(TaskType::Networking, m_executionContext.get());
45 }
46
47 void ModulatorImpl::fetchTree(const KURL& url,
48 const KURL& baseURL,
49 ModuleTreeClient* client) {
50 // Step 1. Perform the internal module script graph fetching procedure given
51 // url, settings object, destination, cryptographic nonce, parser state,
52 // credentials mode, settings object, a new empty list, "client", and with the
53 // top-level module fetch flag set. If the caller of this algorithm specified
54 // custom perform the fetch steps, pass those along as well.
55 fetchTreeInternal(url, baseURL, client);
56
57 // Step 2. When the internal module script graph fetching procedure
58 // asynchronously completes with result, asynchronously complete this
59 // algorithm with result.
60 }
61
62 void ModulatorImpl::fetchSingle(const KURL& url,
63 const KURL& baseURL,
64 SingleModuleClient* client) {
65 m_map->retrieveAndFetchIfNeeded(url, baseURL, client);
66 }
67
68 void ModulatorImpl::fetchNewSingleModule(const KURL& url,
69 const KURL& baseURL,
70 ModuleScriptLoaderClient* client) {
71 m_loaderRegistry->fetch(url, baseURL, m_moduleController.get(),
72 m_fetcher.get(), client);
73 }
74
75 void ModulatorImpl::fetchTreeInternal(const KURL& url,
76 const KURL& baseURL,
77 ModuleTreeClient* client) {
78 m_treeLinkerRegistry->fetch(url, baseURL, this, client);
79 }
80
81 ModuleScript* ModulatorImpl::retrieveFetchedModuleScript(const KURL& url) {
82 return m_map->retrieveFetchedModuleScript(url);
83 }
84
85 DEFINE_TRACE(ModulatorImpl) {
86 visitor->trace(m_map);
87 visitor->trace(m_scriptModuleResolver);
88 visitor->trace(m_executionContext);
89 visitor->trace(m_moduleController);
90 visitor->trace(m_fetcher);
91 visitor->trace(m_loaderRegistry);
92 visitor->trace(m_treeLinkerRegistry);
93 }
94
95 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698