| 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/timing/WorkerGlobalScopePerformance.h" |
| 9 #include "core/workers/WorkerClients.h" | 10 #include "core/workers/WorkerClients.h" |
| 10 #include "core/workers/WorkerGlobalScope.h" | 11 #include "core/workers/WorkerGlobalScope.h" |
| 11 #include "platform/Supplementable.h" | 12 #include "platform/Supplementable.h" |
| 12 #include "platform/WebTaskRunner.h" | 13 #include "platform/WebTaskRunner.h" |
| 13 #include "platform/exported/WrappedResourceRequest.h" | 14 #include "platform/exported/WrappedResourceRequest.h" |
| 14 #include "platform/loader/fetch/ResourceFetcher.h" | 15 #include "platform/loader/fetch/ResourceFetcher.h" |
| 15 #include "platform/scheduler/child/web_scheduler.h" | 16 #include "platform/scheduler/child/web_scheduler.h" |
| 16 #include "public/platform/Platform.h" | 17 #include "public/platform/Platform.h" |
| 17 #include "public/platform/WebThread.h" | 18 #include "public/platform/WebThread.h" |
| 18 #include "public/platform/WebURLRequest.h" | 19 #include "public/platform/WebURLRequest.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 BaseFetchContext::AddAdditionalRequestHeaders(request, type); | 179 BaseFetchContext::AddAdditionalRequestHeaders(request, type); |
| 179 | 180 |
| 180 // The remaining modifications are only necessary for HTTP and HTTPS. | 181 // The remaining modifications are only necessary for HTTP and HTTPS. |
| 181 if (!request.Url().IsEmpty() && !request.Url().ProtocolIsInHTTPFamily()) | 182 if (!request.Url().IsEmpty() && !request.Url().ProtocolIsInHTTPFamily()) |
| 182 return; | 183 return; |
| 183 | 184 |
| 184 if (web_context_->IsDataSaverEnabled()) | 185 if (web_context_->IsDataSaverEnabled()) |
| 185 request.SetHTTPHeaderField("Save-Data", "on"); | 186 request.SetHTTPHeaderField("Save-Data", "on"); |
| 186 } | 187 } |
| 187 | 188 |
| 189 void WorkerFetchContext::AddResourceTiming(const ResourceTimingInfo& info) { |
| 190 WorkerGlobalScopePerformance::performance(*worker_global_scope_) |
| 191 ->AddResourceTiming(info); |
| 192 } |
| 193 |
| 188 DEFINE_TRACE(WorkerFetchContext) { | 194 DEFINE_TRACE(WorkerFetchContext) { |
| 189 visitor->Trace(worker_global_scope_); | 195 visitor->Trace(worker_global_scope_); |
| 190 visitor->Trace(resource_fetcher_); | 196 visitor->Trace(resource_fetcher_); |
| 191 BaseFetchContext::Trace(visitor); | 197 BaseFetchContext::Trace(visitor); |
| 192 } | 198 } |
| 193 | 199 |
| 194 void ProvideWorkerFetchContextToWorker( | 200 void ProvideWorkerFetchContextToWorker( |
| 195 WorkerClients* clients, | 201 WorkerClients* clients, |
| 196 std::unique_ptr<WebWorkerFetchContext> web_context) { | 202 std::unique_ptr<WebWorkerFetchContext> web_context) { |
| 197 DCHECK(clients); | 203 DCHECK(clients); |
| 198 WorkerFetchContextHolder::ProvideTo( | 204 WorkerFetchContextHolder::ProvideTo( |
| 199 *clients, WorkerFetchContextHolder::SupplementName(), | 205 *clients, WorkerFetchContextHolder::SupplementName(), |
| 200 new WorkerFetchContextHolder(std::move(web_context))); | 206 new WorkerFetchContextHolder(std::move(web_context))); |
| 201 } | 207 } |
| 202 | 208 |
| 203 } // namespace blink | 209 } // namespace blink |
| OLD | NEW |