| 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" | |
| 10 #include "core/loader/modulescript/ModuleScriptFetchRequest.h" | 9 #include "core/loader/modulescript/ModuleScriptFetchRequest.h" |
| 11 #include "core/loader/modulescript/ModuleScriptLoaderClient.h" | 10 #include "core/loader/modulescript/ModuleScriptLoaderClient.h" |
| 12 #include "platform/WebTaskRunner.h" | 11 #include "platform/WebTaskRunner.h" |
| 13 | 12 |
| 14 namespace blink { | 13 namespace blink { |
| 15 | 14 |
| 16 // Entry struct represents a value in "module map" spec object. | 15 // Entry struct represents a value in "module map" spec object. |
| 17 // https://html.spec.whatwg.org/multipage/webappapis.html#module-map | 16 // https://html.spec.whatwg.org/multipage/webappapis.html#module-map |
| 18 class ModuleMap::Entry final : public GarbageCollectedFinalized<Entry>, | 17 class ModuleMap::Entry final : public GarbageCollectedFinalized<Entry>, |
| 19 public TraceWrapperBase, | 18 public TraceWrapperBase, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 82 |
| 84 clients_.insert(new_client); | 83 clients_.insert(new_client); |
| 85 } | 84 } |
| 86 | 85 |
| 87 void ModuleMap::Entry::NotifyNewSingleModuleFinished( | 86 void ModuleMap::Entry::NotifyNewSingleModuleFinished( |
| 88 ModuleScript* module_script) { | 87 ModuleScript* module_script) { |
| 89 CHECK(is_fetching_); | 88 CHECK(is_fetching_); |
| 90 module_script_ = module_script; | 89 module_script_ = module_script; |
| 91 is_fetching_ = false; | 90 is_fetching_ = false; |
| 92 | 91 |
| 93 if (module_script_) { | |
| 94 map_->GetModulator()->GetScriptModuleResolver()->RegisterModuleScript( | |
| 95 module_script_); | |
| 96 } | |
| 97 | |
| 98 for (const auto& client : clients_) { | 92 for (const auto& client : clients_) { |
| 99 DispatchFinishedNotificationAsync(client); | 93 DispatchFinishedNotificationAsync(client); |
| 100 } | 94 } |
| 101 clients_.clear(); | 95 clients_.clear(); |
| 102 } | 96 } |
| 103 | 97 |
| 104 ModuleScript* ModuleMap::Entry::GetModuleScript() const { | 98 ModuleScript* ModuleMap::Entry::GetModuleScript() const { |
| 105 DCHECK(!is_fetching_); | 99 DCHECK(!is_fetching_); |
| 106 return module_script_.Get(); | 100 return module_script_.Get(); |
| 107 } | 101 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 entry->AddClient(client); | 144 entry->AddClient(client); |
| 151 } | 145 } |
| 152 | 146 |
| 153 ModuleScript* ModuleMap::GetFetchedModuleScript(const KURL& url) const { | 147 ModuleScript* ModuleMap::GetFetchedModuleScript(const KURL& url) const { |
| 154 MapImpl::const_iterator it = map_.find(url); | 148 MapImpl::const_iterator it = map_.find(url); |
| 155 CHECK_NE(it, map_.end()); | 149 CHECK_NE(it, map_.end()); |
| 156 return it->value->GetModuleScript(); | 150 return it->value->GetModuleScript(); |
| 157 } | 151 } |
| 158 | 152 |
| 159 } // namespace blink | 153 } // namespace blink |
| OLD | NEW |