| 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 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 blink::WebURLResponse::WebSecurityDetails webSecurityDetails( | 282 blink::WebURLResponse::WebSecurityDetails webSecurityDetails( |
| 283 WebString::fromUTF8(protocol), WebString::fromUTF8(key_exchange), | 283 WebString::fromUTF8(protocol), WebString::fromUTF8(key_exchange), |
| 284 WebString::fromUTF8(cipher), WebString::fromUTF8(mac), | 284 WebString::fromUTF8(cipher), WebString::fromUTF8(mac), |
| 285 ssl_status.cert_id, num_unknown_scts, num_invalid_scts, num_valid_scts); | 285 ssl_status.cert_id, num_unknown_scts, num_invalid_scts, num_valid_scts); |
| 286 | 286 |
| 287 response->setSecurityDetails(webSecurityDetails); | 287 response->setSecurityDetails(webSecurityDetails); |
| 288 } | 288 } |
| 289 | 289 |
| 290 } // namespace | 290 } // namespace |
| 291 | 291 |
| 292 StreamOverrideParameters::StreamOverrideParameters() : browser_request_id(-1) {} |
| 293 |
| 294 StreamOverrideParameters::~StreamOverrideParameters() {} |
| 295 |
| 292 // This inner class exists since the WebURLLoader may be deleted while inside a | 296 // This inner class exists since the WebURLLoader may be deleted while inside a |
| 293 // call to WebURLLoaderClient. Refcounting is to keep the context from being | 297 // call to WebURLLoaderClient. Refcounting is to keep the context from being |
| 294 // deleted if it may have work to do after calling into the client. | 298 // deleted if it may have work to do after calling into the client. |
| 295 class WebURLLoaderImpl::Context : public base::RefCounted<Context> { | 299 class WebURLLoaderImpl::Context : public base::RefCounted<Context> { |
| 296 public: | 300 public: |
| 297 using ReceivedData = RequestPeer::ReceivedData; | 301 using ReceivedData = RequestPeer::ReceivedData; |
| 298 | 302 |
| 299 Context(WebURLLoaderImpl* loader, | 303 Context(WebURLLoaderImpl* loader, |
| 300 ResourceDispatcher* resource_dispatcher, | 304 ResourceDispatcher* resource_dispatcher, |
| 301 scoped_ptr<blink::WebTaskRunner> task_runner); | 305 scoped_ptr<blink::WebTaskRunner> task_runner); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 GetRequestContextTypeForWebURLRequest(request); | 539 GetRequestContextTypeForWebURLRequest(request); |
| 536 request_info.fetch_frame_type = | 540 request_info.fetch_frame_type = |
| 537 GetRequestContextFrameTypeForWebURLRequest(request); | 541 GetRequestContextFrameTypeForWebURLRequest(request); |
| 538 request_info.extra_data = request.getExtraData(); | 542 request_info.extra_data = request.getExtraData(); |
| 539 request_info.report_raw_headers = request.reportRawHeaders(); | 543 request_info.report_raw_headers = request.reportRawHeaders(); |
| 540 request_info.loading_web_task_runner.reset(web_task_runner_->clone()); | 544 request_info.loading_web_task_runner.reset(web_task_runner_->clone()); |
| 541 | 545 |
| 542 scoped_refptr<ResourceRequestBody> request_body = | 546 scoped_refptr<ResourceRequestBody> request_body = |
| 543 GetRequestBodyForWebURLRequest(request).get(); | 547 GetRequestBodyForWebURLRequest(request).get(); |
| 544 | 548 |
| 545 // PlzNavigate: during navigation, the renderer should request a stream which | |
| 546 // contains the body of the response. The network request has already been | |
| 547 // made by the browser. | |
| 548 if (stream_override_.get()) { | |
| 549 CHECK(IsBrowserSideNavigationEnabled()); | |
| 550 DCHECK(!sync_load_response); | |
| 551 DCHECK_NE(WebURLRequest::FrameTypeNone, request.getFrameType()); | |
| 552 request_info.resource_body_stream_url = stream_override_->stream_url; | |
| 553 } | |
| 554 | |
| 555 if (sync_load_response) { | 549 if (sync_load_response) { |
| 550 DCHECK(!stream_override_); |
| 556 resource_dispatcher_->StartSync( | 551 resource_dispatcher_->StartSync( |
| 557 request_info, request_body.get(), sync_load_response); | 552 request_info, request_body.get(), sync_load_response); |
| 558 return; | 553 return; |
| 559 } | 554 } |
| 560 | 555 |
| 556 // PlzNavigate: during navigation, the browser should have sent a consumer |
| 557 // handle for a Mojo data pipe along with the respective browser generated |
| 558 // request id. The network request has already been made by the browser. |
| 559 mojo::ScopedDataPipeConsumerHandle mojo_data_pipe_handle; |
| 560 int browser_request_id = -1; |
| 561 if (stream_override_) { |
| 562 CHECK(IsBrowserSideNavigationEnabled()); |
| 563 DCHECK(!sync_load_response); |
| 564 DCHECK_NE(WebURLRequest::FrameTypeNone, request.getFrameType()); |
| 565 DCHECK(stream_override_->mojo_handle.is_valid()); |
| 566 DCHECK_LT(stream_override_->browser_request_id, -1); |
| 567 mojo_data_pipe_handle = std::move(stream_override_->mojo_handle); |
| 568 browser_request_id = stream_override_->browser_request_id; |
| 569 } |
| 570 |
| 561 request_id_ = resource_dispatcher_->StartAsync( | 571 request_id_ = resource_dispatcher_->StartAsync( |
| 562 request_info, request_body.get(), | 572 request_info, request_body.get(), |
| 563 make_scoped_ptr(new WebURLLoaderImpl::RequestPeerImpl(this))); | 573 make_scoped_ptr(new WebURLLoaderImpl::RequestPeerImpl(this)), |
| 574 std::move(mojo_data_pipe_handle), browser_request_id); |
| 564 } | 575 } |
| 565 | 576 |
| 566 void WebURLLoaderImpl::Context::SetWebTaskRunner( | 577 void WebURLLoaderImpl::Context::SetWebTaskRunner( |
| 567 scoped_ptr<blink::WebTaskRunner> web_task_runner) { | 578 scoped_ptr<blink::WebTaskRunner> web_task_runner) { |
| 568 web_task_runner_ = std::move(web_task_runner); | 579 web_task_runner_ = std::move(web_task_runner); |
| 569 } | 580 } |
| 570 | 581 |
| 571 void WebURLLoaderImpl::Context::OnUploadProgress(uint64_t position, | 582 void WebURLLoaderImpl::Context::OnUploadProgress(uint64_t position, |
| 572 uint64_t size) { | 583 uint64_t size) { |
| 573 if (client_) | 584 if (client_) |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 response->clearHTTPHeaderField(webStringName); | 1183 response->clearHTTPHeaderField(webStringName); |
| 1173 while (response_headers->EnumerateHeader(&iterator, name, &value)) { | 1184 while (response_headers->EnumerateHeader(&iterator, name, &value)) { |
| 1174 response->addHTTPHeaderField(webStringName, | 1185 response->addHTTPHeaderField(webStringName, |
| 1175 WebString::fromLatin1(value)); | 1186 WebString::fromLatin1(value)); |
| 1176 } | 1187 } |
| 1177 } | 1188 } |
| 1178 return true; | 1189 return true; |
| 1179 } | 1190 } |
| 1180 | 1191 |
| 1181 } // namespace content | 1192 } // namespace content |
| OLD | NEW |