| 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/WorkerFetchContext.h" | 5 #include "core/loader/WorkerFetchContext.h" |
| 6 | 6 |
| 7 #include "core/frame/Deprecation.h" | 7 #include "core/frame/Deprecation.h" |
| 8 #include "core/frame/UseCounter.h" | 8 #include "core/frame/UseCounter.h" |
| 9 #include "core/loader/MixedContentChecker.h" |
| 9 #include "core/timing/WorkerGlobalScopePerformance.h" | 10 #include "core/timing/WorkerGlobalScopePerformance.h" |
| 10 #include "core/workers/WorkerClients.h" | 11 #include "core/workers/WorkerClients.h" |
| 11 #include "core/workers/WorkerGlobalScope.h" | 12 #include "core/workers/WorkerGlobalScope.h" |
| 12 #include "platform/Supplementable.h" | 13 #include "platform/Supplementable.h" |
| 13 #include "platform/WebTaskRunner.h" | 14 #include "platform/WebTaskRunner.h" |
| 14 #include "platform/exported/WrappedResourceRequest.h" | 15 #include "platform/exported/WrappedResourceRequest.h" |
| 15 #include "platform/loader/fetch/ResourceFetcher.h" | 16 #include "platform/loader/fetch/ResourceFetcher.h" |
| 16 #include "platform/scheduler/child/web_scheduler.h" | 17 #include "platform/scheduler/child/web_scheduler.h" |
| 17 #include "public/platform/Platform.h" | 18 #include "public/platform/Platform.h" |
| 19 #include "public/platform/WebMixedContent.h" |
| 20 #include "public/platform/WebMixedContentContextType.h" |
| 18 #include "public/platform/WebThread.h" | 21 #include "public/platform/WebThread.h" |
| 19 #include "public/platform/WebURLRequest.h" | 22 #include "public/platform/WebURLRequest.h" |
| 20 #include "public/platform/WebWorkerFetchContext.h" | 23 #include "public/platform/WebWorkerFetchContext.h" |
| 21 | 24 |
| 22 namespace blink { | 25 namespace blink { |
| 23 | 26 |
| 24 namespace { | 27 namespace { |
| 25 | 28 |
| 26 // WorkerFetchContextHolder is used to pass the WebWorkerFetchContext from the | 29 // WorkerFetchContextHolder is used to pass the WebWorkerFetchContext from the |
| 27 // main thread to the worker thread by attaching to the WorkerClients as a | 30 // main thread to the worker thread by attaching to the WorkerClients as a |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 BaseFetchContext::AddAdditionalRequestHeaders(request, type); | 186 BaseFetchContext::AddAdditionalRequestHeaders(request, type); |
| 184 | 187 |
| 185 // The remaining modifications are only necessary for HTTP and HTTPS. | 188 // The remaining modifications are only necessary for HTTP and HTTPS. |
| 186 if (!request.Url().IsEmpty() && !request.Url().ProtocolIsInHTTPFamily()) | 189 if (!request.Url().IsEmpty() && !request.Url().ProtocolIsInHTTPFamily()) |
| 187 return; | 190 return; |
| 188 | 191 |
| 189 if (web_context_->IsDataSaverEnabled()) | 192 if (web_context_->IsDataSaverEnabled()) |
| 190 request.SetHTTPHeaderField("Save-Data", "on"); | 193 request.SetHTTPHeaderField("Save-Data", "on"); |
| 191 } | 194 } |
| 192 | 195 |
| 196 void WorkerFetchContext::DispatchDidReceiveResponse( |
| 197 unsigned long identifier, |
| 198 const ResourceResponse& response, |
| 199 WebURLRequest::FrameType frame_type, |
| 200 WebURLRequest::RequestContext request_context, |
| 201 Resource* resource, |
| 202 ResourceResponseType) { |
| 203 if (response.HasMajorCertificateErrors()) { |
| 204 WebMixedContentContextType context_type = |
| 205 WebMixedContent::ContextTypeFromRequestContext( |
| 206 request_context, false /* strictMixedContentCheckingForPlugin */); |
| 207 if (context_type == WebMixedContentContextType::kBlockable) { |
| 208 web_context_->DidRunContentWithCertificateErrors(response.Url()); |
| 209 } else { |
| 210 web_context_->DidDisplayContentWithCertificateErrors(response.Url()); |
| 211 } |
| 212 } |
| 213 } |
| 214 |
| 193 void WorkerFetchContext::AddResourceTiming(const ResourceTimingInfo& info) { | 215 void WorkerFetchContext::AddResourceTiming(const ResourceTimingInfo& info) { |
| 194 WorkerGlobalScopePerformance::performance(*worker_global_scope_) | 216 WorkerGlobalScopePerformance::performance(*worker_global_scope_) |
| 195 ->AddResourceTiming(info); | 217 ->AddResourceTiming(info); |
| 196 } | 218 } |
| 197 | 219 |
| 198 void WorkerFetchContext::PopulateResourceRequest( | 220 void WorkerFetchContext::PopulateResourceRequest( |
| 199 const KURL& url, | 221 const KURL& url, |
| 200 Resource::Type type, | 222 Resource::Type type, |
| 201 const ClientHintsPreferences& hints_preferences, | 223 const ClientHintsPreferences& hints_preferences, |
| 202 const FetchParameters::ResourceWidth& resource_width, | 224 const FetchParameters::ResourceWidth& resource_width, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 226 void ProvideWorkerFetchContextToWorker( | 248 void ProvideWorkerFetchContextToWorker( |
| 227 WorkerClients* clients, | 249 WorkerClients* clients, |
| 228 std::unique_ptr<WebWorkerFetchContext> web_context) { | 250 std::unique_ptr<WebWorkerFetchContext> web_context) { |
| 229 DCHECK(clients); | 251 DCHECK(clients); |
| 230 WorkerFetchContextHolder::ProvideTo( | 252 WorkerFetchContextHolder::ProvideTo( |
| 231 *clients, WorkerFetchContextHolder::SupplementName(), | 253 *clients, WorkerFetchContextHolder::SupplementName(), |
| 232 new WorkerFetchContextHolder(std::move(web_context))); | 254 new WorkerFetchContextHolder(std::move(web_context))); |
| 233 } | 255 } |
| 234 | 256 |
| 235 } // namespace blink | 257 } // namespace blink |
| OLD | NEW |