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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/trace_event/trace_event.h" |
10 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 11 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
11 #include "content/browser/frame_host/navigation_request_info.h" | 12 #include "content/browser/frame_host/navigation_request_info.h" |
12 #include "content/browser/loader/navigation_resource_handler.h" | 13 #include "content/browser/loader/navigation_resource_handler.h" |
13 #include "content/browser/loader/navigation_resource_throttle.h" | 14 #include "content/browser/loader/navigation_resource_throttle.h" |
14 #include "content/browser/loader/navigation_url_loader_delegate.h" | 15 #include "content/browser/loader/navigation_url_loader_delegate.h" |
15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/global_request_id.h" | 17 #include "content/public/browser/global_request_id.h" |
17 #include "content/public/browser/navigation_data.h" | 18 #include "content/public/browser/navigation_data.h" |
18 #include "content/public/browser/navigation_ui_data.h" | 19 #include "content/public/browser/navigation_ui_data.h" |
19 #include "content/public/browser/ssl_status.h" | 20 #include "content/public/browser/ssl_status.h" |
(...skipping 28 matching lines...) Expand all Loading... |
48 ResourceContext* resource_context, | 49 ResourceContext* resource_context, |
49 StoragePartition* storage_partition, | 50 StoragePartition* storage_partition, |
50 std::unique_ptr<NavigationRequestInfo> request_info, | 51 std::unique_ptr<NavigationRequestInfo> request_info, |
51 std::unique_ptr<NavigationUIData> navigation_ui_data, | 52 std::unique_ptr<NavigationUIData> navigation_ui_data, |
52 ServiceWorkerNavigationHandle* service_worker_handle, | 53 ServiceWorkerNavigationHandle* service_worker_handle, |
53 AppCacheNavigationHandle* appcache_handle, | 54 AppCacheNavigationHandle* appcache_handle, |
54 NavigationURLLoaderDelegate* delegate) | 55 NavigationURLLoaderDelegate* delegate) |
55 : delegate_(delegate), binding_(this), weak_factory_(this) { | 56 : delegate_(delegate), binding_(this), weak_factory_(this) { |
56 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 57 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
57 | 58 |
| 59 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( |
| 60 "navigation", "Navigation timeToResponseStarted", this, |
| 61 request_info->common_params.navigation_start, "FrameTreeNode id", |
| 62 request_info->frame_tree_node_id); |
| 63 |
58 // TODO(scottmg): Maybe some of this setup should be done only once, instead | 64 // TODO(scottmg): Maybe some of this setup should be done only once, instead |
59 // of every time. | 65 // of every time. |
60 ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface( | 66 ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface( |
61 mojom::kNetworkServiceName, &url_loader_factory_); | 67 mojom::kNetworkServiceName, &url_loader_factory_); |
62 | 68 |
63 // TODO(scottmg): Port over stuff from RDHI::BeginNavigationRequest() here. | 69 // TODO(scottmg): Port over stuff from RDHI::BeginNavigationRequest() here. |
64 auto new_request = base::MakeUnique<ResourceRequest>(); | 70 auto new_request = base::MakeUnique<ResourceRequest>(); |
65 | 71 |
66 new_request->method = request_info->common_params.method; | 72 new_request->method = request_info->common_params.method; |
67 new_request->url = request_info->common_params.url; | 73 new_request->url = request_info->common_params.url; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 151 |
146 void NavigationURLLoaderNetworkService::OnReceiveCachedMetadata( | 152 void NavigationURLLoaderNetworkService::OnReceiveCachedMetadata( |
147 const std::vector<uint8_t>& data) {} | 153 const std::vector<uint8_t>& data) {} |
148 | 154 |
149 void NavigationURLLoaderNetworkService::OnTransferSizeUpdated( | 155 void NavigationURLLoaderNetworkService::OnTransferSizeUpdated( |
150 int32_t transfer_size_diff) {} | 156 int32_t transfer_size_diff) {} |
151 | 157 |
152 void NavigationURLLoaderNetworkService::OnStartLoadingResponseBody( | 158 void NavigationURLLoaderNetworkService::OnStartLoadingResponseBody( |
153 mojo::ScopedDataPipeConsumerHandle body) { | 159 mojo::ScopedDataPipeConsumerHandle body) { |
154 DCHECK(response_); | 160 DCHECK(response_); |
| 161 |
| 162 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", this, |
| 163 "&NavigationURLLoaderNetworkService", this, "success", |
| 164 true); |
| 165 |
155 // Temporarily, we pass both a stream (null) and the data pipe to the | 166 // Temporarily, we pass both a stream (null) and the data pipe to the |
156 // delegate until PlzNavigate has shipped and we can be comfortable fully | 167 // delegate until PlzNavigate has shipped and we can be comfortable fully |
157 // switching to the data pipe. | 168 // switching to the data pipe. |
158 delegate_->OnResponseStarted(response_, nullptr, std::move(body), ssl_status_, | 169 delegate_->OnResponseStarted(response_, nullptr, std::move(body), ssl_status_, |
159 std::unique_ptr<NavigationData>(), | 170 std::unique_ptr<NavigationData>(), |
160 GlobalRequestID() /* request_id? */, | 171 GlobalRequestID() /* request_id? */, |
161 false /* is_download? */, false /* is_stream */); | 172 false /* is_download? */, false /* is_stream */); |
162 } | 173 } |
163 | 174 |
164 void NavigationURLLoaderNetworkService::OnComplete( | 175 void NavigationURLLoaderNetworkService::OnComplete( |
165 const ResourceRequestCompletionStatus& completion_status) { | 176 const ResourceRequestCompletionStatus& completion_status) { |
166 if (completion_status.error_code != net::OK) { | 177 if (completion_status.error_code != net::OK) { |
| 178 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", |
| 179 this, "&NavigationURLLoaderNetworkService", this, |
| 180 "success", false); |
| 181 |
167 delegate_->OnRequestFailed(completion_status.exists_in_cache, | 182 delegate_->OnRequestFailed(completion_status.exists_in_cache, |
168 completion_status.error_code); | 183 completion_status.error_code); |
169 } | 184 } |
170 } | 185 } |
171 | 186 |
172 void NavigationURLLoaderNetworkService::StartURLRequest( | 187 void NavigationURLLoaderNetworkService::StartURLRequest( |
173 std::unique_ptr<ResourceRequest> request) { | 188 std::unique_ptr<ResourceRequest> request) { |
174 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 189 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
175 | 190 |
176 mojom::URLLoaderClientPtr url_loader_client_ptr_to_pass; | 191 mojom::URLLoaderClientPtr url_loader_client_ptr_to_pass; |
177 binding_.Bind(&url_loader_client_ptr_to_pass); | 192 binding_.Bind(&url_loader_client_ptr_to_pass); |
178 | 193 |
179 url_loader_factory_->CreateLoaderAndStart( | 194 url_loader_factory_->CreateLoaderAndStart( |
180 mojo::MakeRequest(&url_loader_associated_ptr_), 0 /* routing_id? */, | 195 mojo::MakeRequest(&url_loader_associated_ptr_), 0 /* routing_id? */, |
181 0 /* request_id? */, mojom::kURLLoadOptionSendSSLInfo, *request, | 196 0 /* request_id? */, mojom::kURLLoadOptionSendSSLInfo, *request, |
182 std::move(url_loader_client_ptr_to_pass)); | 197 std::move(url_loader_client_ptr_to_pass)); |
183 } | 198 } |
184 | 199 |
185 } // namespace content | 200 } // namespace content |
OLD | NEW |