Add remaining Linux configs for MB.
[chromium-blink-merge.git] / content / child / web_url_loader_impl.cc
blobc09713f64895a7a807f14a60483cb4240bd9fba3
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/child/web_url_loader_impl.h"
7 #include <algorithm>
8 #include <string>
10 #include "base/bind.h"
11 #include "base/command_line.h"
12 #include "base/files/file_path.h"
13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/single_thread_task_runner.h"
16 #include "base/strings/string_util.h"
17 #include "base/time/time.h"
18 #include "components/mime_util/mime_util.h"
19 #include "content/child/child_thread_impl.h"
20 #include "content/child/ftp_directory_listing_response_delegate.h"
21 #include "content/child/multipart_response_delegate.h"
22 #include "content/child/request_extra_data.h"
23 #include "content/child/request_info.h"
24 #include "content/child/resource_dispatcher.h"
25 #include "content/child/shared_memory_data_consumer_handle.h"
26 #include "content/child/sync_load_response.h"
27 #include "content/child/web_url_request_util.h"
28 #include "content/child/weburlresponse_extradata_impl.h"
29 #include "content/common/resource_messages.h"
30 #include "content/common/resource_request_body.h"
31 #include "content/common/service_worker/service_worker_types.h"
32 #include "content/common/ssl_status_serialization.h"
33 #include "content/public/child/fixed_received_data.h"
34 #include "content/public/child/request_peer.h"
35 #include "content/public/common/content_switches.h"
36 #include "net/base/data_url.h"
37 #include "net/base/filename_util.h"
38 #include "net/base/net_errors.h"
39 #include "net/http/http_response_headers.h"
40 #include "net/http/http_util.h"
41 #include "net/ssl/ssl_cipher_suite_names.h"
42 #include "net/ssl/ssl_connection_status_flags.h"
43 #include "net/url_request/redirect_info.h"
44 #include "net/url_request/url_request_data_job.h"
45 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h"
46 #include "third_party/WebKit/public/platform/WebURL.h"
47 #include "third_party/WebKit/public/platform/WebURLError.h"
48 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h"
49 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
50 #include "third_party/WebKit/public/platform/WebURLRequest.h"
51 #include "third_party/WebKit/public/platform/WebURLResponse.h"
52 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
54 using base::Time;
55 using base::TimeTicks;
56 using blink::WebData;
57 using blink::WebHTTPBody;
58 using blink::WebHTTPHeaderVisitor;
59 using blink::WebHTTPLoadInfo;
60 using blink::WebReferrerPolicy;
61 using blink::WebSecurityPolicy;
62 using blink::WebString;
63 using blink::WebURL;
64 using blink::WebURLError;
65 using blink::WebURLLoadTiming;
66 using blink::WebURLLoader;
67 using blink::WebURLLoaderClient;
68 using blink::WebURLRequest;
69 using blink::WebURLResponse;
71 namespace content {
73 // Utilities ------------------------------------------------------------------
75 namespace {
77 using HeadersVector = ResourceDevToolsInfo::HeadersVector;
79 // Converts timing data from |load_timing| to the format used by WebKit.
80 void PopulateURLLoadTiming(const net::LoadTimingInfo& load_timing,
81 WebURLLoadTiming* url_timing) {
82 DCHECK(!load_timing.request_start.is_null());
84 const TimeTicks kNullTicks;
85 url_timing->initialize();
86 url_timing->setRequestTime(
87 (load_timing.request_start - kNullTicks).InSecondsF());
88 url_timing->setProxyStart(
89 (load_timing.proxy_resolve_start - kNullTicks).InSecondsF());
90 url_timing->setProxyEnd(
91 (load_timing.proxy_resolve_end - kNullTicks).InSecondsF());
92 url_timing->setDNSStart(
93 (load_timing.connect_timing.dns_start - kNullTicks).InSecondsF());
94 url_timing->setDNSEnd(
95 (load_timing.connect_timing.dns_end - kNullTicks).InSecondsF());
96 url_timing->setConnectStart(
97 (load_timing.connect_timing.connect_start - kNullTicks).InSecondsF());
98 url_timing->setConnectEnd(
99 (load_timing.connect_timing.connect_end - kNullTicks).InSecondsF());
100 url_timing->setSSLStart(
101 (load_timing.connect_timing.ssl_start - kNullTicks).InSecondsF());
102 url_timing->setSSLEnd(
103 (load_timing.connect_timing.ssl_end - kNullTicks).InSecondsF());
104 url_timing->setSendStart(
105 (load_timing.send_start - kNullTicks).InSecondsF());
106 url_timing->setSendEnd(
107 (load_timing.send_end - kNullTicks).InSecondsF());
108 url_timing->setReceiveHeadersEnd(
109 (load_timing.receive_headers_end - kNullTicks).InSecondsF());
112 net::RequestPriority ConvertWebKitPriorityToNetPriority(
113 const WebURLRequest::Priority& priority) {
114 switch (priority) {
115 case WebURLRequest::PriorityVeryHigh:
116 return net::HIGHEST;
118 case WebURLRequest::PriorityHigh:
119 return net::MEDIUM;
121 case WebURLRequest::PriorityMedium:
122 return net::LOW;
124 case WebURLRequest::PriorityLow:
125 return net::LOWEST;
127 case WebURLRequest::PriorityVeryLow:
128 return net::IDLE;
130 case WebURLRequest::PriorityUnresolved:
131 default:
132 NOTREACHED();
133 return net::LOW;
137 // Extracts info from a data scheme URL |url| into |info| and |data|. Returns
138 // net::OK if successful. Returns a net error code otherwise.
139 int GetInfoFromDataURL(const GURL& url,
140 ResourceResponseInfo* info,
141 std::string* data) {
142 // Assure same time for all time fields of data: URLs.
143 Time now = Time::Now();
144 info->load_timing.request_start = TimeTicks::Now();
145 info->load_timing.request_start_time = now;
146 info->request_time = now;
147 info->response_time = now;
149 std::string mime_type;
150 std::string charset;
151 scoped_refptr<net::HttpResponseHeaders> headers(
152 new net::HttpResponseHeaders(std::string()));
153 int result = net::URLRequestDataJob::BuildResponse(
154 url, &mime_type, &charset, data, headers.get());
155 if (result != net::OK)
156 return result;
158 info->headers = headers;
159 info->mime_type.swap(mime_type);
160 info->charset.swap(charset);
161 info->security_info.clear();
162 info->content_length = data->length();
163 info->encoded_data_length = 0;
165 return net::OK;
168 #define STATIC_ASSERT_MATCHING_ENUMS(content_name, blink_name) \
169 static_assert( \
170 static_cast<int>(content_name) == static_cast<int>(blink_name), \
171 "mismatching enums: " #content_name)
173 STATIC_ASSERT_MATCHING_ENUMS(FETCH_REQUEST_MODE_SAME_ORIGIN,
174 WebURLRequest::FetchRequestModeSameOrigin);
175 STATIC_ASSERT_MATCHING_ENUMS(FETCH_REQUEST_MODE_NO_CORS,
176 WebURLRequest::FetchRequestModeNoCORS);
177 STATIC_ASSERT_MATCHING_ENUMS(FETCH_REQUEST_MODE_CORS,
178 WebURLRequest::FetchRequestModeCORS);
179 STATIC_ASSERT_MATCHING_ENUMS(
180 FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT,
181 WebURLRequest::FetchRequestModeCORSWithForcedPreflight);
183 FetchRequestMode GetFetchRequestMode(const WebURLRequest& request) {
184 return static_cast<FetchRequestMode>(request.fetchRequestMode());
187 STATIC_ASSERT_MATCHING_ENUMS(FETCH_CREDENTIALS_MODE_OMIT,
188 WebURLRequest::FetchCredentialsModeOmit);
189 STATIC_ASSERT_MATCHING_ENUMS(FETCH_CREDENTIALS_MODE_SAME_ORIGIN,
190 WebURLRequest::FetchCredentialsModeSameOrigin);
191 STATIC_ASSERT_MATCHING_ENUMS(FETCH_CREDENTIALS_MODE_INCLUDE,
192 WebURLRequest::FetchCredentialsModeInclude);
194 FetchCredentialsMode GetFetchCredentialsMode(const WebURLRequest& request) {
195 return static_cast<FetchCredentialsMode>(request.fetchCredentialsMode());
198 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_FRAME_TYPE_AUXILIARY,
199 WebURLRequest::FrameTypeAuxiliary);
200 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_FRAME_TYPE_NESTED,
201 WebURLRequest::FrameTypeNested);
202 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_FRAME_TYPE_NONE,
203 WebURLRequest::FrameTypeNone);
204 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL,
205 WebURLRequest::FrameTypeTopLevel);
207 RequestContextFrameType GetRequestContextFrameType(
208 const WebURLRequest& request) {
209 return static_cast<RequestContextFrameType>(request.frameType());
212 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_UNSPECIFIED,
213 WebURLRequest::RequestContextUnspecified);
214 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_AUDIO,
215 WebURLRequest::RequestContextAudio);
216 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_BEACON,
217 WebURLRequest::RequestContextBeacon);
218 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_CSP_REPORT,
219 WebURLRequest::RequestContextCSPReport);
220 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_DOWNLOAD,
221 WebURLRequest::RequestContextDownload);
222 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_EMBED,
223 WebURLRequest::RequestContextEmbed);
224 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_EVENT_SOURCE,
225 WebURLRequest::RequestContextEventSource);
226 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_FAVICON,
227 WebURLRequest::RequestContextFavicon);
228 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_FETCH,
229 WebURLRequest::RequestContextFetch);
230 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_FONT,
231 WebURLRequest::RequestContextFont);
232 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_FORM,
233 WebURLRequest::RequestContextForm);
234 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_FRAME,
235 WebURLRequest::RequestContextFrame);
236 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_HYPERLINK,
237 WebURLRequest::RequestContextHyperlink);
238 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_IFRAME,
239 WebURLRequest::RequestContextIframe);
240 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_IMAGE,
241 WebURLRequest::RequestContextImage);
242 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_IMAGE_SET,
243 WebURLRequest::RequestContextImageSet);
244 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_IMPORT,
245 WebURLRequest::RequestContextImport);
246 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_INTERNAL,
247 WebURLRequest::RequestContextInternal);
248 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_LOCATION,
249 WebURLRequest::RequestContextLocation);
250 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_MANIFEST,
251 WebURLRequest::RequestContextManifest);
252 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_OBJECT,
253 WebURLRequest::RequestContextObject);
254 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_PING,
255 WebURLRequest::RequestContextPing);
256 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_PLUGIN,
257 WebURLRequest::RequestContextPlugin);
258 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_PREFETCH,
259 WebURLRequest::RequestContextPrefetch);
260 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_SCRIPT,
261 WebURLRequest::RequestContextScript);
262 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_SERVICE_WORKER,
263 WebURLRequest::RequestContextServiceWorker);
264 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_SHARED_WORKER,
265 WebURLRequest::RequestContextSharedWorker);
266 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_SUBRESOURCE,
267 WebURLRequest::RequestContextSubresource);
268 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_STYLE,
269 WebURLRequest::RequestContextStyle);
270 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_TRACK,
271 WebURLRequest::RequestContextTrack);
272 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_VIDEO,
273 WebURLRequest::RequestContextVideo);
274 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_WORKER,
275 WebURLRequest::RequestContextWorker);
276 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_XML_HTTP_REQUEST,
277 WebURLRequest::RequestContextXMLHttpRequest);
278 STATIC_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_XSLT,
279 WebURLRequest::RequestContextXSLT);
281 RequestContextType GetRequestContextType(const WebURLRequest& request) {
282 return static_cast<RequestContextType>(request.requestContext());
285 void SetSecurityStyleAndDetails(const GURL& url,
286 const std::string& security_info,
287 WebURLResponse* response,
288 bool report_security_info) {
289 if (!report_security_info) {
290 response->setSecurityStyle(WebURLResponse::SecurityStyleUnknown);
291 return;
293 if (!url.SchemeIsCryptographic()) {
294 response->setSecurityStyle(WebURLResponse::SecurityStyleUnauthenticated);
295 return;
298 // There are cases where an HTTPS request can come in without security
299 // info attached (such as a redirect response).
300 if (security_info.empty()) {
301 response->setSecurityStyle(WebURLResponse::SecurityStyleUnknown);
302 return;
305 SSLStatus ssl_status;
306 if (!DeserializeSecurityInfo(security_info, &ssl_status)) {
307 response->setSecurityStyle(WebURLResponse::SecurityStyleUnknown);
308 DLOG(ERROR)
309 << "DeserializeSecurityInfo() failed for an authenticated request.";
310 return;
313 int ssl_version =
314 net::SSLConnectionStatusToVersion(ssl_status.connection_status);
315 const char* protocol;
316 net::SSLVersionToString(&protocol, ssl_version);
318 const char* key_exchange;
319 const char* cipher;
320 const char* mac;
321 bool is_aead;
322 uint16_t cipher_suite =
323 net::SSLConnectionStatusToCipherSuite(ssl_status.connection_status);
324 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
325 cipher_suite);
326 if (mac == NULL) {
327 DCHECK(is_aead);
328 mac = "";
331 blink::WebURLResponse::SecurityStyle securityStyle =
332 WebURLResponse::SecurityStyleUnknown;
333 switch (ssl_status.security_style) {
334 case SECURITY_STYLE_UNKNOWN:
335 securityStyle = WebURLResponse::SecurityStyleUnknown;
336 break;
337 case SECURITY_STYLE_UNAUTHENTICATED:
338 securityStyle = WebURLResponse::SecurityStyleUnauthenticated;
339 break;
340 case SECURITY_STYLE_AUTHENTICATION_BROKEN:
341 securityStyle = WebURLResponse::SecurityStyleAuthenticationBroken;
342 break;
343 case SECURITY_STYLE_WARNING:
344 securityStyle = WebURLResponse::SecurityStyleWarning;
345 break;
346 case SECURITY_STYLE_AUTHENTICATED:
347 securityStyle = WebURLResponse::SecurityStyleAuthenticated;
348 break;
351 response->setSecurityStyle(securityStyle);
353 blink::WebString protocol_string = blink::WebString::fromUTF8(protocol);
354 blink::WebString cipher_string = blink::WebString::fromUTF8(cipher);
355 blink::WebString key_exchange_string =
356 blink::WebString::fromUTF8(key_exchange);
357 blink::WebString mac_string = blink::WebString::fromUTF8(mac);
358 response->setSecurityDetails(protocol_string, cipher_string,
359 key_exchange_string, mac_string,
360 ssl_status.cert_id);
363 } // namespace
365 // WebURLLoaderImpl::Context --------------------------------------------------
367 // This inner class exists since the WebURLLoader may be deleted while inside a
368 // call to WebURLLoaderClient. Refcounting is to keep the context from being
369 // deleted if it may have work to do after calling into the client.
370 class WebURLLoaderImpl::Context : public base::RefCounted<Context>,
371 public RequestPeer {
372 public:
373 Context(WebURLLoaderImpl* loader,
374 ResourceDispatcher* resource_dispatcher,
375 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
377 WebURLLoaderClient* client() const { return client_; }
378 void set_client(WebURLLoaderClient* client) { client_ = client; }
380 void Cancel();
381 void SetDefersLoading(bool value);
382 void DidChangePriority(WebURLRequest::Priority new_priority,
383 int intra_priority_value);
384 bool AttachThreadedDataReceiver(
385 blink::WebThreadedDataReceiver* threaded_data_receiver);
386 void Start(const WebURLRequest& request,
387 SyncLoadResponse* sync_load_response);
389 // RequestPeer methods:
390 void OnUploadProgress(uint64 position, uint64 size) override;
391 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info,
392 const ResourceResponseInfo& info) override;
393 void OnReceivedResponse(const ResourceResponseInfo& info) override;
394 void OnDownloadedData(int len, int encoded_data_length) override;
395 void OnReceivedData(scoped_ptr<ReceivedData> data) override;
396 void OnReceivedCachedMetadata(const char* data, int len) override;
397 void OnCompletedRequest(int error_code,
398 bool was_ignored_by_handler,
399 bool stale_copy_in_cache,
400 const std::string& security_info,
401 const base::TimeTicks& completion_time,
402 int64 total_transfer_size) override;
403 void OnReceivedCompletedResponse(const ResourceResponseInfo& info,
404 scoped_ptr<ReceivedData> data,
405 int error_code,
406 bool was_ignored_by_handler,
407 bool stale_copy_in_cache,
408 const std::string& security_info,
409 const base::TimeTicks& completion_time,
410 int64 total_transfer_size) override;
412 private:
413 friend class base::RefCounted<Context>;
414 ~Context() override;
416 // Called when the body data stream is detached from the reader side.
417 void CancelBodyStreaming();
418 // We can optimize the handling of data URLs in most cases.
419 bool CanHandleDataURLRequestLocally() const;
420 void HandleDataURL();
422 WebURLLoaderImpl* loader_;
423 WebURLRequest request_;
424 WebURLLoaderClient* client_;
425 ResourceDispatcher* resource_dispatcher_;
426 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
427 WebReferrerPolicy referrer_policy_;
428 scoped_ptr<FtpDirectoryListingResponseDelegate> ftp_listing_delegate_;
429 scoped_ptr<MultipartResponseDelegate> multipart_delegate_;
430 scoped_ptr<StreamOverrideParameters> stream_override_;
431 scoped_ptr<SharedMemoryDataConsumerHandle::Writer> body_stream_writer_;
432 enum DeferState {NOT_DEFERRING, SHOULD_DEFER, DEFERRED_DATA};
433 DeferState defers_loading_;
434 int request_id_;
437 WebURLLoaderImpl::Context::Context(
438 WebURLLoaderImpl* loader,
439 ResourceDispatcher* resource_dispatcher,
440 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
441 : loader_(loader),
442 client_(NULL),
443 resource_dispatcher_(resource_dispatcher),
444 task_runner_(task_runner),
445 referrer_policy_(blink::WebReferrerPolicyDefault),
446 defers_loading_(NOT_DEFERRING),
447 request_id_(-1) {
450 void WebURLLoaderImpl::Context::Cancel() {
451 if (resource_dispatcher_ && // NULL in unittest.
452 request_id_ != -1) {
453 resource_dispatcher_->Cancel(request_id_);
454 request_id_ = -1;
457 if (body_stream_writer_)
458 body_stream_writer_->Fail();
460 // Ensure that we do not notify the multipart delegate anymore as it has
461 // its own pointer to the client.
462 if (multipart_delegate_)
463 multipart_delegate_->Cancel();
464 // Ditto for the ftp delegate.
465 if (ftp_listing_delegate_)
466 ftp_listing_delegate_->Cancel();
468 // Do not make any further calls to the client.
469 client_ = NULL;
470 loader_ = NULL;
473 void WebURLLoaderImpl::Context::SetDefersLoading(bool value) {
474 if (request_id_ != -1)
475 resource_dispatcher_->SetDefersLoading(request_id_, value);
476 if (value && defers_loading_ == NOT_DEFERRING) {
477 defers_loading_ = SHOULD_DEFER;
478 } else if (!value && defers_loading_ != NOT_DEFERRING) {
479 if (defers_loading_ == DEFERRED_DATA) {
480 task_runner_->PostTask(FROM_HERE,
481 base::Bind(&Context::HandleDataURL, this));
483 defers_loading_ = NOT_DEFERRING;
487 void WebURLLoaderImpl::Context::DidChangePriority(
488 WebURLRequest::Priority new_priority, int intra_priority_value) {
489 if (request_id_ != -1) {
490 resource_dispatcher_->DidChangePriority(
491 request_id_,
492 ConvertWebKitPriorityToNetPriority(new_priority),
493 intra_priority_value);
497 bool WebURLLoaderImpl::Context::AttachThreadedDataReceiver(
498 blink::WebThreadedDataReceiver* threaded_data_receiver) {
499 if (request_id_ != -1) {
500 return resource_dispatcher_->AttachThreadedDataReceiver(
501 request_id_, threaded_data_receiver);
504 return false;
507 void WebURLLoaderImpl::Context::Start(const WebURLRequest& request,
508 SyncLoadResponse* sync_load_response) {
509 DCHECK(request_id_ == -1);
510 request_ = request; // Save the request.
511 if (request.extraData()) {
512 RequestExtraData* extra_data =
513 static_cast<RequestExtraData*>(request.extraData());
514 stream_override_ = extra_data->TakeStreamOverrideOwnership();
517 GURL url = request.url();
519 // PlzNavigate: during navigation, the renderer should request a stream which
520 // contains the body of the response. The request has already been made by the
521 // browser.
522 if (stream_override_.get()) {
523 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
524 switches::kEnableBrowserSideNavigation));
525 DCHECK(!sync_load_response);
526 DCHECK_NE(WebURLRequest::FrameTypeNone, request.frameType());
527 DCHECK_EQ("GET", request.httpMethod().latin1());
528 url = stream_override_->stream_url;
531 if (CanHandleDataURLRequestLocally()) {
532 if (sync_load_response) {
533 // This is a sync load. Do the work now.
534 sync_load_response->url = url;
535 sync_load_response->error_code =
536 GetInfoFromDataURL(sync_load_response->url, sync_load_response,
537 &sync_load_response->data);
538 } else {
539 task_runner_->PostTask(FROM_HERE,
540 base::Bind(&Context::HandleDataURL, this));
542 return;
545 // PlzNavigate: outside of tests, the only navigation requests going through
546 // the WebURLLoader are the ones created by CommitNavigation. Several browser
547 // tests load HTML directly through a data url which will be handled by the
548 // block above.
549 DCHECK_IMPLIES(base::CommandLine::ForCurrentProcess()->HasSwitch(
550 switches::kEnableBrowserSideNavigation),
551 stream_override_.get() ||
552 request.frameType() == WebURLRequest::FrameTypeNone);
554 GURL referrer_url(
555 request.httpHeaderField(WebString::fromUTF8("Referer")).latin1());
556 const std::string& method = request.httpMethod().latin1();
558 // TODO(brettw) this should take parameter encoding into account when
559 // creating the GURLs.
561 // TODO(horo): Check credentials flag is unset when credentials mode is omit.
562 // Check credentials flag is set when credentials mode is include.
564 RequestInfo request_info;
565 request_info.method = method;
566 request_info.url = url;
567 request_info.first_party_for_cookies = request.firstPartyForCookies();
568 referrer_policy_ = request.referrerPolicy();
569 request_info.referrer = Referrer(referrer_url, referrer_policy_);
570 request_info.headers = GetWebURLRequestHeaders(request);
571 request_info.load_flags = GetLoadFlagsForWebURLRequest(request);
572 request_info.enable_load_timing = true;
573 request_info.enable_upload_progress = request.reportUploadProgress();
574 if (request.requestContext() == WebURLRequest::RequestContextXMLHttpRequest &&
575 (url.has_username() || url.has_password())) {
576 request_info.do_not_prompt_for_login = true;
578 // requestor_pid only needs to be non-zero if the request originates outside
579 // the render process, so we can use requestorProcessID even for requests
580 // from in-process plugins.
581 request_info.requestor_pid = request.requestorProcessID();
582 request_info.request_type = WebURLRequestToResourceType(request);
583 request_info.priority =
584 ConvertWebKitPriorityToNetPriority(request.priority());
585 request_info.appcache_host_id = request.appCacheHostID();
586 request_info.routing_id = request.requestorID();
587 request_info.download_to_file = request.downloadToFile();
588 request_info.has_user_gesture = request.hasUserGesture();
589 request_info.skip_service_worker = request.skipServiceWorker();
590 request_info.should_reset_appcache = request.shouldResetAppCache();
591 request_info.fetch_request_mode = GetFetchRequestMode(request);
592 request_info.fetch_credentials_mode = GetFetchCredentialsMode(request);
593 request_info.fetch_request_context_type = GetRequestContextType(request);
594 request_info.fetch_frame_type = GetRequestContextFrameType(request);
595 request_info.extra_data = request.extraData();
597 scoped_refptr<ResourceRequestBody> request_body =
598 GetRequestBodyForWebURLRequest(request).get();
600 if (sync_load_response) {
601 resource_dispatcher_->StartSync(
602 request_info, request_body.get(), sync_load_response);
603 return;
606 request_id_ = resource_dispatcher_->StartAsync(
607 request_info, request_body.get(), this);
610 void WebURLLoaderImpl::Context::OnUploadProgress(uint64 position, uint64 size) {
611 if (client_)
612 client_->didSendData(loader_, position, size);
615 bool WebURLLoaderImpl::Context::OnReceivedRedirect(
616 const net::RedirectInfo& redirect_info,
617 const ResourceResponseInfo& info) {
618 if (!client_)
619 return false;
621 WebURLResponse response;
622 response.initialize();
623 PopulateURLResponse(request_.url(), info, &response,
624 request_.reportRawHeaders());
626 // TODO(darin): We lack sufficient information to construct the actual
627 // request that resulted from the redirect.
628 WebURLRequest new_request(redirect_info.new_url);
629 new_request.setFirstPartyForCookies(
630 redirect_info.new_first_party_for_cookies);
631 new_request.setDownloadToFile(request_.downloadToFile());
632 new_request.setUseStreamOnResponse(request_.useStreamOnResponse());
633 new_request.setRequestContext(request_.requestContext());
634 new_request.setFrameType(request_.frameType());
635 new_request.setSkipServiceWorker(!info.was_fetched_via_service_worker);
636 new_request.setShouldResetAppCache(request_.shouldResetAppCache());
637 new_request.setFetchRequestMode(request_.fetchRequestMode());
638 new_request.setFetchCredentialsMode(request_.fetchCredentialsMode());
640 new_request.setHTTPReferrer(WebString::fromUTF8(redirect_info.new_referrer),
641 referrer_policy_);
643 std::string old_method = request_.httpMethod().utf8();
644 new_request.setHTTPMethod(WebString::fromUTF8(redirect_info.new_method));
645 if (redirect_info.new_method == old_method)
646 new_request.setHTTPBody(request_.httpBody());
648 // Protect from deletion during call to willSendRequest.
649 scoped_refptr<Context> protect(this);
651 client_->willSendRequest(loader_, new_request, response);
652 request_ = new_request;
654 // Only follow the redirect if WebKit left the URL unmodified.
655 if (redirect_info.new_url == GURL(new_request.url())) {
656 // First-party cookie logic moved from DocumentLoader in Blink to
657 // net::URLRequest in the browser. Assert that Blink didn't try to change it
658 // to something else.
659 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(),
660 request_.firstPartyForCookies().string().utf8());
661 return true;
664 // We assume that WebKit only changes the URL to suppress a redirect, and we
665 // assume that it does so by setting it to be invalid.
666 DCHECK(!new_request.url().isValid());
667 return false;
670 void WebURLLoaderImpl::Context::OnReceivedResponse(
671 const ResourceResponseInfo& initial_info) {
672 if (!client_)
673 return;
675 ResourceResponseInfo info = initial_info;
677 // PlzNavigate: during navigations, the ResourceResponse has already been
678 // received on the browser side, and has been passed down to the renderer.
679 if (stream_override_.get()) {
680 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
681 switches::kEnableBrowserSideNavigation));
682 info = stream_override_->response;
685 WebURLResponse response;
686 response.initialize();
687 PopulateURLResponse(request_.url(), info, &response,
688 request_.reportRawHeaders());
690 bool show_raw_listing = (GURL(request_.url()).query() == "raw");
692 if (info.mime_type == "text/vnd.chromium.ftp-dir") {
693 if (show_raw_listing) {
694 // Set the MIME type to plain text to prevent any active content.
695 response.setMIMEType("text/plain");
696 } else {
697 // We're going to produce a parsed listing in HTML.
698 response.setMIMEType("text/html");
702 // Prevent |this| from being destroyed if the client destroys the loader,
703 // ether in didReceiveResponse, or when the multipart/ftp delegate calls into
704 // it.
705 scoped_refptr<Context> protect(this);
707 if (request_.useStreamOnResponse()) {
708 SharedMemoryDataConsumerHandle::BackpressureMode mode =
709 SharedMemoryDataConsumerHandle::kDoNotApplyBackpressure;
710 if (info.headers &&
711 info.headers->HasHeaderValue("Cache-Control", "no-store")) {
712 mode = SharedMemoryDataConsumerHandle::kApplyBackpressure;
715 auto read_handle = make_scoped_ptr(new SharedMemoryDataConsumerHandle(
716 mode, base::Bind(&Context::CancelBodyStreaming, this),
717 &body_stream_writer_));
719 // Here |body_stream_writer_| has an indirect reference to |this| and that
720 // creates a reference cycle, but it is not a problem because the cycle
721 // will break if one of the following happens:
722 // 1) The body data transfer is done (with or without an error).
723 // 2) |read_handle| (and its reader) is detached.
725 // The client takes |read_handle|'s ownership.
726 client_->didReceiveResponse(loader_, response, read_handle.release());
727 // TODO(yhirano): Support ftp listening and multipart
728 return;
729 } else {
730 client_->didReceiveResponse(loader_, response);
733 // We may have been cancelled after didReceiveResponse, which would leave us
734 // without a client and therefore without much need to do further handling.
735 if (!client_)
736 return;
738 DCHECK(!ftp_listing_delegate_.get());
739 DCHECK(!multipart_delegate_.get());
740 if (info.headers.get() && info.mime_type == "multipart/x-mixed-replace") {
741 std::string content_type;
742 info.headers->EnumerateHeader(NULL, "content-type", &content_type);
744 std::string mime_type;
745 std::string charset;
746 bool had_charset = false;
747 std::string boundary;
748 net::HttpUtil::ParseContentType(content_type, &mime_type, &charset,
749 &had_charset, &boundary);
750 base::TrimString(boundary, " \"", &boundary);
752 // If there's no boundary, just handle the request normally. In the gecko
753 // code, nsMultiMixedConv::OnStartRequest throws an exception.
754 if (!boundary.empty()) {
755 multipart_delegate_.reset(
756 new MultipartResponseDelegate(client_, loader_, response, boundary));
758 } else if (info.mime_type == "text/vnd.chromium.ftp-dir" &&
759 !show_raw_listing) {
760 ftp_listing_delegate_.reset(
761 new FtpDirectoryListingResponseDelegate(client_, loader_, response));
765 void WebURLLoaderImpl::Context::OnDownloadedData(int len,
766 int encoded_data_length) {
767 if (client_)
768 client_->didDownloadData(loader_, len, encoded_data_length);
771 void WebURLLoaderImpl::Context::OnReceivedData(scoped_ptr<ReceivedData> data) {
772 const char* payload = data->payload();
773 int data_length = data->length();
774 int encoded_data_length = data->encoded_length();
775 if (!client_)
776 return;
778 if (ftp_listing_delegate_) {
779 // The FTP listing delegate will make the appropriate calls to
780 // client_->didReceiveData and client_->didReceiveResponse. Since the
781 // delegate may want to do work after sending data to the delegate, keep
782 // |this| and the delegate alive until it's finished handling the data.
783 scoped_refptr<Context> protect(this);
784 ftp_listing_delegate_->OnReceivedData(payload, data_length);
785 } else if (multipart_delegate_) {
786 // The multipart delegate will make the appropriate calls to
787 // client_->didReceiveData and client_->didReceiveResponse. Since the
788 // delegate may want to do work after sending data to the delegate, keep
789 // |this| and the delegate alive until it's finished handling the data.
790 scoped_refptr<Context> protect(this);
791 multipart_delegate_->OnReceivedData(payload, data_length,
792 encoded_data_length);
793 } else {
794 scoped_refptr<Context> protect(this);
795 // We dispatch the data even when |useStreamOnResponse()| is set, in order
796 // to make Devtools work.
797 client_->didReceiveData(loader_, payload, data_length, encoded_data_length);
799 if (request_.useStreamOnResponse()) {
800 // We don't support ftp_listening_delegate_ and multipart_delegate_ for
801 // now.
802 // TODO(yhirano): Support ftp listening and multipart.
803 body_stream_writer_->AddData(data.Pass());
808 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata(
809 const char* data, int len) {
810 if (client_)
811 client_->didReceiveCachedMetadata(loader_, data, len);
814 void WebURLLoaderImpl::Context::OnCompletedRequest(
815 int error_code,
816 bool was_ignored_by_handler,
817 bool stale_copy_in_cache,
818 const std::string& security_info,
819 const base::TimeTicks& completion_time,
820 int64 total_transfer_size) {
821 // The WebURLLoaderImpl may be deleted in any of the calls to the client or
822 // the delegates below (As they also may call in to the client). Keep |this|
823 // alive in that case, to avoid a crash. If that happens, the request will be
824 // cancelled and |client_| will be set to NULL.
825 scoped_refptr<Context> protect(this);
827 if (ftp_listing_delegate_) {
828 ftp_listing_delegate_->OnCompletedRequest();
829 ftp_listing_delegate_.reset(NULL);
830 } else if (multipart_delegate_) {
831 multipart_delegate_->OnCompletedRequest();
832 multipart_delegate_.reset(NULL);
835 if (body_stream_writer_ && error_code != net::OK)
836 body_stream_writer_->Fail();
837 body_stream_writer_.reset();
839 if (client_) {
840 if (error_code != net::OK) {
841 client_->didFail(
842 loader_,
843 CreateWebURLError(request_.url(), stale_copy_in_cache, error_code,
844 was_ignored_by_handler));
845 } else {
846 client_->didFinishLoading(loader_,
847 (completion_time - TimeTicks()).InSecondsF(),
848 total_transfer_size);
853 void WebURLLoaderImpl::Context::OnReceivedCompletedResponse(
854 const ResourceResponseInfo& info,
855 scoped_ptr<ReceivedData> data,
856 int error_code,
857 bool was_ignored_by_handler,
858 bool stale_copy_in_cache,
859 const std::string& security_info,
860 const base::TimeTicks& completion_time,
861 int64 total_transfer_size) {
862 scoped_refptr<Context> protect(this);
864 OnReceivedResponse(info);
865 if (data)
866 OnReceivedData(data.Pass());
867 OnCompletedRequest(error_code, was_ignored_by_handler, stale_copy_in_cache,
868 security_info, completion_time, total_transfer_size);
871 WebURLLoaderImpl::Context::~Context() {
872 if (request_id_ >= 0) {
873 resource_dispatcher_->RemovePendingRequest(request_id_);
877 void WebURLLoaderImpl::Context::CancelBodyStreaming() {
878 scoped_refptr<Context> protect(this);
880 // Notify renderer clients that the request is canceled.
881 if (ftp_listing_delegate_) {
882 ftp_listing_delegate_->OnCompletedRequest();
883 ftp_listing_delegate_.reset(NULL);
884 } else if (multipart_delegate_) {
885 multipart_delegate_->OnCompletedRequest();
886 multipart_delegate_.reset(NULL);
889 if (body_stream_writer_) {
890 body_stream_writer_->Fail();
891 body_stream_writer_.reset();
893 if (client_) {
894 // TODO(yhirano): Set |stale_copy_in_cache| appropriately if possible.
895 client_->didFail(
896 loader_, CreateWebURLError(request_.url(), false, net::ERR_ABORTED));
899 // Notify the browser process that the request is canceled.
900 Cancel();
903 bool WebURLLoaderImpl::Context::CanHandleDataURLRequestLocally() const {
904 GURL url = request_.url();
905 if (!url.SchemeIs(url::kDataScheme))
906 return false;
908 // The fast paths for data URL, Start() and HandleDataURL(), don't support
909 // the downloadToFile option.
910 if (request_.downloadToFile())
911 return false;
913 // Data url requests from object tags may need to be intercepted as streams
914 // and so need to be sent to the browser.
915 if (request_.requestContext() == WebURLRequest::RequestContextObject)
916 return false;
918 // Optimize for the case where we can handle a data URL locally. We must
919 // skip this for data URLs targetted at frames since those could trigger a
920 // download.
922 // NOTE: We special case MIME types we can render both for performance
923 // reasons as well as to support unit tests.
925 #if defined(OS_ANDROID)
926 // For compatibility reasons on Android we need to expose top-level data://
927 // to the browser.
928 if (request_.frameType() == WebURLRequest::FrameTypeTopLevel)
929 return false;
930 #endif
932 if (request_.frameType() != WebURLRequest::FrameTypeTopLevel &&
933 request_.frameType() != WebURLRequest::FrameTypeNested)
934 return true;
936 std::string mime_type, unused_charset;
937 if (net::DataURL::Parse(request_.url(), &mime_type, &unused_charset, NULL) &&
938 mime_util::IsSupportedMimeType(mime_type))
939 return true;
941 return false;
944 void WebURLLoaderImpl::Context::HandleDataURL() {
945 DCHECK_NE(defers_loading_, DEFERRED_DATA);
946 if (defers_loading_ == SHOULD_DEFER) {
947 defers_loading_ = DEFERRED_DATA;
948 return;
951 ResourceResponseInfo info;
952 std::string data;
954 int error_code = GetInfoFromDataURL(request_.url(), &info, &data);
956 if (error_code == net::OK) {
957 OnReceivedResponse(info);
958 if (!data.empty())
959 OnReceivedData(
960 make_scoped_ptr(new FixedReceivedData(data.data(), data.size(), 0)));
963 OnCompletedRequest(error_code, false, false, info.security_info,
964 base::TimeTicks::Now(), 0);
967 // WebURLLoaderImpl -----------------------------------------------------------
969 WebURLLoaderImpl::WebURLLoaderImpl(
970 ResourceDispatcher* resource_dispatcher,
971 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
972 : context_(new Context(this, resource_dispatcher, task_runner)) {
975 WebURLLoaderImpl::~WebURLLoaderImpl() {
976 cancel();
979 void WebURLLoaderImpl::PopulateURLResponse(const GURL& url,
980 const ResourceResponseInfo& info,
981 WebURLResponse* response,
982 bool report_security_info) {
983 response->setURL(url);
984 response->setResponseTime(info.response_time.ToInternalValue());
985 response->setMIMEType(WebString::fromUTF8(info.mime_type));
986 response->setTextEncodingName(WebString::fromUTF8(info.charset));
987 response->setExpectedContentLength(info.content_length);
988 response->setSecurityInfo(info.security_info);
989 response->setAppCacheID(info.appcache_id);
990 response->setAppCacheManifestURL(info.appcache_manifest_url);
991 response->setWasCached(!info.load_timing.request_start_time.is_null() &&
992 info.response_time < info.load_timing.request_start_time);
993 response->setRemoteIPAddress(
994 WebString::fromUTF8(info.socket_address.host()));
995 response->setRemotePort(info.socket_address.port());
996 response->setConnectionID(info.load_timing.socket_log_id);
997 response->setConnectionReused(info.load_timing.socket_reused);
998 response->setDownloadFilePath(info.download_file_path.AsUTF16Unsafe());
999 response->setWasFetchedViaSPDY(info.was_fetched_via_spdy);
1000 response->setWasFetchedViaServiceWorker(info.was_fetched_via_service_worker);
1001 response->setWasFallbackRequiredByServiceWorker(
1002 info.was_fallback_required_by_service_worker);
1003 response->setServiceWorkerResponseType(info.response_type_via_service_worker);
1004 response->setOriginalURLViaServiceWorker(
1005 info.original_url_via_service_worker);
1007 SetSecurityStyleAndDetails(url, info.security_info, response,
1008 report_security_info);
1010 WebURLResponseExtraDataImpl* extra_data =
1011 new WebURLResponseExtraDataImpl(info.npn_negotiated_protocol);
1012 response->setExtraData(extra_data);
1013 extra_data->set_was_fetched_via_spdy(info.was_fetched_via_spdy);
1014 extra_data->set_was_npn_negotiated(info.was_npn_negotiated);
1015 extra_data->set_was_alternate_protocol_available(
1016 info.was_alternate_protocol_available);
1017 extra_data->set_connection_info(info.connection_info);
1018 extra_data->set_was_fetched_via_proxy(info.was_fetched_via_proxy);
1019 extra_data->set_proxy_server(info.proxy_server);
1021 // If there's no received headers end time, don't set load timing. This is
1022 // the case for non-HTTP requests, requests that don't go over the wire, and
1023 // certain error cases.
1024 if (!info.load_timing.receive_headers_end.is_null()) {
1025 WebURLLoadTiming timing;
1026 PopulateURLLoadTiming(info.load_timing, &timing);
1027 const TimeTicks kNullTicks;
1028 timing.setWorkerStart(
1029 (info.service_worker_start_time - kNullTicks).InSecondsF());
1030 timing.setWorkerReady(
1031 (info.service_worker_ready_time - kNullTicks).InSecondsF());
1032 response->setLoadTiming(timing);
1035 if (info.devtools_info.get()) {
1036 WebHTTPLoadInfo load_info;
1038 load_info.setHTTPStatusCode(info.devtools_info->http_status_code);
1039 load_info.setHTTPStatusText(WebString::fromLatin1(
1040 info.devtools_info->http_status_text));
1041 load_info.setEncodedDataLength(info.encoded_data_length);
1043 load_info.setRequestHeadersText(WebString::fromLatin1(
1044 info.devtools_info->request_headers_text));
1045 load_info.setResponseHeadersText(WebString::fromLatin1(
1046 info.devtools_info->response_headers_text));
1047 const HeadersVector& request_headers = info.devtools_info->request_headers;
1048 for (HeadersVector::const_iterator it = request_headers.begin();
1049 it != request_headers.end(); ++it) {
1050 load_info.addRequestHeader(WebString::fromLatin1(it->first),
1051 WebString::fromLatin1(it->second));
1053 const HeadersVector& response_headers =
1054 info.devtools_info->response_headers;
1055 for (HeadersVector::const_iterator it = response_headers.begin();
1056 it != response_headers.end(); ++it) {
1057 load_info.addResponseHeader(WebString::fromLatin1(it->first),
1058 WebString::fromLatin1(it->second));
1060 load_info.setNPNNegotiatedProtocol(WebString::fromLatin1(
1061 info.npn_negotiated_protocol));
1062 response->setHTTPLoadInfo(load_info);
1065 const net::HttpResponseHeaders* headers = info.headers.get();
1066 if (!headers)
1067 return;
1069 WebURLResponse::HTTPVersion version = WebURLResponse::Unknown;
1070 if (headers->GetHttpVersion() == net::HttpVersion(0, 9))
1071 version = WebURLResponse::HTTP_0_9;
1072 else if (headers->GetHttpVersion() == net::HttpVersion(1, 0))
1073 version = WebURLResponse::HTTP_1_0;
1074 else if (headers->GetHttpVersion() == net::HttpVersion(1, 1))
1075 version = WebURLResponse::HTTP_1_1;
1076 response->setHTTPVersion(version);
1077 response->setHTTPStatusCode(headers->response_code());
1078 response->setHTTPStatusText(WebString::fromLatin1(headers->GetStatusText()));
1080 // TODO(darin): We should leverage HttpResponseHeaders for this, and this
1081 // should be using the same code as ResourceDispatcherHost.
1082 // TODO(jungshik): Figure out the actual value of the referrer charset and
1083 // pass it to GetSuggestedFilename.
1084 std::string value;
1085 headers->EnumerateHeader(NULL, "content-disposition", &value);
1086 response->setSuggestedFileName(
1087 net::GetSuggestedFilename(url,
1088 value,
1089 std::string(), // referrer_charset
1090 std::string(), // suggested_name
1091 std::string(), // mime_type
1092 std::string())); // default_name
1094 Time time_val;
1095 if (headers->GetLastModifiedValue(&time_val))
1096 response->setLastModifiedDate(time_val.ToDoubleT());
1098 // Build up the header map.
1099 void* iter = NULL;
1100 std::string name;
1101 while (headers->EnumerateHeaderLines(&iter, &name, &value)) {
1102 response->addHTTPHeaderField(WebString::fromLatin1(name),
1103 WebString::fromLatin1(value));
1107 void WebURLLoaderImpl::loadSynchronously(const WebURLRequest& request,
1108 WebURLResponse& response,
1109 WebURLError& error,
1110 WebData& data) {
1111 SyncLoadResponse sync_load_response;
1112 context_->Start(request, &sync_load_response);
1114 const GURL& final_url = sync_load_response.url;
1116 // TODO(tc): For file loads, we may want to include a more descriptive
1117 // status code or status text.
1118 int error_code = sync_load_response.error_code;
1119 if (error_code != net::OK) {
1120 response.setURL(final_url);
1121 error.domain = WebString::fromUTF8(net::kErrorDomain);
1122 error.reason = error_code;
1123 error.unreachableURL = final_url;
1124 return;
1127 PopulateURLResponse(final_url, sync_load_response, &response,
1128 request.reportRawHeaders());
1130 data.assign(sync_load_response.data.data(),
1131 sync_load_response.data.size());
1134 void WebURLLoaderImpl::loadAsynchronously(const WebURLRequest& request,
1135 WebURLLoaderClient* client) {
1136 DCHECK(!context_->client());
1138 context_->set_client(client);
1139 context_->Start(request, NULL);
1142 void WebURLLoaderImpl::cancel() {
1143 context_->Cancel();
1146 void WebURLLoaderImpl::setDefersLoading(bool value) {
1147 context_->SetDefersLoading(value);
1150 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority,
1151 int intra_priority_value) {
1152 context_->DidChangePriority(new_priority, intra_priority_value);
1155 bool WebURLLoaderImpl::attachThreadedDataReceiver(
1156 blink::WebThreadedDataReceiver* threaded_data_receiver) {
1157 return context_->AttachThreadedDataReceiver(threaded_data_receiver);
1160 } // namespace content