OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "content/child/web_url_loader_impl.h" | 5 #include "content/child/web_url_loader_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 #include <utility> | 12 #include <utility> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
20 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
24 #include "components/mime_util/mime_util.h" | 24 #include "components/mime_util/mime_util.h" |
25 #include "components/scheduler/child/web_task_runner_impl.h" | |
26 #include "content/child/child_thread_impl.h" | 25 #include "content/child/child_thread_impl.h" |
27 #include "content/child/ftp_directory_listing_response_delegate.h" | 26 #include "content/child/ftp_directory_listing_response_delegate.h" |
28 #include "content/child/request_extra_data.h" | 27 #include "content/child/request_extra_data.h" |
29 #include "content/child/request_info.h" | 28 #include "content/child/request_info.h" |
30 #include "content/child/resource_dispatcher.h" | 29 #include "content/child/resource_dispatcher.h" |
31 #include "content/child/shared_memory_data_consumer_handle.h" | 30 #include "content/child/shared_memory_data_consumer_handle.h" |
32 #include "content/child/sync_load_response.h" | 31 #include "content/child/sync_load_response.h" |
33 #include "content/child/web_url_request_util.h" | 32 #include "content/child/web_url_request_util.h" |
34 #include "content/child/weburlresponse_extradata_impl.h" | 33 #include "content/child/weburlresponse_extradata_impl.h" |
35 #include "content/common/resource_messages.h" | 34 #include "content/common/resource_messages.h" |
36 #include "content/common/resource_request_body_impl.h" | 35 #include "content/common/resource_request_body_impl.h" |
37 #include "content/common/service_worker/service_worker_types.h" | 36 #include "content/common/service_worker/service_worker_types.h" |
38 #include "content/common/ssl_status_serialization.h" | 37 #include "content/common/ssl_status_serialization.h" |
39 #include "content/public/child/fixed_received_data.h" | 38 #include "content/public/child/fixed_received_data.h" |
40 #include "content/public/child/request_peer.h" | 39 #include "content/public/child/request_peer.h" |
41 #include "content/public/common/browser_side_navigation_policy.h" | 40 #include "content/public/common/browser_side_navigation_policy.h" |
42 #include "content/public/common/ssl_status.h" | 41 #include "content/public/common/ssl_status.h" |
43 #include "net/base/data_url.h" | 42 #include "net/base/data_url.h" |
44 #include "net/base/filename_util.h" | 43 #include "net/base/filename_util.h" |
45 #include "net/base/net_errors.h" | 44 #include "net/base/net_errors.h" |
46 #include "net/cert/cert_status_flags.h" | 45 #include "net/cert/cert_status_flags.h" |
47 #include "net/cert/ct_sct_to_string.h" | 46 #include "net/cert/ct_sct_to_string.h" |
48 #include "net/http/http_response_headers.h" | 47 #include "net/http/http_response_headers.h" |
49 #include "net/http/http_util.h" | 48 #include "net/http/http_util.h" |
50 #include "net/ssl/ssl_cipher_suite_names.h" | 49 #include "net/ssl/ssl_cipher_suite_names.h" |
51 #include "net/ssl/ssl_connection_status_flags.h" | 50 #include "net/ssl/ssl_connection_status_flags.h" |
52 #include "net/url_request/url_request_data_job.h" | 51 #include "net/url_request/url_request_data_job.h" |
53 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h" | 52 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h" |
54 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 53 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
55 #include "third_party/WebKit/public/platform/WebTraceLocation.h" | 54 #include "third_party/WebKit/public/platform/WebTaskRunner.h" |
56 #include "third_party/WebKit/public/platform/WebURL.h" | 55 #include "third_party/WebKit/public/platform/WebURL.h" |
57 #include "third_party/WebKit/public/platform/WebURLError.h" | 56 #include "third_party/WebKit/public/platform/WebURLError.h" |
58 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h" | 57 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h" |
59 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" | 58 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" |
60 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 59 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
61 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 60 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
62 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 61 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
63 | 62 |
64 using base::Time; | 63 using base::Time; |
65 using base::TimeTicks; | 64 using base::TimeTicks; |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 | 297 |
299 } // namespace | 298 } // namespace |
300 | 299 |
301 // This inner class exists since the WebURLLoader may be deleted while inside a | 300 // This inner class exists since the WebURLLoader may be deleted while inside a |
302 // call to WebURLLoaderClient. Refcounting is to keep the context from being | 301 // call to WebURLLoaderClient. Refcounting is to keep the context from being |
303 // deleted if it may have work to do after calling into the client. | 302 // deleted if it may have work to do after calling into the client. |
304 class WebURLLoaderImpl::Context : public base::RefCounted<Context> { | 303 class WebURLLoaderImpl::Context : public base::RefCounted<Context> { |
305 public: | 304 public: |
306 using ReceivedData = RequestPeer::ReceivedData; | 305 using ReceivedData = RequestPeer::ReceivedData; |
307 | 306 |
308 Context(WebURLLoaderImpl* loader, | 307 Context(WebURLLoaderImpl* loader, ResourceDispatcher* resource_dispatcher); |
309 ResourceDispatcher* resource_dispatcher, | |
310 std::unique_ptr<blink::WebTaskRunner> task_runner); | |
311 | 308 |
312 WebURLLoaderClient* client() const { return client_; } | 309 WebURLLoaderClient* client() const { return client_; } |
313 void set_client(WebURLLoaderClient* client) { client_ = client; } | 310 void set_client(WebURLLoaderClient* client) { client_ = client; } |
314 | 311 |
315 void Cancel(); | 312 void Cancel(); |
316 void SetDefersLoading(bool value); | 313 void SetDefersLoading(bool value); |
317 void DidChangePriority(WebURLRequest::Priority new_priority, | 314 void DidChangePriority(WebURLRequest::Priority new_priority, |
318 int intra_priority_value); | 315 int intra_priority_value); |
319 void Start(const WebURLRequest& request, | 316 void Start(const WebURLRequest& request, |
320 SyncLoadResponse* sync_load_response); | 317 SyncLoadResponse* sync_load_response); |
321 void SetWebTaskRunner(std::unique_ptr<blink::WebTaskRunner> task_runner); | 318 void SetTaskRunner(scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
no sievers
2016/08/08 18:45:54
nit: const-ref here too
Sami
2016/08/09 10:09:42
Done.
| |
322 | 319 |
323 void OnUploadProgress(uint64_t position, uint64_t size); | 320 void OnUploadProgress(uint64_t position, uint64_t size); |
324 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, | 321 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, |
325 const ResourceResponseInfo& info); | 322 const ResourceResponseInfo& info); |
326 void OnReceivedResponse(const ResourceResponseInfo& info); | 323 void OnReceivedResponse(const ResourceResponseInfo& info); |
327 void OnDownloadedData(int len, int encoded_data_length); | 324 void OnDownloadedData(int len, int encoded_data_length); |
328 void OnReceivedData(std::unique_ptr<ReceivedData> data); | 325 void OnReceivedData(std::unique_ptr<ReceivedData> data); |
329 void OnReceivedCachedMetadata(const char* data, int len); | 326 void OnReceivedCachedMetadata(const char* data, int len); |
330 void OnCompletedRequest(int error_code, | 327 void OnCompletedRequest(int error_code, |
331 bool was_ignored_by_handler, | 328 bool was_ignored_by_handler, |
332 bool stale_copy_in_cache, | 329 bool stale_copy_in_cache, |
333 const std::string& security_info, | 330 const std::string& security_info, |
334 const base::TimeTicks& completion_time, | 331 const base::TimeTicks& completion_time, |
335 int64_t total_transfer_size); | 332 int64_t total_transfer_size); |
336 | 333 |
337 private: | 334 private: |
338 friend class base::RefCounted<Context>; | 335 friend class base::RefCounted<Context>; |
339 ~Context(); | 336 ~Context(); |
340 | 337 |
341 class HandleDataURLTask : public blink::WebTaskRunner::Task { | |
342 public: | |
343 explicit HandleDataURLTask(scoped_refptr<Context> context) | |
344 : context_(context) {} | |
345 | |
346 void run() override { | |
347 context_->HandleDataURL(); | |
348 } | |
349 | |
350 private: | |
351 scoped_refptr<Context> context_; | |
352 }; | |
353 | |
354 // Called when the body data stream is detached from the reader side. | 338 // Called when the body data stream is detached from the reader side. |
355 void CancelBodyStreaming(); | 339 void CancelBodyStreaming(); |
356 // We can optimize the handling of data URLs in most cases. | 340 // We can optimize the handling of data URLs in most cases. |
357 bool CanHandleDataURLRequestLocally() const; | 341 bool CanHandleDataURLRequestLocally() const; |
358 void HandleDataURL(); | 342 void HandleDataURL(); |
359 | 343 |
360 WebURLLoaderImpl* loader_; | 344 WebURLLoaderImpl* loader_; |
361 WebURLRequest request_; | 345 WebURLRequest request_; |
362 WebURLLoaderClient* client_; | 346 WebURLLoaderClient* client_; |
363 ResourceDispatcher* resource_dispatcher_; | 347 ResourceDispatcher* resource_dispatcher_; |
364 std::unique_ptr<blink::WebTaskRunner> web_task_runner_; | 348 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
365 WebReferrerPolicy referrer_policy_; | 349 WebReferrerPolicy referrer_policy_; |
366 std::unique_ptr<FtpDirectoryListingResponseDelegate> ftp_listing_delegate_; | 350 std::unique_ptr<FtpDirectoryListingResponseDelegate> ftp_listing_delegate_; |
367 std::unique_ptr<StreamOverrideParameters> stream_override_; | 351 std::unique_ptr<StreamOverrideParameters> stream_override_; |
368 std::unique_ptr<SharedMemoryDataConsumerHandle::Writer> body_stream_writer_; | 352 std::unique_ptr<SharedMemoryDataConsumerHandle::Writer> body_stream_writer_; |
369 enum DeferState {NOT_DEFERRING, SHOULD_DEFER, DEFERRED_DATA}; | 353 enum DeferState {NOT_DEFERRING, SHOULD_DEFER, DEFERRED_DATA}; |
370 DeferState defers_loading_; | 354 DeferState defers_loading_; |
371 int request_id_; | 355 int request_id_; |
372 }; | 356 }; |
373 | 357 |
374 // A thin wrapper class for Context to ensure its lifetime while it is | 358 // A thin wrapper class for Context to ensure its lifetime while it is |
(...skipping 18 matching lines...) Expand all Loading... | |
393 const base::TimeTicks& completion_time, | 377 const base::TimeTicks& completion_time, |
394 int64_t total_transfer_size) override; | 378 int64_t total_transfer_size) override; |
395 | 379 |
396 private: | 380 private: |
397 scoped_refptr<Context> context_; | 381 scoped_refptr<Context> context_; |
398 DISALLOW_COPY_AND_ASSIGN(RequestPeerImpl); | 382 DISALLOW_COPY_AND_ASSIGN(RequestPeerImpl); |
399 }; | 383 }; |
400 | 384 |
401 // WebURLLoaderImpl::Context -------------------------------------------------- | 385 // WebURLLoaderImpl::Context -------------------------------------------------- |
402 | 386 |
403 WebURLLoaderImpl::Context::Context( | 387 WebURLLoaderImpl::Context::Context(WebURLLoaderImpl* loader, |
404 WebURLLoaderImpl* loader, | 388 ResourceDispatcher* resource_dispatcher) |
405 ResourceDispatcher* resource_dispatcher, | |
406 std::unique_ptr<blink::WebTaskRunner> web_task_runner) | |
407 : loader_(loader), | 389 : loader_(loader), |
408 client_(NULL), | 390 client_(NULL), |
409 resource_dispatcher_(resource_dispatcher), | 391 resource_dispatcher_(resource_dispatcher), |
410 web_task_runner_(std::move(web_task_runner)), | 392 task_runner_(base::ThreadTaskRunnerHandle::Get()), |
411 referrer_policy_(blink::WebReferrerPolicyDefault), | 393 referrer_policy_(blink::WebReferrerPolicyDefault), |
412 defers_loading_(NOT_DEFERRING), | 394 defers_loading_(NOT_DEFERRING), |
413 request_id_(-1) {} | 395 request_id_(-1) {} |
414 | 396 |
415 void WebURLLoaderImpl::Context::Cancel() { | 397 void WebURLLoaderImpl::Context::Cancel() { |
416 TRACE_EVENT_WITH_FLOW0("loading", "WebURLLoaderImpl::Context::Cancel", this, | 398 TRACE_EVENT_WITH_FLOW0("loading", "WebURLLoaderImpl::Context::Cancel", this, |
417 TRACE_EVENT_FLAG_FLOW_IN); | 399 TRACE_EVENT_FLAG_FLOW_IN); |
418 if (resource_dispatcher_ && // NULL in unittest. | 400 if (resource_dispatcher_ && // NULL in unittest. |
419 request_id_ != -1) { | 401 request_id_ != -1) { |
420 resource_dispatcher_->Cancel(request_id_); | 402 resource_dispatcher_->Cancel(request_id_); |
(...skipping 13 matching lines...) Expand all Loading... | |
434 loader_ = NULL; | 416 loader_ = NULL; |
435 } | 417 } |
436 | 418 |
437 void WebURLLoaderImpl::Context::SetDefersLoading(bool value) { | 419 void WebURLLoaderImpl::Context::SetDefersLoading(bool value) { |
438 if (request_id_ != -1) | 420 if (request_id_ != -1) |
439 resource_dispatcher_->SetDefersLoading(request_id_, value); | 421 resource_dispatcher_->SetDefersLoading(request_id_, value); |
440 if (value && defers_loading_ == NOT_DEFERRING) { | 422 if (value && defers_loading_ == NOT_DEFERRING) { |
441 defers_loading_ = SHOULD_DEFER; | 423 defers_loading_ = SHOULD_DEFER; |
442 } else if (!value && defers_loading_ != NOT_DEFERRING) { | 424 } else if (!value && defers_loading_ != NOT_DEFERRING) { |
443 if (defers_loading_ == DEFERRED_DATA) { | 425 if (defers_loading_ == DEFERRED_DATA) { |
444 // TODO(alexclarke): Find a way to let blink and chromium FROM_HERE | 426 task_runner_->PostTask(FROM_HERE, base::Bind(&Context::HandleDataURL, |
445 // coexist. | 427 this)); |
446 web_task_runner_->postTask( | |
447 BLINK_FROM_HERE, | |
448 new HandleDataURLTask(this)); | |
449 } | 428 } |
450 defers_loading_ = NOT_DEFERRING; | 429 defers_loading_ = NOT_DEFERRING; |
451 } | 430 } |
452 } | 431 } |
453 | 432 |
454 void WebURLLoaderImpl::Context::DidChangePriority( | 433 void WebURLLoaderImpl::Context::DidChangePriority( |
455 WebURLRequest::Priority new_priority, int intra_priority_value) { | 434 WebURLRequest::Priority new_priority, int intra_priority_value) { |
456 if (request_id_ != -1) { | 435 if (request_id_ != -1) { |
457 resource_dispatcher_->DidChangePriority( | 436 resource_dispatcher_->DidChangePriority( |
458 request_id_, | 437 request_id_, |
459 ConvertWebKitPriorityToNetPriority(new_priority), | 438 ConvertWebKitPriorityToNetPriority(new_priority), |
460 intra_priority_value); | 439 intra_priority_value); |
461 } | 440 } |
462 } | 441 } |
463 | 442 |
464 void WebURLLoaderImpl::Context::Start(const WebURLRequest& request, | 443 void WebURLLoaderImpl::Context::Start(const WebURLRequest& request, |
465 SyncLoadResponse* sync_load_response) { | 444 SyncLoadResponse* sync_load_response) { |
466 DCHECK(request_id_ == -1); | 445 DCHECK(request_id_ == -1); |
467 request_ = request; // Save the request. | 446 request_ = request; // Save the request. |
468 GURL url = request.url(); | 447 GURL url = request.url(); |
469 | 448 |
470 if (CanHandleDataURLRequestLocally()) { | 449 if (CanHandleDataURLRequestLocally()) { |
471 if (sync_load_response) { | 450 if (sync_load_response) { |
472 // This is a sync load. Do the work now. | 451 // This is a sync load. Do the work now. |
473 sync_load_response->url = url; | 452 sync_load_response->url = url; |
474 sync_load_response->error_code = | 453 sync_load_response->error_code = |
475 GetInfoFromDataURL(sync_load_response->url, sync_load_response, | 454 GetInfoFromDataURL(sync_load_response->url, sync_load_response, |
476 &sync_load_response->data); | 455 &sync_load_response->data); |
477 } else { | 456 } else { |
478 // TODO(alexclarke): Find a way to let blink and chromium FROM_HERE | 457 task_runner_->PostTask(FROM_HERE, base::Bind(&Context::HandleDataURL, |
479 // coexist. | 458 this)); |
480 web_task_runner_->postTask( | |
481 BLINK_FROM_HERE, | |
482 new HandleDataURLTask(this)); | |
483 } | 459 } |
484 return; | 460 return; |
485 } | 461 } |
486 | 462 |
487 if (request.getExtraData()) { | 463 if (request.getExtraData()) { |
488 RequestExtraData* extra_data = | 464 RequestExtraData* extra_data = |
489 static_cast<RequestExtraData*>(request.getExtraData()); | 465 static_cast<RequestExtraData*>(request.getExtraData()); |
490 stream_override_ = extra_data->TakeStreamOverrideOwnership(); | 466 stream_override_ = extra_data->TakeStreamOverrideOwnership(); |
491 } | 467 } |
492 | 468 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
543 request_info.fetch_credentials_mode = | 519 request_info.fetch_credentials_mode = |
544 GetFetchCredentialsModeForWebURLRequest(request); | 520 GetFetchCredentialsModeForWebURLRequest(request); |
545 request_info.fetch_redirect_mode = | 521 request_info.fetch_redirect_mode = |
546 GetFetchRedirectModeForWebURLRequest(request); | 522 GetFetchRedirectModeForWebURLRequest(request); |
547 request_info.fetch_request_context_type = | 523 request_info.fetch_request_context_type = |
548 GetRequestContextTypeForWebURLRequest(request); | 524 GetRequestContextTypeForWebURLRequest(request); |
549 request_info.fetch_frame_type = | 525 request_info.fetch_frame_type = |
550 GetRequestContextFrameTypeForWebURLRequest(request); | 526 GetRequestContextFrameTypeForWebURLRequest(request); |
551 request_info.extra_data = request.getExtraData(); | 527 request_info.extra_data = request.getExtraData(); |
552 request_info.report_raw_headers = request.reportRawHeaders(); | 528 request_info.report_raw_headers = request.reportRawHeaders(); |
553 request_info.loading_web_task_runner = web_task_runner_->clone(); | 529 request_info.loading_task_runner = task_runner_; |
554 request_info.lofi_state = static_cast<LoFiState>(request.getLoFiState()); | 530 request_info.lofi_state = static_cast<LoFiState>(request.getLoFiState()); |
555 | 531 |
556 scoped_refptr<ResourceRequestBodyImpl> request_body = | 532 scoped_refptr<ResourceRequestBodyImpl> request_body = |
557 GetRequestBodyForWebURLRequest(request).get(); | 533 GetRequestBodyForWebURLRequest(request).get(); |
558 | 534 |
559 // PlzNavigate: during navigation, the renderer should request a stream which | 535 // PlzNavigate: during navigation, the renderer should request a stream which |
560 // contains the body of the response. The network request has already been | 536 // contains the body of the response. The network request has already been |
561 // made by the browser. | 537 // made by the browser. |
562 if (stream_override_.get()) { | 538 if (stream_override_.get()) { |
563 CHECK(IsBrowserSideNavigationEnabled()); | 539 CHECK(IsBrowserSideNavigationEnabled()); |
(...skipping 12 matching lines...) Expand all Loading... | |
576 TRACE_EVENT_WITH_FLOW0("loading", "WebURLLoaderImpl::Context::Start", this, | 552 TRACE_EVENT_WITH_FLOW0("loading", "WebURLLoaderImpl::Context::Start", this, |
577 TRACE_EVENT_FLAG_FLOW_OUT); | 553 TRACE_EVENT_FLAG_FLOW_OUT); |
578 request_id_ = resource_dispatcher_->StartAsync( | 554 request_id_ = resource_dispatcher_->StartAsync( |
579 request_info, request_body.get(), | 555 request_info, request_body.get(), |
580 base::WrapUnique(new WebURLLoaderImpl::RequestPeerImpl(this))); | 556 base::WrapUnique(new WebURLLoaderImpl::RequestPeerImpl(this))); |
581 | 557 |
582 if (defers_loading_ != NOT_DEFERRING) | 558 if (defers_loading_ != NOT_DEFERRING) |
583 resource_dispatcher_->SetDefersLoading(request_id_, true); | 559 resource_dispatcher_->SetDefersLoading(request_id_, true); |
584 } | 560 } |
585 | 561 |
586 void WebURLLoaderImpl::Context::SetWebTaskRunner( | 562 void WebURLLoaderImpl::Context::SetTaskRunner( |
587 std::unique_ptr<blink::WebTaskRunner> web_task_runner) { | 563 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
588 web_task_runner_ = std::move(web_task_runner); | 564 task_runner_ = std::move(task_runner); |
no sievers
2016/08/08 18:45:54
here too
Sami
2016/08/09 10:09:42
Done.
| |
589 } | 565 } |
590 | 566 |
591 void WebURLLoaderImpl::Context::OnUploadProgress(uint64_t position, | 567 void WebURLLoaderImpl::Context::OnUploadProgress(uint64_t position, |
592 uint64_t size) { | 568 uint64_t size) { |
593 if (client_) | 569 if (client_) |
594 client_->didSendData(loader_, position, size); | 570 client_->didSendData(loader_, position, size); |
595 } | 571 } |
596 | 572 |
597 bool WebURLLoaderImpl::Context::OnReceivedRedirect( | 573 bool WebURLLoaderImpl::Context::OnReceivedRedirect( |
598 const net::RedirectInfo& redirect_info, | 574 const net::RedirectInfo& redirect_info, |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
941 const std::string& security_info, | 917 const std::string& security_info, |
942 const base::TimeTicks& completion_time, | 918 const base::TimeTicks& completion_time, |
943 int64_t total_transfer_size) { | 919 int64_t total_transfer_size) { |
944 context_->OnCompletedRequest(error_code, was_ignored_by_handler, | 920 context_->OnCompletedRequest(error_code, was_ignored_by_handler, |
945 stale_copy_in_cache, security_info, | 921 stale_copy_in_cache, security_info, |
946 completion_time, total_transfer_size); | 922 completion_time, total_transfer_size); |
947 } | 923 } |
948 | 924 |
949 // WebURLLoaderImpl ----------------------------------------------------------- | 925 // WebURLLoaderImpl ----------------------------------------------------------- |
950 | 926 |
951 WebURLLoaderImpl::WebURLLoaderImpl( | 927 WebURLLoaderImpl::WebURLLoaderImpl(ResourceDispatcher* resource_dispatcher) |
952 ResourceDispatcher* resource_dispatcher, | 928 : context_(new Context(this, resource_dispatcher)) {} |
953 std::unique_ptr<blink::WebTaskRunner> web_task_runner) | |
954 : context_( | |
955 new Context(this, resource_dispatcher, std::move(web_task_runner))) {} | |
956 | 929 |
957 WebURLLoaderImpl::~WebURLLoaderImpl() { | 930 WebURLLoaderImpl::~WebURLLoaderImpl() { |
958 cancel(); | 931 cancel(); |
959 } | 932 } |
960 | 933 |
961 void WebURLLoaderImpl::PopulateURLResponse(const GURL& url, | 934 void WebURLLoaderImpl::PopulateURLResponse(const GURL& url, |
962 const ResourceResponseInfo& info, | 935 const ResourceResponseInfo& info, |
963 WebURLResponse* response, | 936 WebURLResponse* response, |
964 bool report_security_info) { | 937 bool report_security_info) { |
965 response->setURL(url); | 938 response->setURL(url); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1180 context_->SetDefersLoading(value); | 1153 context_->SetDefersLoading(value); |
1181 } | 1154 } |
1182 | 1155 |
1183 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority, | 1156 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority, |
1184 int intra_priority_value) { | 1157 int intra_priority_value) { |
1185 context_->DidChangePriority(new_priority, intra_priority_value); | 1158 context_->DidChangePriority(new_priority, intra_priority_value); |
1186 } | 1159 } |
1187 | 1160 |
1188 void WebURLLoaderImpl::setLoadingTaskRunner( | 1161 void WebURLLoaderImpl::setLoadingTaskRunner( |
1189 blink::WebTaskRunner* loading_task_runner) { | 1162 blink::WebTaskRunner* loading_task_runner) { |
1190 // There's no guarantee on the lifetime of |loading_task_runner| so we take a | 1163 context_->SetTaskRunner(loading_task_runner->taskRunner()); |
1191 // copy. | |
1192 context_->SetWebTaskRunner(loading_task_runner->clone()); | |
1193 } | 1164 } |
1194 | 1165 |
1195 // This function is implemented here because it uses net functions. it is | 1166 // This function is implemented here because it uses net functions. it is |
1196 // tested in | 1167 // tested in |
1197 // third_party/WebKit/Source/core/fetch/MultipartImageResourceParserTest.cpp. | 1168 // third_party/WebKit/Source/core/fetch/MultipartImageResourceParserTest.cpp. |
1198 bool WebURLLoaderImpl::ParseMultipartHeadersFromBody( | 1169 bool WebURLLoaderImpl::ParseMultipartHeadersFromBody( |
1199 const char* bytes, | 1170 const char* bytes, |
1200 size_t size, | 1171 size_t size, |
1201 blink::WebURLResponse* response, | 1172 blink::WebURLResponse* response, |
1202 size_t* end) { | 1173 size_t* end) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1234 response->clearHTTPHeaderField(webStringName); | 1205 response->clearHTTPHeaderField(webStringName); |
1235 while (response_headers->EnumerateHeader(&iterator, name, &value)) { | 1206 while (response_headers->EnumerateHeader(&iterator, name, &value)) { |
1236 response->addHTTPHeaderField(webStringName, | 1207 response->addHTTPHeaderField(webStringName, |
1237 WebString::fromLatin1(value)); | 1208 WebString::fromLatin1(value)); |
1238 } | 1209 } |
1239 } | 1210 } |
1240 return true; | 1211 return true; |
1241 } | 1212 } |
1242 | 1213 |
1243 } // namespace content | 1214 } // namespace content |
OLD | NEW |