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 "base/trace_event/trace_event.h" |
11 #include "content/browser/appcache/appcache_navigation_handle.h" | 11 #include "content/browser/appcache/appcache_navigation_handle.h" |
12 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 12 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
13 #include "content/browser/frame_host/frame_tree_node.h" | 13 #include "content/browser/frame_host/frame_tree_node.h" |
14 #include "content/browser/frame_host/navigation_request_info.h" | 14 #include "content/browser/frame_host/navigation_request_info.h" |
15 #include "content/browser/loader/navigation_resource_handler.h" | 15 #include "content/browser/loader/navigation_resource_handler.h" |
16 #include "content/browser/loader/navigation_resource_throttle.h" | 16 #include "content/browser/loader/navigation_resource_throttle.h" |
17 #include "content/browser/loader/navigation_url_loader_delegate.h" | 17 #include "content/browser/loader/navigation_url_loader_delegate.h" |
| 18 #include "content/browser/loader/url_loader_request_handler.h" |
18 #include "content/browser/resource_context_impl.h" | 19 #include "content/browser/resource_context_impl.h" |
19 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 20 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
20 #include "content/browser/service_worker/service_worker_navigation_handle_core.h
" | 21 #include "content/browser/service_worker/service_worker_navigation_handle_core.h
" |
21 #include "content/browser/service_worker/service_worker_request_handler.h" | 22 #include "content/browser/service_worker/service_worker_request_handler.h" |
22 #include "content/browser/storage_partition_impl.h" | 23 #include "content/browser/storage_partition_impl.h" |
23 #include "content/browser/url_loader_factory_getter.h" | 24 #include "content/browser/url_loader_factory_getter.h" |
24 #include "content/browser/web_contents/web_contents_impl.h" | 25 #include "content/browser/web_contents/web_contents_impl.h" |
25 #include "content/browser/webui/url_data_manager_backend.h" | 26 #include "content/browser/webui/url_data_manager_backend.h" |
26 #include "content/browser/webui/web_ui_url_loader_factory.h" | 27 #include "content/browser/webui/web_ui_url_loader_factory.h" |
27 #include "content/public/browser/browser_context.h" | 28 #include "content/public/browser/browser_context.h" |
(...skipping 19 matching lines...) Expand all Loading... |
47 WebContents* GetWebContentsFromFrameTreeNodeID(int frame_tree_node_id) { | 48 WebContents* GetWebContentsFromFrameTreeNodeID(int frame_tree_node_id) { |
48 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 49 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
49 FrameTreeNode* frame_tree_node = | 50 FrameTreeNode* frame_tree_node = |
50 FrameTreeNode::GloballyFindByID(frame_tree_node_id); | 51 FrameTreeNode::GloballyFindByID(frame_tree_node_id); |
51 if (!frame_tree_node) | 52 if (!frame_tree_node) |
52 return nullptr; | 53 return nullptr; |
53 | 54 |
54 return WebContentsImpl::FromFrameTreeNode(frame_tree_node); | 55 return WebContentsImpl::FromFrameTreeNode(frame_tree_node); |
55 } | 56 } |
56 | 57 |
57 void PrepareNavigationStartOnIO( | |
58 std::unique_ptr<ResourceRequest> resource_request, | |
59 ResourceContext* resource_context, | |
60 ServiceWorkerNavigationHandleCore* service_worker_navigation_handle_core, | |
61 AppCacheNavigationHandleCore* appcache_handle_core, | |
62 NavigationRequestInfo* request_info, | |
63 mojom::URLLoaderFactoryPtrInfo factory_from_ui, | |
64 scoped_refptr<URLLoaderFactoryGetter> url_loader_factory_getter, | |
65 const base::Callback<WebContents*(void)>& web_contents_getter, | |
66 mojom::URLLoaderAssociatedRequest url_loader_request, | |
67 mojom::URLLoaderClientPtr url_loader_client_to_pass, | |
68 std::unique_ptr<service_manager::Connector> connector) { | |
69 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
70 | |
71 const ResourceType resource_type = request_info->is_main_frame | |
72 ? RESOURCE_TYPE_MAIN_FRAME | |
73 : RESOURCE_TYPE_SUB_FRAME; | |
74 | |
75 if (resource_request->request_body) { | |
76 AttachRequestBodyBlobDataHandles(resource_request->request_body.get(), | |
77 resource_context); | |
78 } | |
79 | |
80 mojom::URLLoaderFactoryPtr url_loader_factory_ptr; | |
81 if (service_worker_navigation_handle_core) { | |
82 RequestContextFrameType frame_type = | |
83 request_info->is_main_frame ? REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL | |
84 : REQUEST_CONTEXT_FRAME_TYPE_NESTED; | |
85 | |
86 storage::BlobStorageContext* blob_storage_context = GetBlobStorageContext( | |
87 GetChromeBlobStorageContextForResourceContext(resource_context)); | |
88 url_loader_factory_ptr = | |
89 ServiceWorkerRequestHandler::InitializeForNavigationNetworkService( | |
90 *resource_request, resource_context, | |
91 service_worker_navigation_handle_core, blob_storage_context, | |
92 request_info->begin_params.skip_service_worker, resource_type, | |
93 request_info->begin_params.request_context_type, frame_type, | |
94 request_info->are_ancestors_secure, | |
95 request_info->common_params.post_data, web_contents_getter); | |
96 } | |
97 | |
98 // If we haven't gotten one from the above, then use the one the UI thread | |
99 // gave us, or otherwise fallback to the default. | |
100 mojom::URLLoaderFactory* factory; | |
101 if (url_loader_factory_ptr) { | |
102 factory = url_loader_factory_ptr.get(); | |
103 } else { | |
104 if (factory_from_ui.is_valid()) { | |
105 url_loader_factory_ptr.Bind(std::move(factory_from_ui)); | |
106 factory = url_loader_factory_ptr.get(); | |
107 } else { | |
108 if (appcache_handle_core) { | |
109 factory = url_loader_factory_getter->GetAppCacheFactory()->get(); | |
110 } else { | |
111 factory = url_loader_factory_getter->GetNetworkFactory()->get(); | |
112 } | |
113 } | |
114 } | |
115 | |
116 factory->CreateLoaderAndStart( | |
117 std::move(url_loader_request), 0 /* routing_id? */, 0 /* request_id? */, | |
118 mojom::kURLLoadOptionSendSSLInfo, *resource_request, | |
119 std::move(url_loader_client_to_pass)); | |
120 } | |
121 | |
122 } // namespace | 58 } // namespace |
123 | 59 |
| 60 // Kept around during the lifetime of the navigation request, and is |
| 61 // responsible for dispatching a ResourceRequest to the appropriate |
| 62 // URLLoaderFactory. In order to get the right URLLoaderFactory it |
| 63 // builds a vector of URLLoaderRequestHandler's and successively calls |
| 64 // MaybeCreateLoaderFactory on each until the request is successfully |
| 65 // handled. The same sequence may be performed multiple times when |
| 66 // redirects happen. |
| 67 class NavigationURLLoaderNetworkService::URLLoaderRequestController { |
| 68 public: |
| 69 URLLoaderRequestController(std::unique_ptr<ResourceRequest> resource_request, |
| 70 ResourceContext* resource_context) |
| 71 : resource_request_(std::move(resource_request)), |
| 72 resource_context_(resource_context), |
| 73 network_factory_(nullptr) {} |
| 74 |
| 75 virtual ~URLLoaderRequestController() { |
| 76 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 77 } |
| 78 |
| 79 void Start( |
| 80 ServiceWorkerNavigationHandleCore* service_worker_navigation_handle_core, |
| 81 AppCacheNavigationHandleCore* appcache_handle_core, |
| 82 std::unique_ptr<NavigationRequestInfo> request_info, |
| 83 mojom::URLLoaderFactoryPtrInfo factory_for_webui, |
| 84 scoped_refptr<URLLoaderFactoryGetter> url_loader_factory_getter, |
| 85 const base::Callback<WebContents*(void)>& web_contents_getter, |
| 86 mojom::URLLoaderAssociatedRequest url_loader_request, |
| 87 mojom::URLLoaderClientPtr url_loader_client_ptr, |
| 88 std::unique_ptr<service_manager::Connector> connector) { |
| 89 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 90 const ResourceType resource_type = request_info->is_main_frame |
| 91 ? RESOURCE_TYPE_MAIN_FRAME |
| 92 : RESOURCE_TYPE_SUB_FRAME; |
| 93 |
| 94 if (resource_request_->request_body) { |
| 95 AttachRequestBodyBlobDataHandles(resource_request_->request_body.get(), |
| 96 resource_context_); |
| 97 } |
| 98 |
| 99 // Requests to WebUI scheme won't get redirected to/from other schemes |
| 100 // or be intercepted, so we just let it go here. |
| 101 if (factory_for_webui.is_valid()) { |
| 102 mojom::URLLoaderFactoryPtr factory_ptr; |
| 103 factory_ptr.Bind(std::move(factory_for_webui)); |
| 104 factory_ptr->CreateLoaderAndStart( |
| 105 std::move(url_loader_request), 0 /* routing_id? */, |
| 106 0 /* request_id? */, mojom::kURLLoadOptionSendSSLInfo, |
| 107 *resource_request_, std::move(url_loader_client_ptr)); |
| 108 return; |
| 109 } |
| 110 |
| 111 DCHECK(handlers_.empty()); |
| 112 if (service_worker_navigation_handle_core) { |
| 113 RequestContextFrameType frame_type = |
| 114 request_info->is_main_frame ? REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL |
| 115 : REQUEST_CONTEXT_FRAME_TYPE_NESTED; |
| 116 |
| 117 storage::BlobStorageContext* blob_storage_context = GetBlobStorageContext( |
| 118 GetChromeBlobStorageContextForResourceContext(resource_context_)); |
| 119 std::unique_ptr<URLLoaderRequestHandler> service_worker_handler = |
| 120 ServiceWorkerRequestHandler::InitializeForNavigationNetworkService( |
| 121 *resource_request_, resource_context_, |
| 122 service_worker_navigation_handle_core, blob_storage_context, |
| 123 request_info->begin_params.skip_service_worker, resource_type, |
| 124 request_info->begin_params.request_context_type, frame_type, |
| 125 request_info->are_ancestors_secure, |
| 126 request_info->common_params.post_data, web_contents_getter); |
| 127 if (service_worker_handler) |
| 128 handlers_.push_back(std::move(service_worker_handler)); |
| 129 } |
| 130 |
| 131 if (appcache_handle_core) { |
| 132 // TODO: add appcache code here. |
| 133 } |
| 134 |
| 135 DCHECK(!network_factory_); |
| 136 network_factory_ = url_loader_factory_getter->GetNetworkFactory()->get(); |
| 137 |
| 138 Restart(std::move(url_loader_request), std::move(url_loader_client_ptr)); |
| 139 } |
| 140 |
| 141 // This could be called multiple times. |
| 142 void Restart(mojom::URLLoaderAssociatedRequest url_loader_request, |
| 143 mojom::URLLoaderClientPtr url_loader_client_ptr) { |
| 144 url_loader_request_ = std::move(url_loader_request); |
| 145 url_loader_client_ptr_ = std::move(url_loader_client_ptr); |
| 146 handler_index_ = 0; |
| 147 MaybeStartLoader(nullptr); |
| 148 } |
| 149 |
| 150 void MaybeStartLoader(mojom::URLLoaderFactory* factory) { |
| 151 DCHECK(url_loader_client_ptr_.is_bound()); |
| 152 |
| 153 if (factory) { |
| 154 factory->CreateLoaderAndStart( |
| 155 std::move(url_loader_request_), 0 /* routing_id? */, |
| 156 0 /* request_id? */, mojom::kURLLoadOptionSendSSLInfo, |
| 157 *resource_request_, std::move(url_loader_client_ptr_)); |
| 158 return; |
| 159 } |
| 160 |
| 161 if (handler_index_ < handlers_.size()) { |
| 162 handlers_[handler_index_++]->MaybeCreateLoaderFactory( |
| 163 *resource_request_, resource_context_, |
| 164 base::BindOnce(&URLLoaderRequestController::MaybeStartLoader, |
| 165 base::Unretained(this))); |
| 166 return; |
| 167 } |
| 168 |
| 169 DCHECK_EQ(handlers_.size(), handler_index_); |
| 170 DCHECK(network_factory_ != nullptr); |
| 171 MaybeStartLoader(network_factory_); |
| 172 } |
| 173 |
| 174 private: |
| 175 std::vector<std::unique_ptr<URLLoaderRequestHandler>> handlers_; |
| 176 size_t handler_index_ = 0; |
| 177 |
| 178 std::unique_ptr<ResourceRequest> resource_request_; |
| 179 ResourceContext* resource_context_; |
| 180 |
| 181 // The factory for doing a vanilla network request, called when |
| 182 // any of other request handlers handle the given request. |
| 183 mojom::URLLoaderFactory* network_factory_; |
| 184 |
| 185 // Kept around until we create a loader. |
| 186 mojom::URLLoaderAssociatedRequest url_loader_request_; |
| 187 mojom::URLLoaderClientPtr url_loader_client_ptr_; |
| 188 |
| 189 DISALLOW_COPY_AND_ASSIGN(URLLoaderRequestController); |
| 190 }; |
| 191 |
124 NavigationURLLoaderNetworkService::NavigationURLLoaderNetworkService( | 192 NavigationURLLoaderNetworkService::NavigationURLLoaderNetworkService( |
125 ResourceContext* resource_context, | 193 ResourceContext* resource_context, |
126 StoragePartition* storage_partition, | 194 StoragePartition* storage_partition, |
127 std::unique_ptr<NavigationRequestInfo> request_info, | 195 std::unique_ptr<NavigationRequestInfo> request_info, |
128 std::unique_ptr<NavigationUIData> navigation_ui_data, | 196 std::unique_ptr<NavigationUIData> navigation_ui_data, |
129 ServiceWorkerNavigationHandle* service_worker_navigation_handle, | 197 ServiceWorkerNavigationHandle* service_worker_navigation_handle, |
130 AppCacheNavigationHandle* appcache_handle, | 198 AppCacheNavigationHandle* appcache_handle, |
131 NavigationURLLoaderDelegate* delegate) | 199 NavigationURLLoaderDelegate* delegate) |
132 : delegate_(delegate), | 200 : delegate_(delegate), binding_(this) { |
133 binding_(this), | |
134 request_info_(std::move(request_info)) { | |
135 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 201 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
136 | 202 |
137 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( | 203 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( |
138 "navigation", "Navigation timeToResponseStarted", this, | 204 "navigation", "Navigation timeToResponseStarted", this, |
139 request_info_->common_params.navigation_start, "FrameTreeNode id", | 205 request_info->common_params.navigation_start, "FrameTreeNode id", |
140 request_info_->frame_tree_node_id); | 206 request_info->frame_tree_node_id); |
141 | 207 |
142 // TODO(scottmg): Port over stuff from RDHI::BeginNavigationRequest() here. | 208 // TODO(scottmg): Port over stuff from RDHI::BeginNavigationRequest() here. |
143 auto new_request = base::MakeUnique<ResourceRequest>(); | 209 auto new_request = base::MakeUnique<ResourceRequest>(); |
144 | 210 |
145 new_request->method = request_info_->common_params.method; | 211 new_request->method = request_info->common_params.method; |
146 new_request->url = request_info_->common_params.url; | 212 new_request->url = request_info->common_params.url; |
147 new_request->first_party_for_cookies = request_info_->first_party_for_cookies; | 213 new_request->first_party_for_cookies = request_info->first_party_for_cookies; |
148 new_request->priority = net::HIGHEST; | 214 new_request->priority = net::HIGHEST; |
149 | 215 |
150 // The code below to set fields like request_initiator, referrer, etc has | 216 // The code below to set fields like request_initiator, referrer, etc has |
151 // been copied from ResourceDispatcherHostImpl. We did not refactor the | 217 // been copied from ResourceDispatcherHostImpl. We did not refactor the |
152 // common code into a function, because RDHI uses accessor functions on the | 218 // common code into a function, because RDHI uses accessor functions on the |
153 // URLRequest class to set these fields. whereas we use ResourceRequest here. | 219 // URLRequest class to set these fields. whereas we use ResourceRequest here. |
154 new_request->request_initiator = request_info_->begin_params.initiator_origin; | 220 new_request->request_initiator = request_info->begin_params.initiator_origin; |
155 new_request->referrer = request_info_->common_params.referrer.url; | 221 new_request->referrer = request_info->common_params.referrer.url; |
156 new_request->referrer_policy = request_info_->common_params.referrer.policy; | 222 new_request->referrer_policy = request_info->common_params.referrer.policy; |
157 new_request->headers = request_info_->begin_params.headers; | 223 new_request->headers = request_info->begin_params.headers; |
158 | 224 |
159 int load_flags = request_info_->begin_params.load_flags; | 225 int load_flags = request_info->begin_params.load_flags; |
160 load_flags |= net::LOAD_VERIFY_EV_CERT; | 226 load_flags |= net::LOAD_VERIFY_EV_CERT; |
161 if (request_info_->is_main_frame) | 227 if (request_info->is_main_frame) |
162 load_flags |= net::LOAD_MAIN_FRAME_DEPRECATED; | 228 load_flags |= net::LOAD_MAIN_FRAME_DEPRECATED; |
163 | 229 |
164 // Sync loads should have maximum priority and should be the only | 230 // Sync loads should have maximum priority and should be the only |
165 // requests that have the ignore limits flag set. | 231 // requests that have the ignore limits flag set. |
166 DCHECK(!(load_flags & net::LOAD_IGNORE_LIMITS)); | 232 DCHECK(!(load_flags & net::LOAD_IGNORE_LIMITS)); |
167 | 233 |
168 new_request->load_flags = load_flags; | 234 new_request->load_flags = load_flags; |
169 | 235 |
170 new_request->request_body = request_info_->common_params.post_data.get(); | 236 new_request->request_body = request_info->common_params.post_data.get(); |
| 237 |
| 238 int frame_tree_node_id = request_info->frame_tree_node_id; |
171 | 239 |
172 mojom::URLLoaderAssociatedRequest loader_associated_request = | 240 mojom::URLLoaderAssociatedRequest loader_associated_request = |
173 mojo::MakeRequest(&url_loader_associated_ptr_); | 241 mojo::MakeRequest(&url_loader_associated_ptr_); |
174 mojom::URLLoaderClientPtr url_loader_client_ptr_to_pass; | 242 mojom::URLLoaderClientPtr url_loader_client_ptr_to_pass; |
175 binding_.Bind(mojo::MakeRequest(&url_loader_client_ptr_to_pass)); | 243 binding_.Bind(mojo::MakeRequest(&url_loader_client_ptr_to_pass)); |
176 | 244 |
177 // Check if a web UI scheme wants to handle this request. | 245 // Check if a web UI scheme wants to handle this request. |
178 mojom::URLLoaderFactoryPtrInfo factory_ptr_info; | 246 mojom::URLLoaderFactoryPtrInfo factory_for_webui; |
179 | |
180 const auto& schemes = URLDataManagerBackend::GetWebUISchemes(); | 247 const auto& schemes = URLDataManagerBackend::GetWebUISchemes(); |
181 if (std::find(schemes.begin(), schemes.end(), new_request->url.scheme()) != | 248 if (std::find(schemes.begin(), schemes.end(), new_request->url.scheme()) != |
182 schemes.end()) { | 249 schemes.end()) { |
183 FrameTreeNode* frame_tree_node = | 250 FrameTreeNode* frame_tree_node = |
184 FrameTreeNode::GloballyFindByID(request_info_->frame_tree_node_id); | 251 FrameTreeNode::GloballyFindByID(frame_tree_node_id); |
185 factory_ptr_info = GetWebUIURLLoader(frame_tree_node).PassInterface(); | 252 factory_for_webui = GetWebUIURLLoader(frame_tree_node).PassInterface(); |
186 } | 253 } |
187 | 254 |
188 g_next_request_id--; | 255 g_next_request_id--; |
189 | 256 |
| 257 DCHECK(!request_controller_); |
| 258 request_controller_ = base::MakeUnique<URLLoaderRequestController>( |
| 259 std::move(new_request), resource_context); |
190 BrowserThread::PostTask( | 260 BrowserThread::PostTask( |
191 BrowserThread::IO, FROM_HERE, | 261 BrowserThread::IO, FROM_HERE, |
192 base::Bind(&PrepareNavigationStartOnIO, | 262 base::Bind( |
193 base::Passed(std::move(new_request)), resource_context, | 263 &URLLoaderRequestController::Start, |
194 service_worker_navigation_handle | 264 base::Unretained(request_controller_.get()), |
195 ? service_worker_navigation_handle->core() | 265 service_worker_navigation_handle |
196 : nullptr, | 266 ? service_worker_navigation_handle->core() |
197 appcache_handle ? appcache_handle->core() : nullptr, | 267 : nullptr, |
198 request_info_.get(), base::Passed(std::move(factory_ptr_info)), | 268 appcache_handle ? appcache_handle->core() : nullptr, |
199 static_cast<StoragePartitionImpl*>(storage_partition) | 269 base::Passed(std::move(request_info)), |
200 ->url_loader_factory_getter(), | 270 base::Passed(std::move(factory_for_webui)), |
201 base::Bind(&GetWebContentsFromFrameTreeNodeID, | 271 static_cast<StoragePartitionImpl*>(storage_partition) |
202 request_info_->frame_tree_node_id), | 272 ->url_loader_factory_getter(), |
203 base::Passed(std::move(loader_associated_request)), | 273 base::Bind(&GetWebContentsFromFrameTreeNodeID, frame_tree_node_id), |
204 base::Passed(std::move(url_loader_client_ptr_to_pass)), | 274 base::Passed(std::move(loader_associated_request)), |
205 base::Passed(ServiceManagerConnection::GetForProcess() | 275 base::Passed(std::move(url_loader_client_ptr_to_pass)), |
206 ->GetConnector() | 276 base::Passed(ServiceManagerConnection::GetForProcess() |
207 ->Clone()))); | 277 ->GetConnector() |
| 278 ->Clone()))); |
208 } | 279 } |
209 | 280 |
210 NavigationURLLoaderNetworkService::~NavigationURLLoaderNetworkService() {} | 281 NavigationURLLoaderNetworkService::~NavigationURLLoaderNetworkService() { |
| 282 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, |
| 283 request_controller_.release()); |
| 284 } |
211 | 285 |
212 void NavigationURLLoaderNetworkService::FollowRedirect() { | 286 void NavigationURLLoaderNetworkService::FollowRedirect() { |
213 url_loader_associated_ptr_->FollowRedirect(); | 287 url_loader_associated_ptr_->FollowRedirect(); |
214 } | 288 } |
215 | 289 |
216 void NavigationURLLoaderNetworkService::ProceedWithResponse() {} | 290 void NavigationURLLoaderNetworkService::ProceedWithResponse() {} |
217 | 291 |
218 void NavigationURLLoaderNetworkService::OnReceiveResponse( | 292 void NavigationURLLoaderNetworkService::OnReceiveResponse( |
219 const ResourceResponseHead& head, | 293 const ResourceResponseHead& head, |
220 const base::Optional<net::SSLInfo>& ssl_info, | 294 const base::Optional<net::SSLInfo>& ssl_info, |
221 mojom::DownloadedTempFilePtr downloaded_file) { | 295 mojom::DownloadedTempFilePtr downloaded_file) { |
222 // TODO(scottmg): This needs to do more of what | 296 // TODO(scottmg): This needs to do more of what |
223 // NavigationResourceHandler::OnReponseStarted() does. Or maybe in | 297 // NavigationResourceHandler::OnReponseStarted() does. Or maybe in |
224 // OnStartLoadingResponseBody(). | 298 // OnStartLoadingResponseBody(). |
225 if (ssl_info && ssl_info->cert) | 299 if (ssl_info && ssl_info->cert) |
226 NavigationResourceHandler::GetSSLStatusForRequest(*ssl_info, &ssl_status_); | 300 NavigationResourceHandler::GetSSLStatusForRequest(*ssl_info, &ssl_status_); |
227 response_ = base::MakeRefCounted<ResourceResponse>(); | 301 response_ = base::MakeRefCounted<ResourceResponse>(); |
228 response_->head = head; | 302 response_->head = head; |
229 } | 303 } |
230 | 304 |
231 void NavigationURLLoaderNetworkService::OnReceiveRedirect( | 305 void NavigationURLLoaderNetworkService::OnReceiveRedirect( |
232 const net::RedirectInfo& redirect_info, | 306 const net::RedirectInfo& redirect_info, |
233 const ResourceResponseHead& head) { | 307 const ResourceResponseHead& head) { |
234 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 308 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 309 // TODO(kinuko): Perform the necessary check and call |
| 310 // URLLoaderRequestController::Restart with the new URL?? |
235 scoped_refptr<ResourceResponse> response(new ResourceResponse()); | 311 scoped_refptr<ResourceResponse> response(new ResourceResponse()); |
236 response->head = head; | 312 response->head = head; |
237 delegate_->OnRequestRedirected(redirect_info, response); | 313 delegate_->OnRequestRedirected(redirect_info, response); |
238 } | 314 } |
239 | 315 |
240 void NavigationURLLoaderNetworkService::OnDataDownloaded( | 316 void NavigationURLLoaderNetworkService::OnDataDownloaded( |
241 int64_t data_length, | 317 int64_t data_length, |
242 int64_t encoded_length) {} | 318 int64_t encoded_length) {} |
243 | 319 |
244 void NavigationURLLoaderNetworkService::OnUploadProgress( | 320 void NavigationURLLoaderNetworkService::OnUploadProgress( |
(...skipping 30 matching lines...) Expand all Loading... |
275 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", | 351 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", |
276 this, "&NavigationURLLoaderNetworkService", this, | 352 this, "&NavigationURLLoaderNetworkService", this, |
277 "success", false); | 353 "success", false); |
278 | 354 |
279 delegate_->OnRequestFailed(completion_status.exists_in_cache, | 355 delegate_->OnRequestFailed(completion_status.exists_in_cache, |
280 completion_status.error_code); | 356 completion_status.error_code); |
281 } | 357 } |
282 } | 358 } |
283 | 359 |
284 } // namespace content | 360 } // namespace content |
OLD | NEW |