Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Side by Side Diff: third_party/WebKit/Source/core/loader/WorkerFetchContext.cpp

Issue 2900613002: Support DevTools for off-main-thread-fetch (Closed)
Patch Set: incorporated kinuko's comment Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/loader/MixedContentChecker.h"
10 #include "core/probe/CoreProbes.h"
10 #include "core/timing/WorkerGlobalScopePerformance.h" 11 #include "core/timing/WorkerGlobalScopePerformance.h"
11 #include "core/workers/WorkerClients.h" 12 #include "core/workers/WorkerClients.h"
12 #include "core/workers/WorkerGlobalScope.h" 13 #include "core/workers/WorkerGlobalScope.h"
14 #include "platform/RuntimeEnabledFeatures.h"
13 #include "platform/Supplementable.h" 15 #include "platform/Supplementable.h"
14 #include "platform/WebTaskRunner.h" 16 #include "platform/WebTaskRunner.h"
15 #include "platform/exported/WrappedResourceRequest.h" 17 #include "platform/exported/WrappedResourceRequest.h"
16 #include "platform/loader/fetch/ResourceFetcher.h" 18 #include "platform/loader/fetch/ResourceFetcher.h"
17 #include "platform/scheduler/child/web_scheduler.h" 19 #include "platform/scheduler/child/web_scheduler.h"
20 #include "platform/weborigin/SecurityPolicy.h"
18 #include "public/platform/Platform.h" 21 #include "public/platform/Platform.h"
19 #include "public/platform/WebMixedContent.h" 22 #include "public/platform/WebMixedContent.h"
20 #include "public/platform/WebMixedContentContextType.h" 23 #include "public/platform/WebMixedContentContextType.h"
21 #include "public/platform/WebThread.h" 24 #include "public/platform/WebThread.h"
22 #include "public/platform/WebURLRequest.h" 25 #include "public/platform/WebURLRequest.h"
23 #include "public/platform/WebWorkerFetchContext.h" 26 #include "public/platform/WebWorkerFetchContext.h"
24 27
25 namespace blink { 28 namespace blink {
26 29
27 namespace { 30 namespace {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 SubresourceFilter* WorkerFetchContext::GetSubresourceFilter() const { 116 SubresourceFilter* WorkerFetchContext::GetSubresourceFilter() const {
114 // TODO(horo): Implement this. 117 // TODO(horo): Implement this.
115 return nullptr; 118 return nullptr;
116 } 119 }
117 120
118 SecurityContext* WorkerFetchContext::GetParentSecurityContext() const { 121 SecurityContext* WorkerFetchContext::GetParentSecurityContext() const {
119 // TODO(horo): Implement this. 122 // TODO(horo): Implement this.
120 return nullptr; 123 return nullptr;
121 } 124 }
122 125
123 bool WorkerFetchContext::ShouldBlockRequestByInspector(
124 const ResourceRequest& resource_request) const {
125 // TODO(horo): Implement this.
126 return false;
127 }
128
129 void WorkerFetchContext::DispatchDidBlockRequest( 126 void WorkerFetchContext::DispatchDidBlockRequest(
130 const ResourceRequest& resource_request, 127 const ResourceRequest& resource_request,
131 const FetchInitiatorInfo& fetch_initiator_info, 128 const FetchInitiatorInfo& fetch_initiator_info,
132 ResourceRequestBlockedReason blocked_reason) const { 129 ResourceRequestBlockedReason blocked_reason) const {
133 // TODO(horo): Implement this. 130 probe::didBlockRequest(worker_global_scope_, resource_request, nullptr,
131 fetch_initiator_info, blocked_reason);
134 } 132 }
135 133
136 void WorkerFetchContext::ReportLocalLoadFailed(const KURL&) const { 134 void WorkerFetchContext::ReportLocalLoadFailed(const KURL&) const {
137 // TODO(horo): Implement this. 135 // TODO(horo): Implement this.
138 } 136 }
139 137
140 bool WorkerFetchContext::ShouldBypassMainWorldCSP() const { 138 bool WorkerFetchContext::ShouldBypassMainWorldCSP() const {
141 // TODO(horo): Implement this. 139 // TODO(horo): Implement this.
142 return false; 140 return false;
143 } 141 }
(...skipping 23 matching lines...) Expand all
167 std::unique_ptr<WebURLLoader> WorkerFetchContext::CreateURLLoader() { 165 std::unique_ptr<WebURLLoader> WorkerFetchContext::CreateURLLoader() {
168 return web_context_->CreateURLLoader(); 166 return web_context_->CreateURLLoader();
169 } 167 }
170 168
171 bool WorkerFetchContext::IsControlledByServiceWorker() const { 169 bool WorkerFetchContext::IsControlledByServiceWorker() const {
172 return web_context_->IsControlledByServiceWorker(); 170 return web_context_->IsControlledByServiceWorker();
173 } 171 }
174 172
175 void WorkerFetchContext::PrepareRequest(ResourceRequest& request, 173 void WorkerFetchContext::PrepareRequest(ResourceRequest& request,
176 RedirectType) { 174 RedirectType) {
175 String user_agent = worker_global_scope_->UserAgent();
176 probe::applyUserAgentOverride(worker_global_scope_, &user_agent);
177 DCHECK(!user_agent.IsNull());
178 request.SetHTTPUserAgent(AtomicString(user_agent));
179
177 request.OverrideLoadingIPCType(WebURLRequest::LoadingIPCType::kMojo); 180 request.OverrideLoadingIPCType(WebURLRequest::LoadingIPCType::kMojo);
178 WrappedResourceRequest webreq(request); 181 WrappedResourceRequest webreq(request);
179 web_context_->WillSendRequest(webreq); 182 web_context_->WillSendRequest(webreq);
180 } 183 }
181 184
182 RefPtr<WebTaskRunner> WorkerFetchContext::LoadingTaskRunner() const { 185 RefPtr<WebTaskRunner> WorkerFetchContext::LoadingTaskRunner() const {
183 return loading_task_runner_; 186 return loading_task_runner_;
184 } 187 }
185 188
186 void WorkerFetchContext::AddAdditionalRequestHeaders(ResourceRequest& request, 189 void WorkerFetchContext::AddAdditionalRequestHeaders(ResourceRequest& request,
187 FetchResourceType type) { 190 FetchResourceType type) {
188 BaseFetchContext::AddAdditionalRequestHeaders(request, type); 191 BaseFetchContext::AddAdditionalRequestHeaders(request, type);
189 192
190 // The remaining modifications are only necessary for HTTP and HTTPS. 193 // The remaining modifications are only necessary for HTTP and HTTPS.
191 if (!request.Url().IsEmpty() && !request.Url().ProtocolIsInHTTPFamily()) 194 if (!request.Url().IsEmpty() && !request.Url().ProtocolIsInHTTPFamily())
192 return; 195 return;
193 196
194 if (web_context_->IsDataSaverEnabled()) 197 if (web_context_->IsDataSaverEnabled())
195 request.SetHTTPHeaderField("Save-Data", "on"); 198 request.SetHTTPHeaderField("Save-Data", "on");
196 } 199 }
197 200
201 void WorkerFetchContext::DispatchWillSendRequest(
202 unsigned long identifier,
203 ResourceRequest& request,
204 const ResourceResponse& redirect_response,
205 const FetchInitiatorInfo& initiator_info) {
206 probe::willSendRequest(worker_global_scope_, identifier, nullptr, request,
207 redirect_response, initiator_info);
208 }
209
198 void WorkerFetchContext::DispatchDidReceiveResponse( 210 void WorkerFetchContext::DispatchDidReceiveResponse(
199 unsigned long identifier, 211 unsigned long identifier,
200 const ResourceResponse& response, 212 const ResourceResponse& response,
201 WebURLRequest::FrameType frame_type, 213 WebURLRequest::FrameType frame_type,
202 WebURLRequest::RequestContext request_context, 214 WebURLRequest::RequestContext request_context,
203 Resource* resource, 215 Resource* resource,
204 ResourceResponseType) { 216 ResourceResponseType) {
205 if (response.HasMajorCertificateErrors()) { 217 if (response.HasMajorCertificateErrors()) {
206 WebMixedContentContextType context_type = 218 WebMixedContentContextType context_type =
207 WebMixedContent::ContextTypeFromRequestContext( 219 WebMixedContent::ContextTypeFromRequestContext(
208 request_context, false /* strictMixedContentCheckingForPlugin */); 220 request_context, false /* strictMixedContentCheckingForPlugin */);
209 if (context_type == WebMixedContentContextType::kBlockable) { 221 if (context_type == WebMixedContentContextType::kBlockable) {
210 web_context_->DidRunContentWithCertificateErrors(response.Url()); 222 web_context_->DidRunContentWithCertificateErrors(response.Url());
211 } else { 223 } else {
212 web_context_->DidDisplayContentWithCertificateErrors(response.Url()); 224 web_context_->DidDisplayContentWithCertificateErrors(response.Url());
213 } 225 }
214 } 226 }
227 probe::didReceiveResourceResponse(worker_global_scope_, identifier, nullptr,
228 response, resource);
229 }
230
231 void WorkerFetchContext::DispatchDidReceiveData(unsigned long identifier,
232 const char* data,
233 int data_length) {
234 probe::didReceiveData(worker_global_scope_, identifier, nullptr, data,
235 data_length);
236 }
237
238 void WorkerFetchContext::DispatchDidFinishLoading(unsigned long identifier,
239 double finish_time,
240 int64_t encoded_data_length,
241 int64_t decoded_body_length) {
242 probe::didFinishLoading(worker_global_scope_, identifier, nullptr,
243 finish_time, encoded_data_length,
244 decoded_body_length);
245 }
246
247 void WorkerFetchContext::DispatchDidFail(unsigned long identifier,
248 const ResourceError& error,
249 int64_t encoded_data_length,
250 bool is_internal_request) {
251 probe::didFailLoading(worker_global_scope_, identifier, error);
215 } 252 }
216 253
217 void WorkerFetchContext::AddResourceTiming(const ResourceTimingInfo& info) { 254 void WorkerFetchContext::AddResourceTiming(const ResourceTimingInfo& info) {
218 WorkerGlobalScopePerformance::performance(*worker_global_scope_) 255 WorkerGlobalScopePerformance::performance(*worker_global_scope_)
219 ->AddResourceTiming(info); 256 ->AddResourceTiming(info);
220 } 257 }
221 258
222 void WorkerFetchContext::PopulateResourceRequest( 259 void WorkerFetchContext::PopulateResourceRequest(
223 const KURL& url, 260 const KURL& url,
224 Resource::Type type, 261 Resource::Type type,
(...skipping 25 matching lines...) Expand all
250 void ProvideWorkerFetchContextToWorker( 287 void ProvideWorkerFetchContextToWorker(
251 WorkerClients* clients, 288 WorkerClients* clients,
252 std::unique_ptr<WebWorkerFetchContext> web_context) { 289 std::unique_ptr<WebWorkerFetchContext> web_context) {
253 DCHECK(clients); 290 DCHECK(clients);
254 WorkerFetchContextHolder::ProvideTo( 291 WorkerFetchContextHolder::ProvideTo(
255 *clients, WorkerFetchContextHolder::SupplementName(), 292 *clients, WorkerFetchContextHolder::SupplementName(),
256 new WorkerFetchContextHolder(std::move(web_context))); 293 new WorkerFetchContextHolder(std::move(web_context)));
257 } 294 }
258 295
259 } // namespace blink 296 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698