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/workers/WorkerClients.h" | 9 #include "core/workers/WorkerClients.h" |
10 #include "core/workers/WorkerGlobalScope.h" | 10 #include "core/workers/WorkerGlobalScope.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 loading_task_runner_->ToSingleThreadTaskRunner()); | 85 loading_task_runner_->ToSingleThreadTaskRunner()); |
86 } | 86 } |
87 | 87 |
88 ResourceFetcher* WorkerFetchContext::GetResourceFetcher() { | 88 ResourceFetcher* WorkerFetchContext::GetResourceFetcher() { |
89 if (resource_fetcher_) | 89 if (resource_fetcher_) |
90 return resource_fetcher_; | 90 return resource_fetcher_; |
91 resource_fetcher_ = ResourceFetcher::Create(this); | 91 resource_fetcher_ = ResourceFetcher::Create(this); |
92 return resource_fetcher_; | 92 return resource_fetcher_; |
93 } | 93 } |
94 | 94 |
95 KURL WorkerFetchContext::FirstPartyForCookies() const { | |
96 return web_context_->FirstPartyForCookies(); | |
97 } | |
98 | |
95 ContentSettingsClient* WorkerFetchContext::GetContentSettingsClient() const { | 99 ContentSettingsClient* WorkerFetchContext::GetContentSettingsClient() const { |
96 // TODO(horo): Implement this. | 100 // TODO(horo): Implement this. |
97 return nullptr; | 101 return nullptr; |
98 } | 102 } |
99 | 103 |
100 Settings* WorkerFetchContext::GetSettings() const { | 104 Settings* WorkerFetchContext::GetSettings() const { |
101 // TODO(horo): Implement this. | 105 // TODO(horo): Implement this. |
102 return nullptr; | 106 return nullptr; |
103 } | 107 } |
104 | 108 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 BaseFetchContext::AddAdditionalRequestHeaders(request, type); | 182 BaseFetchContext::AddAdditionalRequestHeaders(request, type); |
179 | 183 |
180 // The remaining modifications are only necessary for HTTP and HTTPS. | 184 // The remaining modifications are only necessary for HTTP and HTTPS. |
181 if (!request.Url().IsEmpty() && !request.Url().ProtocolIsInHTTPFamily()) | 185 if (!request.Url().IsEmpty() && !request.Url().ProtocolIsInHTTPFamily()) |
182 return; | 186 return; |
183 | 187 |
184 if (web_context_->IsDataSaverEnabled()) | 188 if (web_context_->IsDataSaverEnabled()) |
185 request.SetHTTPHeaderField("Save-Data", "on"); | 189 request.SetHTTPHeaderField("Save-Data", "on"); |
186 } | 190 } |
187 | 191 |
192 void WorkerFetchContext::PopulateResourceRequest( | |
193 const KURL& url, | |
194 Resource::Type type, | |
195 const ClientHintsPreferences& hints_preferences, | |
196 const FetchParameters::ResourceWidth& resource_width, | |
197 const ResourceLoaderOptions& options, | |
198 SecurityViolationReportingPolicy reporting_policy, | |
199 ResourceRequest& request) { | |
falken
2017/05/17 08:55:31
out_request
horo
2017/05/17 09:44:03
Done.
| |
200 SetFirstPartyCookieAndRequestorOrigin(request); | |
201 } | |
202 | |
203 void WorkerFetchContext::SetFirstPartyCookieAndRequestorOrigin( | |
204 ResourceRequest& request) { | |
205 if (request.FirstPartyForCookies().IsNull()) | |
206 request.SetFirstPartyForCookies(FirstPartyForCookies()); | |
207 } | |
208 | |
188 DEFINE_TRACE(WorkerFetchContext) { | 209 DEFINE_TRACE(WorkerFetchContext) { |
189 visitor->Trace(worker_global_scope_); | 210 visitor->Trace(worker_global_scope_); |
190 visitor->Trace(resource_fetcher_); | 211 visitor->Trace(resource_fetcher_); |
191 BaseFetchContext::Trace(visitor); | 212 BaseFetchContext::Trace(visitor); |
192 } | 213 } |
193 | 214 |
194 void ProvideWorkerFetchContextToWorker( | 215 void ProvideWorkerFetchContextToWorker( |
195 WorkerClients* clients, | 216 WorkerClients* clients, |
196 std::unique_ptr<WebWorkerFetchContext> web_context) { | 217 std::unique_ptr<WebWorkerFetchContext> web_context) { |
197 DCHECK(clients); | 218 DCHECK(clients); |
198 WorkerFetchContextHolder::ProvideTo( | 219 WorkerFetchContextHolder::ProvideTo( |
199 *clients, WorkerFetchContextHolder::SupplementName(), | 220 *clients, WorkerFetchContextHolder::SupplementName(), |
200 new WorkerFetchContextHolder(std::move(web_context))); | 221 new WorkerFetchContextHolder(std::move(web_context))); |
201 } | 222 } |
202 | 223 |
203 } // namespace blink | 224 } // namespace blink |
OLD | NEW |