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

Side by Side Diff: third_party/WebKit/Source/core/dom/ScriptModuleResolverImpl.cpp

Issue 2555653002: [WIP Prototype] ES6 https://html.spec.whatwg.org/#fetch-a-single-module-script implementation (Closed)
Patch Set: snapshot Created 3 years, 10 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/ScriptModuleResolverImpl.h"
6
7 #include "bindings/core/v8/ScriptModule.h"
8 #include "core/dom/Modulator.h"
9 #include "core/dom/ModuleScript.h"
10
11 namespace blink {
12
13 void ScriptModuleResolverImpl::registerModuleScript(
14 ModuleScript* moduleScript) {
15 #ifndef NDEBUG
16 printf(
17 "ScriptModuleResolverImpl::registerModuleScript(url=\"%s\", hash=%u)\n",
18 moduleScript->baseURL().getString().utf8().data(),
19 ScriptModuleIdentifierHash::hash(moduleScript->record().identifier()));
20 #endif
21
22 DCHECK(moduleScript);
23 DCHECK(!moduleScript->record().isNull());
24 auto result = m_recordToModuleScriptMap.set(
25 moduleScript->record().identifier(), moduleScript);
26 DCHECK(result.isNewEntry);
27 }
28
29 ScriptModule ScriptModuleResolverImpl::resolve(const String& specifier,
30 ScriptModuleIdentifier referrer,
31 ExceptionState& exceptionState) {
32 // TODO(kouhei):
33 // https://html.spec.whatwg.org/#hostresolveimportedmodule(referencingmodule,-sp ecifier)
34 #ifndef NDEBUG
35 printf("ScriptModuleResolverImpl::resolve(\"%s\") hash: %u\n",
36 specifier.utf8().data(), ScriptModuleIdentifierHash::hash(referrer));
37 #endif
38
39 const auto it = m_recordToModuleScriptMap.find(referrer);
40 CHECK_NE(it, m_recordToModuleScriptMap.end())
41 << "Failed to find referrer ModuleScript corresponding to the record";
42 ModuleScript* referrerModule = it->value;
43
44 KURL url =
45 Modulator::resolveModuleSpecifier(specifier, referrerModule->baseURL());
46 ModuleScript* moduleScript = m_modulator->retrieveFetchedModuleScript(url);
47 return moduleScript->record();
48 }
49
50 DEFINE_TRACE(ScriptModuleResolverImpl) {
51 ScriptModuleResolver::trace(visitor);
52 visitor->trace(m_recordToModuleScriptMap);
53 visitor->trace(m_modulator);
54 }
55
56 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/ScriptModuleResolverImpl.h ('k') | third_party/WebKit/Source/core/loader/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698