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 15 matching lines...) Expand all Loading... | |
26 | 26 |
27 DECLARE_TRACE(); | 27 DECLARE_TRACE(); |
28 DECLARE_TRACE_WRAPPERS(); | 28 DECLARE_TRACE_WRAPPERS(); |
29 | 29 |
30 // Notify fetched |m_moduleScript| to the client asynchronously. | 30 // Notify fetched |m_moduleScript| to the client asynchronously. |
31 void AddClient(SingleModuleClient*); | 31 void AddClient(SingleModuleClient*); |
32 | 32 |
33 // This is only to be used from ScriptModuleResolver implementations. | 33 // This is only to be used from ScriptModuleResolver implementations. |
34 ModuleScript* GetModuleScript() const; | 34 ModuleScript* GetModuleScript() const; |
35 | 35 |
36 // Implements ModuleScriptLoaderClient | |
37 void NotifyNewSingleModuleFinished(ModuleScript*) override; | |
38 | |
36 private: | 39 private: |
37 explicit Entry(ModuleMap*); | 40 explicit Entry(ModuleMap*); |
38 | 41 |
39 void DispatchFinishedNotificationAsync(SingleModuleClient*); | 42 void DispatchFinishedNotificationAsync(SingleModuleClient*); |
40 | 43 |
41 // Implements ModuleScriptLoaderClient | |
42 void NotifyNewSingleModuleFinished(ModuleScript*) override; | |
43 | |
44 TraceWrapperMember<ModuleScript> module_script_; | 44 TraceWrapperMember<ModuleScript> module_script_; |
45 Member<ModuleMap> map_; | 45 Member<ModuleMap> map_; |
46 | 46 |
47 // Correspond to the HTML spec: "fetching" state. | 47 // Correspond to the HTML spec: "fetching" state. |
48 bool is_fetching_ = true; | 48 bool is_fetching_ = true; |
49 | 49 |
50 HeapHashSet<Member<SingleModuleClient>> clients_; | 50 HeapHashSet<Member<SingleModuleClient>> clients_; |
51 }; | 51 }; |
52 | 52 |
53 ModuleMap::Entry::Entry(ModuleMap* map) | 53 ModuleMap::Entry::Entry(ModuleMap* map) |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 } | 143 } |
144 DCHECK(entry); | 144 DCHECK(entry); |
145 | 145 |
146 // Step 3. If moduleMap[url] exists, asynchronously complete this algorithm | 146 // Step 3. If moduleMap[url] exists, asynchronously complete this algorithm |
147 // with moduleMap[url], and abort these steps. | 147 // with moduleMap[url], and abort these steps. |
148 // Step 10. Set moduleMap[url] to module script, and asynchronously complete | 148 // Step 10. Set moduleMap[url] to module script, and asynchronously complete |
149 // this algorithm with module script. | 149 // this algorithm with module script. |
150 entry->AddClient(client); | 150 entry->AddClient(client); |
151 } | 151 } |
152 | 152 |
153 void ModuleMap::SetInlineModuleScript(ModuleScript* module_script) { | |
154 MapImpl::AddResult result = map_.insert( | |
155 module_script->BaseURL(), TraceWrapperMember<Entry>(this, nullptr)); | |
156 TraceWrapperMember<Entry>& entry = result.stored_value->value; | |
157 DCHECK(result.is_new_entry); | |
158 entry = TraceWrapperMember<Entry>(this, Entry::Create(this)); | |
159 entry->NotifyNewSingleModuleFinished(module_script); | |
kouhei (in TOK)
2017/04/27 03:47:25
This will allow other module script in the graph t
hiroshige
2017/04/27 21:57:20
This function is removed.
| |
160 } | |
161 | |
153 ModuleScript* ModuleMap::GetFetchedModuleScript(const KURL& url) const { | 162 ModuleScript* ModuleMap::GetFetchedModuleScript(const KURL& url) const { |
154 MapImpl::const_iterator it = map_.find(url); | 163 MapImpl::const_iterator it = map_.find(url); |
155 CHECK_NE(it, map_.end()); | 164 CHECK_NE(it, map_.end()); |
156 return it->value->GetModuleScript(); | 165 return it->value->GetModuleScript(); |
157 } | 166 } |
158 | 167 |
159 } // namespace blink | 168 } // namespace blink |
OLD | NEW |