Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: content/child/web_url_loader_impl.cc

Issue 2105713002: Render process changes for ResourceTiming sizes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@resource_timing_sizes_browser_process
Patch Set: Initialise encoded_body_length for sync XHR to data: URLs Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/child/sync_load_response.h ('k') | content/child/web_url_loader_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 url, &mime_type, &charset, data, headers.get()); 177 url, &mime_type, &charset, data, headers.get());
178 if (result != net::OK) 178 if (result != net::OK)
179 return result; 179 return result;
180 180
181 info->headers = headers; 181 info->headers = headers;
182 info->mime_type.swap(mime_type); 182 info->mime_type.swap(mime_type);
183 info->charset.swap(charset); 183 info->charset.swap(charset);
184 info->security_info.clear(); 184 info->security_info.clear();
185 info->content_length = data->length(); 185 info->content_length = data->length();
186 info->encoded_data_length = 0; 186 info->encoded_data_length = 0;
187 info->encoded_body_length = 0;
187 188
188 return net::OK; 189 return net::OK;
189 } 190 }
190 191
191 // Convert a net::SignedCertificateTimestampAndStatus object to a 192 // Convert a net::SignedCertificateTimestampAndStatus object to a
192 // blink::WebURLResponse::SignedCertificateTimestamp object. 193 // blink::WebURLResponse::SignedCertificateTimestamp object.
193 blink::WebURLResponse::SignedCertificateTimestamp NetSCTToBlinkSCT( 194 blink::WebURLResponse::SignedCertificateTimestamp NetSCTToBlinkSCT(
194 const net::SignedCertificateTimestampAndStatus& sct_and_status) { 195 const net::SignedCertificateTimestampAndStatus& sct_and_status) {
195 return blink::WebURLResponse::SignedCertificateTimestamp( 196 return blink::WebURLResponse::SignedCertificateTimestamp(
196 WebString::fromUTF8(net::ct::StatusToString(sct_and_status.status)), 197 WebString::fromUTF8(net::ct::StatusToString(sct_and_status.status)),
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 request_.reportRawHeaders()); 609 request_.reportRawHeaders());
609 610
610 WebURLRequest new_request; 611 WebURLRequest new_request;
611 PopulateURLRequestForRedirect( 612 PopulateURLRequestForRedirect(
612 request_, redirect_info, referrer_policy_, 613 request_, redirect_info, referrer_policy_,
613 info.was_fetched_via_service_worker 614 info.was_fetched_via_service_worker
614 ? blink::WebURLRequest::SkipServiceWorker::None 615 ? blink::WebURLRequest::SkipServiceWorker::None
615 : blink::WebURLRequest::SkipServiceWorker::All, 616 : blink::WebURLRequest::SkipServiceWorker::All,
616 &new_request); 617 &new_request);
617 618
618 client_->willFollowRedirect(loader_, new_request, response); 619 client_->willFollowRedirect(loader_, new_request, response,
620 info.encoded_data_length);
619 request_ = new_request; 621 request_ = new_request;
620 622
621 // Only follow the redirect if WebKit left the URL unmodified. 623 // Only follow the redirect if WebKit left the URL unmodified.
622 if (redirect_info.new_url == GURL(new_request.url())) { 624 if (redirect_info.new_url == GURL(new_request.url())) {
623 // First-party cookie logic moved from DocumentLoader in Blink to 625 // First-party cookie logic moved from DocumentLoader in Blink to
624 // net::URLRequest in the browser. Assert that Blink didn't try to change it 626 // net::URLRequest in the browser. Assert that Blink didn't try to change it
625 // to something else. 627 // to something else.
626 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(), 628 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(),
627 request_.firstPartyForCookies().string().utf8()); 629 request_.firstPartyForCookies().string().utf8());
628 return true; 630 return true;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 void WebURLLoaderImpl::Context::OnDownloadedData(int len, 724 void WebURLLoaderImpl::Context::OnDownloadedData(int len,
723 int encoded_data_length) { 725 int encoded_data_length) {
724 if (client_) 726 if (client_)
725 client_->didDownloadData(loader_, len, encoded_data_length); 727 client_->didDownloadData(loader_, len, encoded_data_length);
726 } 728 }
727 729
728 void WebURLLoaderImpl::Context::OnReceivedData( 730 void WebURLLoaderImpl::Context::OnReceivedData(
729 std::unique_ptr<ReceivedData> data) { 731 std::unique_ptr<ReceivedData> data) {
730 const char* payload = data->payload(); 732 const char* payload = data->payload();
731 int data_length = data->length(); 733 int data_length = data->length();
732 int encoded_data_length = data->encoded_length(); 734 int encoded_data_length = data->encoded_data_length();
733 if (!client_) 735 if (!client_)
734 return; 736 return;
735 737
736 TRACE_EVENT_WITH_FLOW0( 738 TRACE_EVENT_WITH_FLOW0(
737 "loading", "WebURLLoaderImpl::Context::OnReceivedData", 739 "loading", "WebURLLoaderImpl::Context::OnReceivedData",
738 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); 740 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT);
739 741
740 if (ftp_listing_delegate_) { 742 if (ftp_listing_delegate_) {
741 // The FTP listing delegate will make the appropriate calls to 743 // The FTP listing delegate will make the appropriate calls to
742 // client_->didReceiveData and client_->didReceiveResponse. 744 // client_->didReceiveData and client_->didReceiveResponse.
743 ftp_listing_delegate_->OnReceivedData(payload, data_length); 745 ftp_listing_delegate_->OnReceivedData(payload, data_length);
744 } else { 746 } else {
745 // We dispatch the data even when |useStreamOnResponse()| is set, in order 747 // We dispatch the data even when |useStreamOnResponse()| is set, in order
746 // to make Devtools work. 748 // to make Devtools work.
747 client_->didReceiveData(loader_, payload, data_length, encoded_data_length); 749 client_->didReceiveData(loader_, payload, data_length, encoded_data_length,
750 data->encoded_body_length());
748 751
749 if (request_.useStreamOnResponse()) { 752 if (request_.useStreamOnResponse()) {
750 // We don't support ftp_listening_delegate_ for now. 753 // We don't support ftp_listening_delegate_ for now.
751 // TODO(yhirano): Support ftp listening. 754 // TODO(yhirano): Support ftp listening.
752 body_stream_writer_->AddData(std::move(data)); 755 body_stream_writer_->AddData(std::move(data));
753 } 756 }
754 } 757 }
755 } 758 }
756 759
757 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata( 760 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata(
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 return; 879 return;
877 } 880 }
878 881
879 ResourceResponseInfo info; 882 ResourceResponseInfo info;
880 std::string data; 883 std::string data;
881 884
882 int error_code = GetInfoFromDataURL(request_.url(), &info, &data); 885 int error_code = GetInfoFromDataURL(request_.url(), &info, &data);
883 886
884 if (error_code == net::OK) { 887 if (error_code == net::OK) {
885 OnReceivedResponse(info); 888 OnReceivedResponse(info);
886 if (!data.empty()) 889 auto size = data.size();
890 if (size != 0)
887 OnReceivedData( 891 OnReceivedData(
888 base::WrapUnique(new FixedReceivedData(data.data(), data.size(), 0))); 892 base::WrapUnique(new FixedReceivedData(data.data(), size, 0, size)));
889 } 893 }
890 894
891 OnCompletedRequest(error_code, false, false, info.security_info, 895 OnCompletedRequest(error_code, false, false, info.security_info,
892 base::TimeTicks::Now(), 0); 896 base::TimeTicks::Now(), 0);
893 } 897 }
894 898
895 // WebURLLoaderImpl::RequestPeerImpl ------------------------------------------ 899 // WebURLLoaderImpl::RequestPeerImpl ------------------------------------------
896 900
897 WebURLLoaderImpl::RequestPeerImpl::RequestPeerImpl(Context* context) 901 WebURLLoaderImpl::RequestPeerImpl::RequestPeerImpl(Context* context)
898 : context_(context) {} 902 : context_(context) {}
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 if (error_code != net::OK) { 1147 if (error_code != net::OK) {
1144 response.setURL(final_url); 1148 response.setURL(final_url);
1145 error.domain = WebString::fromUTF8(net::kErrorDomain); 1149 error.domain = WebString::fromUTF8(net::kErrorDomain);
1146 error.reason = error_code; 1150 error.reason = error_code;
1147 error.unreachableURL = final_url; 1151 error.unreachableURL = final_url;
1148 return; 1152 return;
1149 } 1153 }
1150 1154
1151 PopulateURLResponse(final_url, sync_load_response, &response, 1155 PopulateURLResponse(final_url, sync_load_response, &response,
1152 request.reportRawHeaders()); 1156 request.reportRawHeaders());
1157 response.addToEncodedBodyLength(sync_load_response.encoded_body_length);
1158 response.addToDecodedBodyLength(sync_load_response.data.size());
1153 1159
1154 data.assign(sync_load_response.data.data(), 1160 data.assign(sync_load_response.data.data(), sync_load_response.data.size());
1155 sync_load_response.data.size());
1156 } 1161 }
1157 1162
1158 void WebURLLoaderImpl::loadAsynchronously(const WebURLRequest& request, 1163 void WebURLLoaderImpl::loadAsynchronously(const WebURLRequest& request,
1159 WebURLLoaderClient* client) { 1164 WebURLLoaderClient* client) {
1160 TRACE_EVENT_WITH_FLOW0("loading", "WebURLLoaderImpl::loadAsynchronously", 1165 TRACE_EVENT_WITH_FLOW0("loading", "WebURLLoaderImpl::loadAsynchronously",
1161 this, TRACE_EVENT_FLAG_FLOW_OUT); 1166 this, TRACE_EVENT_FLAG_FLOW_OUT);
1162 DCHECK(!context_->client()); 1167 DCHECK(!context_->client());
1163 1168
1164 context_->set_client(client); 1169 context_->set_client(client);
1165 context_->Start(request, NULL); 1170 context_->Start(request, NULL);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 response->clearHTTPHeaderField(webStringName); 1232 response->clearHTTPHeaderField(webStringName);
1228 while (response_headers->EnumerateHeader(&iterator, name, &value)) { 1233 while (response_headers->EnumerateHeader(&iterator, name, &value)) {
1229 response->addHTTPHeaderField(webStringName, 1234 response->addHTTPHeaderField(webStringName,
1230 WebString::fromLatin1(value)); 1235 WebString::fromLatin1(value));
1231 } 1236 }
1232 } 1237 }
1233 return true; 1238 return true;
1234 } 1239 }
1235 1240
1236 } // namespace content 1241 } // namespace content
OLDNEW
« no previous file with comments | « content/child/sync_load_response.h ('k') | content/child/web_url_loader_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698