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

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

Issue 2860993002: [ES6 modules] ModuleMap::GetFetchedModuleScript to return nullptr when entry not found / "fetching" (Closed)
Patch Set: neis Created 3 years, 7 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/ModuleMap.h" 5 #include "core/dom/ModuleMap.h"
6 6
7 #include "core/dom/Modulator.h" 7 #include "core/dom/Modulator.h"
8 #include "core/dom/ModuleScript.h" 8 #include "core/dom/ModuleScript.h"
9 #include "core/loader/modulescript/ModuleScriptFetchRequest.h" 9 #include "core/loader/modulescript/ModuleScriptFetchRequest.h"
10 #include "core/loader/modulescript/ModuleScriptLoaderClient.h" 10 #include "core/loader/modulescript/ModuleScriptLoaderClient.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 module_script_ = module_script; 89 module_script_ = module_script;
90 is_fetching_ = false; 90 is_fetching_ = false;
91 91
92 for (const auto& client : clients_) { 92 for (const auto& client : clients_) {
93 DispatchFinishedNotificationAsync(client); 93 DispatchFinishedNotificationAsync(client);
94 } 94 }
95 clients_.clear(); 95 clients_.clear();
96 } 96 }
97 97
98 ModuleScript* ModuleMap::Entry::GetModuleScript() const { 98 ModuleScript* ModuleMap::Entry::GetModuleScript() const {
99 DCHECK(!is_fetching_);
100 return module_script_.Get(); 99 return module_script_.Get();
101 } 100 }
102 101
103 ModuleMap::ModuleMap(Modulator* modulator) : modulator_(modulator) { 102 ModuleMap::ModuleMap(Modulator* modulator) : modulator_(modulator) {
104 DCHECK(modulator); 103 DCHECK(modulator);
105 } 104 }
106 105
107 DEFINE_TRACE(ModuleMap) { 106 DEFINE_TRACE(ModuleMap) {
108 visitor->Trace(map_); 107 visitor->Trace(map_);
109 visitor->Trace(modulator_); 108 visitor->Trace(modulator_);
(...skipping 29 matching lines...) Expand all
139 138
140 // Step 3. If moduleMap[url] exists, asynchronously complete this algorithm 139 // Step 3. If moduleMap[url] exists, asynchronously complete this algorithm
141 // with moduleMap[url], and abort these steps. 140 // with moduleMap[url], and abort these steps.
142 // Step 10. Set moduleMap[url] to module script, and asynchronously complete 141 // Step 10. Set moduleMap[url] to module script, and asynchronously complete
143 // this algorithm with module script. 142 // this algorithm with module script.
144 entry->AddClient(client); 143 entry->AddClient(client);
145 } 144 }
146 145
147 ModuleScript* ModuleMap::GetFetchedModuleScript(const KURL& url) const { 146 ModuleScript* ModuleMap::GetFetchedModuleScript(const KURL& url) const {
148 MapImpl::const_iterator it = map_.find(url); 147 MapImpl::const_iterator it = map_.find(url);
149 CHECK_NE(it, map_.end()); 148 if (it == map_.end())
149 return nullptr;
150 return it->value->GetModuleScript(); 150 return it->value->GetModuleScript();
151 } 151 }
neis 2017/05/15 09:08:26 In Modulator.h, the comment on GetFetchedModuleScr
152 152
153 } // namespace blink 153 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/external/wpt/html/semantics/scripting-1/the-script-element/module/resources/delayed-modulescript.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698