OLD | NEW |
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 Loading... |
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_); |
99 return module_script_.Get(); | 100 return module_script_.Get(); |
100 } | 101 } |
101 | 102 |
102 ModuleMap::ModuleMap(Modulator* modulator) : modulator_(modulator) { | 103 ModuleMap::ModuleMap(Modulator* modulator) : modulator_(modulator) { |
103 DCHECK(modulator); | 104 DCHECK(modulator); |
104 } | 105 } |
105 | 106 |
106 DEFINE_TRACE(ModuleMap) { | 107 DEFINE_TRACE(ModuleMap) { |
107 visitor->Trace(map_); | 108 visitor->Trace(map_); |
108 visitor->Trace(modulator_); | 109 visitor->Trace(modulator_); |
(...skipping 29 matching lines...) Expand all Loading... |
138 | 139 |
139 // Step 3. If moduleMap[url] exists, asynchronously complete this algorithm | 140 // Step 3. If moduleMap[url] exists, asynchronously complete this algorithm |
140 // with moduleMap[url], and abort these steps. | 141 // with moduleMap[url], and abort these steps. |
141 // Step 10. Set moduleMap[url] to module script, and asynchronously complete | 142 // Step 10. Set moduleMap[url] to module script, and asynchronously complete |
142 // this algorithm with module script. | 143 // this algorithm with module script. |
143 entry->AddClient(client); | 144 entry->AddClient(client); |
144 } | 145 } |
145 | 146 |
146 ModuleScript* ModuleMap::GetFetchedModuleScript(const KURL& url) const { | 147 ModuleScript* ModuleMap::GetFetchedModuleScript(const KURL& url) const { |
147 MapImpl::const_iterator it = map_.find(url); | 148 MapImpl::const_iterator it = map_.find(url); |
148 if (it == map_.end()) | 149 CHECK_NE(it, map_.end()); |
149 return nullptr; | |
150 return it->value->GetModuleScript(); | 150 return it->value->GetModuleScript(); |
151 } | 151 } |
152 | 152 |
153 } // namespace blink | 153 } // namespace blink |
OLD | NEW |