| 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 "content/browser/loader/navigation_url_loader_network_service.h" | 5 #include "content/browser/loader/navigation_url_loader_network_service.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "content/browser/frame_host/navigation_request_info.h" | 8 #include "content/browser/frame_host/navigation_request_info.h" |
| 9 #include "content/browser/loader/navigation_resource_handler.h" |
| 10 #include "content/browser/loader/navigation_resource_throttle.h" |
| 9 #include "content/browser/loader/navigation_url_loader_delegate.h" | 11 #include "content/browser/loader/navigation_url_loader_delegate.h" |
| 10 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 11 #include "content/public/browser/global_request_id.h" | 13 #include "content/public/browser/global_request_id.h" |
| 12 #include "content/public/browser/navigation_data.h" | 14 #include "content/public/browser/navigation_data.h" |
| 13 #include "content/public/browser/navigation_ui_data.h" | 15 #include "content/public/browser/navigation_ui_data.h" |
| 14 #include "content/public/browser/ssl_status.h" | 16 #include "content/public/browser/ssl_status.h" |
| 15 #include "content/public/browser/stream_handle.h" | 17 #include "content/public/browser/stream_handle.h" |
| 16 #include "content/public/common/service_manager_connection.h" | 18 #include "content/public/common/service_manager_connection.h" |
| 17 #include "content/public/common/service_names.mojom.h" | 19 #include "content/public/common/service_names.mojom.h" |
| 18 #include "net/url_request/url_request_context.h" | 20 #include "net/url_request/url_request_context.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 44 new_request->priority = net::HIGHEST; | 46 new_request->priority = net::HIGHEST; |
| 45 | 47 |
| 46 mojom::URLLoaderClientPtr url_loader_client_ptr; | 48 mojom::URLLoaderClientPtr url_loader_client_ptr; |
| 47 mojom::URLLoaderClientRequest url_loader_client_request = | 49 mojom::URLLoaderClientRequest url_loader_client_request = |
| 48 mojo::MakeRequest(&url_loader_client_ptr); | 50 mojo::MakeRequest(&url_loader_client_ptr); |
| 49 mojom::URLLoaderClientPtr url_loader_client_ptr_to_pass; | 51 mojom::URLLoaderClientPtr url_loader_client_ptr_to_pass; |
| 50 binding_.Bind(&url_loader_client_ptr_to_pass); | 52 binding_.Bind(&url_loader_client_ptr_to_pass); |
| 51 | 53 |
| 52 url_loader_factory_->CreateLoaderAndStart( | 54 url_loader_factory_->CreateLoaderAndStart( |
| 53 mojo::MakeRequest(&url_loader_associated_ptr_), 0 /* routing_id? */, | 55 mojo::MakeRequest(&url_loader_associated_ptr_), 0 /* routing_id? */, |
| 54 0 /* request_id? */, *new_request, | 56 0 /* request_id? */, mojom::kURLLoadOptionSendSSLInfo, *new_request, |
| 55 std::move(url_loader_client_ptr_to_pass)); | 57 std::move(url_loader_client_ptr_to_pass)); |
| 56 } | 58 } |
| 57 | 59 |
| 58 NavigationURLLoaderNetworkService::~NavigationURLLoaderNetworkService() {} | 60 NavigationURLLoaderNetworkService::~NavigationURLLoaderNetworkService() {} |
| 59 | 61 |
| 60 void NavigationURLLoaderNetworkService::FollowRedirect() { | 62 void NavigationURLLoaderNetworkService::FollowRedirect() { |
| 61 url_loader_associated_ptr_->FollowRedirect(); | 63 url_loader_associated_ptr_->FollowRedirect(); |
| 62 } | 64 } |
| 63 | 65 |
| 64 void NavigationURLLoaderNetworkService::ProceedWithResponse() {} | 66 void NavigationURLLoaderNetworkService::ProceedWithResponse() {} |
| 65 | 67 |
| 66 void NavigationURLLoaderNetworkService::OnReceiveResponse( | 68 void NavigationURLLoaderNetworkService::OnReceiveResponse( |
| 67 const ResourceResponseHead& head, | 69 const ResourceResponseHead& head, |
| 70 const base::Optional<net::SSLInfo>& ssl_info, |
| 68 mojom::DownloadedTempFilePtr downloaded_file) { | 71 mojom::DownloadedTempFilePtr downloaded_file) { |
| 69 // TODO(scottmg): This needs to do more of what | 72 // TODO(scottmg): This needs to do more of what |
| 70 // NavigationResourceHandler::OnReponseStarted() does. Or maybe in | 73 // NavigationResourceHandler::OnReponseStarted() does. Or maybe in |
| 71 // OnStartLoadingResponseBody(). | 74 // OnStartLoadingResponseBody(). |
| 75 if (ssl_info && ssl_info->cert) |
| 76 NavigationResourceHandler::GetSSLStatusForRequest(*ssl_info, &ssl_status_); |
| 72 response_ = base::MakeShared<ResourceResponse>(); | 77 response_ = base::MakeShared<ResourceResponse>(); |
| 73 response_->head = head; | 78 response_->head = head; |
| 74 } | 79 } |
| 75 | 80 |
| 76 void NavigationURLLoaderNetworkService::OnReceiveRedirect( | 81 void NavigationURLLoaderNetworkService::OnReceiveRedirect( |
| 77 const net::RedirectInfo& redirect_info, | 82 const net::RedirectInfo& redirect_info, |
| 78 const ResourceResponseHead& head) { | 83 const ResourceResponseHead& head) { |
| 79 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 84 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 80 scoped_refptr<ResourceResponse> response(new ResourceResponse()); | 85 scoped_refptr<ResourceResponse> response(new ResourceResponse()); |
| 81 response->head = head; | 86 response->head = head; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 96 | 101 |
| 97 void NavigationURLLoaderNetworkService::OnTransferSizeUpdated( | 102 void NavigationURLLoaderNetworkService::OnTransferSizeUpdated( |
| 98 int32_t transfer_size_diff) {} | 103 int32_t transfer_size_diff) {} |
| 99 | 104 |
| 100 void NavigationURLLoaderNetworkService::OnStartLoadingResponseBody( | 105 void NavigationURLLoaderNetworkService::OnStartLoadingResponseBody( |
| 101 mojo::ScopedDataPipeConsumerHandle body) { | 106 mojo::ScopedDataPipeConsumerHandle body) { |
| 102 DCHECK(response_); | 107 DCHECK(response_); |
| 103 // Temporarily, we pass both a stream (null) and the data pipe to the | 108 // Temporarily, we pass both a stream (null) and the data pipe to the |
| 104 // delegate until PlzNavigate has shipped and we can be comfortable fully | 109 // delegate until PlzNavigate has shipped and we can be comfortable fully |
| 105 // switching to the data pipe. | 110 // switching to the data pipe. |
| 106 delegate_->OnResponseStarted(response_, nullptr, std::move(body), SSLStatus(), | 111 delegate_->OnResponseStarted(response_, nullptr, std::move(body), ssl_status_, |
| 107 std::unique_ptr<NavigationData>(), | 112 std::unique_ptr<NavigationData>(), |
| 108 GlobalRequestID() /* request_id? */, | 113 GlobalRequestID() /* request_id? */, |
| 109 false /* is_download? */, false /* is_stream */); | 114 false /* is_download? */, false /* is_stream */); |
| 110 } | 115 } |
| 111 | 116 |
| 112 void NavigationURLLoaderNetworkService::OnComplete( | 117 void NavigationURLLoaderNetworkService::OnComplete( |
| 113 const ResourceRequestCompletionStatus& completion_status) {} | 118 const ResourceRequestCompletionStatus& completion_status) {} |
| 114 | 119 |
| 115 } // namespace content | 120 } // namespace content |
| OLD | NEW |