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/loader/modulescript/ModuleTreeLinker.h" | 5 #include "core/loader/modulescript/ModuleTreeLinker.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptModule.h" | 7 #include "bindings/core/v8/ScriptModule.h" |
8 #include "core/dom/AncestorList.h" | 8 #include "core/dom/AncestorList.h" |
9 #include "core/dom/ModuleScript.h" | 9 #include "core/dom/ModuleScript.h" |
10 #include "core/loader/modulescript/ModuleScriptFetchRequest.h" | 10 #include "core/loader/modulescript/ModuleScriptFetchRequest.h" |
11 #include "core/loader/modulescript/ModuleTreeLinkerRegistry.h" | 11 #include "core/loader/modulescript/ModuleTreeLinkerRegistry.h" |
| 12 #include "platform/WebTaskRunner.h" |
12 #include "platform/loader/fetch/ResourceLoadingLog.h" | 13 #include "platform/loader/fetch/ResourceLoadingLog.h" |
13 #include "platform/wtf/Vector.h" | 14 #include "platform/wtf/Vector.h" |
14 | 15 |
15 namespace blink { | 16 namespace blink { |
16 | 17 |
17 ModuleTreeLinker* ModuleTreeLinker::Fetch( | 18 ModuleTreeLinker* ModuleTreeLinker::Fetch( |
18 const ModuleScriptFetchRequest& request, | 19 const ModuleScriptFetchRequest& request, |
19 const AncestorList& ancestor_list, | 20 const AncestorList& ancestor_list, |
20 ModuleGraphLevel level, | 21 ModuleGraphLevel level, |
21 Modulator* modulator, | 22 Modulator* modulator, |
22 ModuleTreeLinkerRegistry* registry, | 23 ModuleTreeLinkerRegistry* registry, |
23 ModuleTreeClient* client) { | 24 ModuleTreeClient* client) { |
24 AncestorList ancestor_list_with_url = ancestor_list; | 25 AncestorList ancestor_list_with_url = ancestor_list; |
25 ancestor_list_with_url.insert(request.Url()); | 26 ancestor_list_with_url.insert(request.Url()); |
26 | 27 |
27 ModuleTreeLinker* fetcher = | 28 ModuleTreeLinker* fetcher = |
28 new ModuleTreeLinker(ancestor_list_with_url, modulator, registry, client); | 29 new ModuleTreeLinker(ancestor_list_with_url, modulator, registry, client); |
29 fetcher->FetchSelf(request, level); | 30 fetcher->FetchSelf(request, level); |
30 return fetcher; | 31 return fetcher; |
31 } | 32 } |
32 | 33 |
| 34 ModuleTreeLinker* ModuleTreeLinker::FetchDescendantsForInlineScript( |
| 35 ModuleScript* module_script, |
| 36 Modulator* modulator, |
| 37 ModuleTreeLinkerRegistry* registry, |
| 38 ModuleTreeClient* client) { |
| 39 AncestorList empty_ancestor_list; |
| 40 |
| 41 ModuleTreeLinker* fetcher = |
| 42 new ModuleTreeLinker(empty_ancestor_list, modulator, registry, client); |
| 43 |
| 44 fetcher->module_script_ = module_script; |
| 45 fetcher->AdvanceState(State::kFetchingSelf); |
| 46 modulator->TaskRunner()->PostTask( |
| 47 BLINK_FROM_HERE, |
| 48 WTF::Bind(&ModuleTreeLinker::FetchDescendants, WrapPersistent(fetcher))); |
| 49 return fetcher; |
| 50 } |
| 51 |
33 ModuleTreeLinker::ModuleTreeLinker(const AncestorList& ancestor_list_with_url, | 52 ModuleTreeLinker::ModuleTreeLinker(const AncestorList& ancestor_list_with_url, |
34 Modulator* modulator, | 53 Modulator* modulator, |
35 ModuleTreeLinkerRegistry* registry, | 54 ModuleTreeLinkerRegistry* registry, |
36 ModuleTreeClient* client) | 55 ModuleTreeClient* client) |
37 : modulator_(modulator), | 56 : modulator_(modulator), |
38 registry_(registry), | 57 registry_(registry), |
39 client_(client), | 58 client_(client), |
40 ancestor_list_with_url_(ancestor_list_with_url) { | 59 ancestor_list_with_url_(ancestor_list_with_url) { |
41 CHECK(modulator); | 60 CHECK(modulator); |
42 CHECK(registry); | 61 CHECK(registry); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 HeapHashSet<Member<ModuleScript>> uninstantiated_set; | 473 HeapHashSet<Member<ModuleScript>> uninstantiated_set; |
455 for (const auto& script : inclusive_descendants) { | 474 for (const auto& script : inclusive_descendants) { |
456 if (script->InstantiationState() == | 475 if (script->InstantiationState() == |
457 ModuleInstantiationState::kUninstantiated) | 476 ModuleInstantiationState::kUninstantiated) |
458 uninstantiated_set.insert(script); | 477 uninstantiated_set.insert(script); |
459 } | 478 } |
460 return uninstantiated_set; | 479 return uninstantiated_set; |
461 } | 480 } |
462 | 481 |
463 } // namespace blink | 482 } // namespace blink |
OLD | NEW |