| 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 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 response.initialize(); | 577 response.initialize(); |
| 578 PopulateURLResponse(request_.url(), info, &response, | 578 PopulateURLResponse(request_.url(), info, &response, |
| 579 request_.reportRawHeaders()); | 579 request_.reportRawHeaders()); |
| 580 | 580 |
| 581 WebURLRequest new_request; | 581 WebURLRequest new_request; |
| 582 new_request.initialize(); | 582 new_request.initialize(); |
| 583 PopulateURLRequestForRedirect(request_, redirect_info, referrer_policy_, | 583 PopulateURLRequestForRedirect(request_, redirect_info, referrer_policy_, |
| 584 !info.was_fetched_via_service_worker, | 584 !info.was_fetched_via_service_worker, |
| 585 &new_request); | 585 &new_request); |
| 586 | 586 |
| 587 client_->willFollowRedirect(loader_, new_request, response); | 587 client_->willFollowRedirect(loader_, new_request, response, |
| 588 info.encoded_data_length); |
| 588 request_ = new_request; | 589 request_ = new_request; |
| 589 | 590 |
| 590 // Only follow the redirect if WebKit left the URL unmodified. | 591 // Only follow the redirect if WebKit left the URL unmodified. |
| 591 if (redirect_info.new_url == GURL(new_request.url())) { | 592 if (redirect_info.new_url == GURL(new_request.url())) { |
| 592 // First-party cookie logic moved from DocumentLoader in Blink to | 593 // First-party cookie logic moved from DocumentLoader in Blink to |
| 593 // net::URLRequest in the browser. Assert that Blink didn't try to change it | 594 // net::URLRequest in the browser. Assert that Blink didn't try to change it |
| 594 // to something else. | 595 // to something else. |
| 595 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(), | 596 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(), |
| 596 request_.firstPartyForCookies().string().utf8()); | 597 request_.firstPartyForCookies().string().utf8()); |
| 597 return true; | 598 return true; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 "loading", "WebURLLoaderImpl::Context::OnReceivedData", | 708 "loading", "WebURLLoaderImpl::Context::OnReceivedData", |
| 708 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); | 709 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); |
| 709 | 710 |
| 710 if (ftp_listing_delegate_) { | 711 if (ftp_listing_delegate_) { |
| 711 // The FTP listing delegate will make the appropriate calls to | 712 // The FTP listing delegate will make the appropriate calls to |
| 712 // client_->didReceiveData and client_->didReceiveResponse. | 713 // client_->didReceiveData and client_->didReceiveResponse. |
| 713 ftp_listing_delegate_->OnReceivedData(payload, data_length); | 714 ftp_listing_delegate_->OnReceivedData(payload, data_length); |
| 714 } else { | 715 } else { |
| 715 // We dispatch the data even when |useStreamOnResponse()| is set, in order | 716 // We dispatch the data even when |useStreamOnResponse()| is set, in order |
| 716 // to make Devtools work. | 717 // to make Devtools work. |
| 717 client_->didReceiveData(loader_, payload, data_length, encoded_data_length); | 718 client_->didReceiveData(loader_, payload, data_length, encoded_data_length, |
| 719 data->encoded_body_length()); |
| 718 | 720 |
| 719 if (request_.useStreamOnResponse()) { | 721 if (request_.useStreamOnResponse()) { |
| 720 // We don't support ftp_listening_delegate_ for now. | 722 // We don't support ftp_listening_delegate_ for now. |
| 721 // TODO(yhirano): Support ftp listening. | 723 // TODO(yhirano): Support ftp listening. |
| 722 body_stream_writer_->AddData(std::move(data)); | 724 body_stream_writer_->AddData(std::move(data)); |
| 723 } | 725 } |
| 724 } | 726 } |
| 725 } | 727 } |
| 726 | 728 |
| 727 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata( | 729 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata( |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 return; | 848 return; |
| 847 } | 849 } |
| 848 | 850 |
| 849 ResourceResponseInfo info; | 851 ResourceResponseInfo info; |
| 850 std::string data; | 852 std::string data; |
| 851 | 853 |
| 852 int error_code = GetInfoFromDataURL(request_.url(), &info, &data); | 854 int error_code = GetInfoFromDataURL(request_.url(), &info, &data); |
| 853 | 855 |
| 854 if (error_code == net::OK) { | 856 if (error_code == net::OK) { |
| 855 OnReceivedResponse(info); | 857 OnReceivedResponse(info); |
| 856 if (!data.empty()) | 858 auto size = data.size(); |
| 859 if (size != 0) |
| 857 OnReceivedData( | 860 OnReceivedData( |
| 858 base::WrapUnique(new FixedReceivedData(data.data(), data.size(), 0))); | 861 base::WrapUnique(new FixedReceivedData(data.data(), size, 0, size))); |
| 859 } | 862 } |
| 860 | 863 |
| 861 OnCompletedRequest(error_code, false, false, info.security_info, | 864 OnCompletedRequest(error_code, false, false, info.security_info, |
| 862 base::TimeTicks::Now(), 0); | 865 base::TimeTicks::Now(), 0); |
| 863 } | 866 } |
| 864 | 867 |
| 865 // WebURLLoaderImpl::RequestPeerImpl ------------------------------------------ | 868 // WebURLLoaderImpl::RequestPeerImpl ------------------------------------------ |
| 866 | 869 |
| 867 WebURLLoaderImpl::RequestPeerImpl::RequestPeerImpl(Context* context) | 870 WebURLLoaderImpl::RequestPeerImpl::RequestPeerImpl(Context* context) |
| 868 : context_(context) {} | 871 : context_(context) {} |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 response->clearHTTPHeaderField(webStringName); | 1201 response->clearHTTPHeaderField(webStringName); |
| 1199 while (response_headers->EnumerateHeader(&iterator, name, &value)) { | 1202 while (response_headers->EnumerateHeader(&iterator, name, &value)) { |
| 1200 response->addHTTPHeaderField(webStringName, | 1203 response->addHTTPHeaderField(webStringName, |
| 1201 WebString::fromLatin1(value)); | 1204 WebString::fromLatin1(value)); |
| 1202 } | 1205 } |
| 1203 } | 1206 } |
| 1204 return true; | 1207 return true; |
| 1205 } | 1208 } |
| 1206 | 1209 |
| 1207 } // namespace content | 1210 } // namespace content |
| OLD | NEW |