OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
6 | 6 |
7 #include "content/child/resource_dispatcher.h" | 7 #include "content/child/resource_dispatcher.h" |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "content/common/navigation_params.h" | 32 #include "content/common/navigation_params.h" |
33 #include "content/common/resource_messages.h" | 33 #include "content/common/resource_messages.h" |
34 #include "content/common/resource_request.h" | 34 #include "content/common/resource_request.h" |
35 #include "content/common/resource_request_completion_status.h" | 35 #include "content/common/resource_request_completion_status.h" |
36 #include "content/public/child/fixed_received_data.h" | 36 #include "content/public/child/fixed_received_data.h" |
37 #include "content/public/child/request_peer.h" | 37 #include "content/public/child/request_peer.h" |
38 #include "content/public/child/resource_dispatcher_delegate.h" | 38 #include "content/public/child/resource_dispatcher_delegate.h" |
39 #include "content/public/common/content_features.h" | 39 #include "content/public/common/content_features.h" |
40 #include "content/public/common/resource_response.h" | 40 #include "content/public/common/resource_response.h" |
41 #include "content/public/common/resource_type.h" | 41 #include "content/public/common/resource_type.h" |
42 #include "mojo/public/cpp/bindings/associated_group.h" | |
43 #include "net/base/net_errors.h" | 42 #include "net/base/net_errors.h" |
44 #include "net/base/request_priority.h" | 43 #include "net/base/request_priority.h" |
45 #include "net/http/http_response_headers.h" | 44 #include "net/http/http_response_headers.h" |
46 | 45 |
47 namespace content { | 46 namespace content { |
48 | 47 |
49 namespace { | 48 namespace { |
50 | 49 |
51 // Converts |time| from a remote to local TimeTicks, overwriting the original | 50 // Converts |time| from a remote to local TimeTicks, overwriting the original |
52 // value. | 51 // value. |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 response->encoded_body_length = result.encoded_body_length; | 646 response->encoded_body_length = result.encoded_body_length; |
648 } | 647 } |
649 | 648 |
650 int ResourceDispatcher::StartAsync( | 649 int ResourceDispatcher::StartAsync( |
651 std::unique_ptr<ResourceRequest> request, | 650 std::unique_ptr<ResourceRequest> request, |
652 int routing_id, | 651 int routing_id, |
653 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner, | 652 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner, |
654 const url::Origin& frame_origin, | 653 const url::Origin& frame_origin, |
655 std::unique_ptr<RequestPeer> peer, | 654 std::unique_ptr<RequestPeer> peer, |
656 blink::WebURLRequest::LoadingIPCType ipc_type, | 655 blink::WebURLRequest::LoadingIPCType ipc_type, |
657 mojom::URLLoaderFactory* url_loader_factory, | 656 mojom::URLLoaderFactory* url_loader_factory) { |
658 mojo::AssociatedGroup* associated_group) { | |
659 CheckSchemeForReferrerPolicy(*request); | 657 CheckSchemeForReferrerPolicy(*request); |
660 | 658 |
661 // Compute a unique request_id for this renderer process. | 659 // Compute a unique request_id for this renderer process. |
662 int request_id = MakeRequestID(); | 660 int request_id = MakeRequestID(); |
663 pending_requests_[request_id] = base::MakeUnique<PendingRequestInfo>( | 661 pending_requests_[request_id] = base::MakeUnique<PendingRequestInfo>( |
664 std::move(peer), request->resource_type, request->origin_pid, | 662 std::move(peer), request->resource_type, request->origin_pid, |
665 frame_origin, request->url, request->download_to_file); | 663 frame_origin, request->url, request->download_to_file); |
666 | 664 |
667 if (resource_scheduling_filter_.get() && loading_task_runner) { | 665 if (resource_scheduling_filter_.get() && loading_task_runner) { |
668 resource_scheduling_filter_->SetRequestIdTaskRunner(request_id, | 666 resource_scheduling_filter_->SetRequestIdTaskRunner(request_id, |
669 loading_task_runner); | 667 loading_task_runner); |
670 } | 668 } |
671 | 669 |
672 if (ipc_type == blink::WebURLRequest::LoadingIPCType::Mojo) { | 670 if (ipc_type == blink::WebURLRequest::LoadingIPCType::Mojo) { |
673 std::unique_ptr<URLLoaderClientImpl> client( | 671 std::unique_ptr<URLLoaderClientImpl> client( |
674 new URLLoaderClientImpl(request_id, this, main_thread_task_runner_)); | 672 new URLLoaderClientImpl(request_id, this, main_thread_task_runner_)); |
675 mojom::URLLoaderAssociatedPtr url_loader; | 673 mojom::URLLoaderAssociatedPtr url_loader; |
676 mojom::URLLoaderClientAssociatedPtrInfo client_ptr_info; | 674 mojom::URLLoaderClientAssociatedPtrInfo client_ptr_info; |
677 client->Bind(&client_ptr_info, associated_group); | 675 client->Bind(&client_ptr_info); |
678 url_loader_factory->CreateLoaderAndStart( | 676 url_loader_factory->CreateLoaderAndStart(MakeRequest(&url_loader), |
679 MakeRequest(&url_loader, associated_group), routing_id, request_id, | 677 routing_id, request_id, *request, |
680 *request, std::move(client_ptr_info)); | 678 std::move(client_ptr_info)); |
681 pending_requests_[request_id]->url_loader = std::move(url_loader); | 679 pending_requests_[request_id]->url_loader = std::move(url_loader); |
682 pending_requests_[request_id]->url_loader_client = std::move(client); | 680 pending_requests_[request_id]->url_loader_client = std::move(client); |
683 } else { | 681 } else { |
684 message_sender_->Send( | 682 message_sender_->Send( |
685 new ResourceHostMsg_RequestResource(routing_id, request_id, *request)); | 683 new ResourceHostMsg_RequestResource(routing_id, request_id, *request)); |
686 } | 684 } |
687 | 685 |
688 return request_id; | 686 return request_id; |
689 } | 687 } |
690 | 688 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 delete message; | 820 delete message; |
823 } | 821 } |
824 } | 822 } |
825 | 823 |
826 void ResourceDispatcher::SetResourceSchedulingFilter( | 824 void ResourceDispatcher::SetResourceSchedulingFilter( |
827 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { | 825 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { |
828 resource_scheduling_filter_ = resource_scheduling_filter; | 826 resource_scheduling_filter_ = resource_scheduling_filter; |
829 } | 827 } |
830 | 828 |
831 } // namespace content | 829 } // namespace content |
OLD | NEW |