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/ModuleScriptFetcher.h" | 5 #include "core/loader/modulescript/ModuleScriptFetcher.h" |
6 | 6 |
7 #include "core/dom/ExecutionContext.h" | 7 #include "core/dom/ExecutionContext.h" |
8 #include "core/inspector/ConsoleMessage.h" | 8 #include "core/inspector/ConsoleMessage.h" |
9 #include "platform/loader/fetch/FetchUtils.h" | 9 #include "platform/loader/fetch/FetchUtils.h" |
10 #include "platform/network/mime/MIMETypeRegistry.h" | 10 #include "platform/network/mime/MIMETypeRegistry.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 ConsoleMessage* error_message = nullptr; | 90 ConsoleMessage* error_message = nullptr; |
91 if (!WasModuleLoadSuccessful(script_resource, &error_message)) { | 91 if (!WasModuleLoadSuccessful(script_resource, &error_message)) { |
92 if (error_message) { | 92 if (error_message) { |
93 ExecutionContext::From(modulator_->GetScriptState()) | 93 ExecutionContext::From(modulator_->GetScriptState()) |
94 ->AddConsoleMessage(error_message); | 94 ->AddConsoleMessage(error_message); |
95 } | 95 } |
96 Finalize(WTF::nullopt); | 96 Finalize(WTF::nullopt); |
97 return; | 97 return; |
98 } | 98 } |
99 | 99 |
| 100 const ScriptResourceData* resource_data = GetResource()->ResourceData(); |
100 ModuleScriptCreationParams params( | 101 ModuleScriptCreationParams params( |
101 script_resource->GetResponse().Url(), script_resource->SourceText(), | 102 resource_data->GetResponse().Url(), resource_data->SourceText(), |
102 script_resource->GetResourceRequest().GetFetchCredentialsMode(), | 103 resource_data->GetFetchCredentialsMode(), |
103 script_resource->CalculateAccessControlStatus()); | 104 resource_data->CalculateAccessControlStatus()); |
104 Finalize(params); | 105 Finalize(params); |
105 } | 106 } |
106 | 107 |
107 void ModuleScriptFetcher::Finalize( | 108 void ModuleScriptFetcher::Finalize( |
108 const WTF::Optional<ModuleScriptCreationParams>& params) { | 109 const WTF::Optional<ModuleScriptCreationParams>& params) { |
109 was_fetched_ = true; | 110 was_fetched_ = true; |
110 client_->NotifyFetchFinished(params); | 111 client_->NotifyFetchFinished(params); |
111 } | 112 } |
112 | 113 |
113 DEFINE_TRACE(ModuleScriptFetcher) { | 114 DEFINE_TRACE(ModuleScriptFetcher) { |
114 visitor->Trace(fetcher_); | 115 visitor->Trace(fetcher_); |
115 visitor->Trace(modulator_); | 116 visitor->Trace(modulator_); |
116 visitor->Trace(client_); | 117 visitor->Trace(client_); |
117 ResourceOwner<ScriptResource>::Trace(visitor); | 118 ResourceOwner<ScriptResource>::Trace(visitor); |
118 } | 119 } |
119 | 120 |
120 } // namespace blink | 121 } // namespace blink |
OLD | NEW |