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

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: rebased Created 3 years, 8 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 ScriptModuleHash::hash(moduleScript->record()));
20 #endif
21
22 DCHECK(moduleScript);
23 DCHECK(!moduleScript->record().isNull());
24 auto result = m_recordToModuleScriptMap.set(
25 moduleScript->record(), moduleScript);
26 DCHECK(result.isNewEntry);
27 }
28
29 ScriptModule ScriptModuleResolverImpl::resolve(
30 const String& specifier,
31 const ScriptModule& referrer,
32 ExceptionState& exceptionState) {
33 // TODO(kouhei):
34 // https://html.spec.whatwg.org/#hostresolveimportedmodule(referencingmodule,-sp ecifier)
35 #ifndef NDEBUG
36 printf("ScriptModuleResolverImpl::resolve(\"%s\") hash: %u\n",
37 specifier.utf8().data(), ScriptModuleHash::hash(referrer));
38 #endif
39
40 const auto it = m_recordToModuleScriptMap.find(referrer);
41 CHECK_NE(it, m_recordToModuleScriptMap.end())
42 << "Failed to find referrer ModuleScript corresponding to the record";
43 ModuleScript* referrerModule = it->value;
44
45 KURL url =
46 Modulator::resolveModuleSpecifier(specifier, referrerModule->baseURL());
47 ModuleScript* moduleScript = m_modulator->getFetchedModuleScript(url);
48 return moduleScript->record();
49 }
50
51 DEFINE_TRACE(ScriptModuleResolverImpl) {
52 ScriptModuleResolver::trace(visitor);
53 visitor->trace(m_recordToModuleScriptMap);
54 visitor->trace(m_modulator);
55 }
56
57 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698