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/dom/ScriptModuleResolver.h" | 9 #include "core/dom/ScriptModuleResolver.h" |
10 #include "core/loader/modulescript/ModuleScriptFetchRequest.h" | 10 #include "core/loader/modulescript/ModuleScriptFetchRequest.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 module_script_); | 95 module_script_); |
96 } | 96 } |
97 | 97 |
98 for (const auto& client : clients_) { | 98 for (const auto& client : clients_) { |
99 DispatchFinishedNotificationAsync(client); | 99 DispatchFinishedNotificationAsync(client); |
100 } | 100 } |
101 clients_.clear(); | 101 clients_.clear(); |
102 } | 102 } |
103 | 103 |
104 ModuleScript* ModuleMap::Entry::GetModuleScript() const { | 104 ModuleScript* ModuleMap::Entry::GetModuleScript() const { |
105 DCHECK(!is_fetching_); | |
kouhei (in TOK)
2017/04/26 13:03:44
The module script maybe during fetch if called fro
| |
106 return module_script_.Get(); | 105 return module_script_.Get(); |
107 } | 106 } |
108 | 107 |
109 ModuleMap::ModuleMap(Modulator* modulator) : modulator_(modulator) { | 108 ModuleMap::ModuleMap(Modulator* modulator) : modulator_(modulator) { |
110 DCHECK(modulator); | 109 DCHECK(modulator); |
111 } | 110 } |
112 | 111 |
113 DEFINE_TRACE(ModuleMap) { | 112 DEFINE_TRACE(ModuleMap) { |
114 visitor->Trace(map_); | 113 visitor->Trace(map_); |
115 visitor->Trace(modulator_); | 114 visitor->Trace(modulator_); |
(...skipping 29 matching lines...) Expand all Loading... | |
145 | 144 |
146 // Step 3. If moduleMap[url] exists, asynchronously complete this algorithm | 145 // Step 3. If moduleMap[url] exists, asynchronously complete this algorithm |
147 // with moduleMap[url], and abort these steps. | 146 // with moduleMap[url], and abort these steps. |
148 // Step 10. Set moduleMap[url] to module script, and asynchronously complete | 147 // Step 10. Set moduleMap[url] to module script, and asynchronously complete |
149 // this algorithm with module script. | 148 // this algorithm with module script. |
150 entry->AddClient(client); | 149 entry->AddClient(client); |
151 } | 150 } |
152 | 151 |
153 ModuleScript* ModuleMap::GetFetchedModuleScript(const KURL& url) const { | 152 ModuleScript* ModuleMap::GetFetchedModuleScript(const KURL& url) const { |
154 MapImpl::const_iterator it = map_.Find(url); | 153 MapImpl::const_iterator it = map_.Find(url); |
155 CHECK_NE(it, map_.end()); | 154 if (it == map_.end()) |
155 return nullptr; | |
kouhei (in TOK)
2017/04/26 13:03:44
I forgot why, but we need this.
| |
156 return it->value->GetModuleScript(); | 156 return it->value->GetModuleScript(); |
157 } | 157 } |
158 | 158 |
159 } // namespace blink | 159 } // namespace blink |
OLD | NEW |