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

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

Issue 2316573002: PlzNavigate: Support ResourceTiming API (Closed)
Patch Set: Addressed comments (clamy@) Created 4 years, 3 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
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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 blink::WebURLResponse::WebSecurityDetails webSecurityDetails( 287 blink::WebURLResponse::WebSecurityDetails webSecurityDetails(
288 WebString::fromUTF8(protocol), WebString::fromUTF8(key_exchange), 288 WebString::fromUTF8(protocol), WebString::fromUTF8(key_exchange),
289 WebString::fromUTF8(cipher), WebString::fromUTF8(mac), ssl_status.cert_id, 289 WebString::fromUTF8(cipher), WebString::fromUTF8(mac), ssl_status.cert_id,
290 sct_list); 290 sct_list);
291 291
292 response->setSecurityDetails(webSecurityDetails); 292 response->setSecurityDetails(webSecurityDetails);
293 } 293 }
294 294
295 } // namespace 295 } // namespace
296 296
297 StreamOverrideParameters::StreamOverrideParameters() {}
298 StreamOverrideParameters::~StreamOverrideParameters() {}
299
297 // This inner class exists since the WebURLLoader may be deleted while inside a 300 // This inner class exists since the WebURLLoader may be deleted while inside a
298 // call to WebURLLoaderClient. Refcounting is to keep the context from being 301 // call to WebURLLoaderClient. Refcounting is to keep the context from being
299 // deleted if it may have work to do after calling into the client. 302 // deleted if it may have work to do after calling into the client.
300 class WebURLLoaderImpl::Context : public base::RefCounted<Context> { 303 class WebURLLoaderImpl::Context : public base::RefCounted<Context> {
301 public: 304 public:
302 using ReceivedData = RequestPeer::ReceivedData; 305 using ReceivedData = RequestPeer::ReceivedData;
303 306
304 Context(WebURLLoaderImpl* loader, 307 Context(WebURLLoaderImpl* loader,
305 ResourceDispatcher* resource_dispatcher, 308 ResourceDispatcher* resource_dispatcher,
306 mojom::URLLoaderFactory* factory); 309 mojom::URLLoaderFactory* factory);
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 request_.reportRawHeaders()); 594 request_.reportRawHeaders());
592 595
593 WebURLRequest new_request; 596 WebURLRequest new_request;
594 PopulateURLRequestForRedirect( 597 PopulateURLRequestForRedirect(
595 request_, redirect_info, referrer_policy_, 598 request_, redirect_info, referrer_policy_,
596 info.was_fetched_via_service_worker 599 info.was_fetched_via_service_worker
597 ? blink::WebURLRequest::SkipServiceWorker::None 600 ? blink::WebURLRequest::SkipServiceWorker::None
598 : blink::WebURLRequest::SkipServiceWorker::All, 601 : blink::WebURLRequest::SkipServiceWorker::All,
599 &new_request); 602 &new_request);
600 603
601 client_->willFollowRedirect(loader_, new_request, response, 604 client_->willFollowRedirect(loader_, new_request, response);
602 info.encoded_data_length);
603 request_ = new_request; 605 request_ = new_request;
604 606
605 // Only follow the redirect if WebKit left the URL unmodified. 607 // Only follow the redirect if WebKit left the URL unmodified.
606 if (redirect_info.new_url == GURL(new_request.url())) { 608 if (redirect_info.new_url == GURL(new_request.url())) {
607 // First-party cookie logic moved from DocumentLoader in Blink to 609 // First-party cookie logic moved from DocumentLoader in Blink to
608 // net::URLRequest in the browser. Assert that Blink didn't try to change it 610 // net::URLRequest in the browser. Assert that Blink didn't try to change it
609 // to something else. 611 // to something else.
610 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(), 612 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(),
611 request_.firstPartyForCookies().string().utf8()); 613 request_.firstPartyForCookies().string().utf8());
612 return true; 614 return true;
(...skipping 20 matching lines...) Expand all
633 // received on the browser side, and has been passed down to the renderer. 635 // received on the browser side, and has been passed down to the renderer.
634 if (stream_override_.get()) { 636 if (stream_override_.get()) {
635 CHECK(IsBrowserSideNavigationEnabled()); 637 CHECK(IsBrowserSideNavigationEnabled());
636 info = stream_override_->response; 638 info = stream_override_->response;
637 } 639 }
638 640
639 WebURLResponse response; 641 WebURLResponse response;
640 PopulateURLResponse(request_.url(), info, &response, 642 PopulateURLResponse(request_.url(), info, &response,
641 request_.reportRawHeaders()); 643 request_.reportRawHeaders());
642 644
645 if (stream_override_.get()) {
646 CHECK(IsBrowserSideNavigationEnabled());
647 DCHECK(stream_override_->redirect_responses.size() ==
648 stream_override_->redirects.size());
649 for (size_t i = 0; i < stream_override_->redirects.size(); ++i) {
650 WebURLResponse previous_response;
651 // TODO(arthursonzogni) Once Devtool is supported by PlzNavigate, the
652 // |report_raw_header| argument must be checked.
653 WebURLLoaderImpl::PopulateURLResponse(
654 stream_override_->redirects[i],
655 stream_override_->redirect_responses[i],
656 &previous_response,
657 request_.reportRawHeaders());
658 response.appendRedirectResponse(previous_response);
659 }
660 }
661
643 bool show_raw_listing = (GURL(request_.url()).query() == "raw"); 662 bool show_raw_listing = (GURL(request_.url()).query() == "raw");
644 663
645 if (info.mime_type == "text/vnd.chromium.ftp-dir") { 664 if (info.mime_type == "text/vnd.chromium.ftp-dir") {
646 if (show_raw_listing) { 665 if (show_raw_listing) {
647 // Set the MIME type to plain text to prevent any active content. 666 // Set the MIME type to plain text to prevent any active content.
648 response.setMIMEType("text/plain"); 667 response.setMIMEType("text/plain");
649 } else { 668 } else {
650 // We're going to produce a parsed listing in HTML. 669 // We're going to produce a parsed listing in HTML.
651 response.setMIMEType("text/html"); 670 response.setMIMEType("text/html");
652 } 671 }
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 info.is_in_cache_storage 990 info.is_in_cache_storage
972 ? blink::WebString::fromUTF8(info.cache_storage_cache_name) 991 ? blink::WebString::fromUTF8(info.cache_storage_cache_name)
973 : blink::WebString()); 992 : blink::WebString());
974 blink::WebVector<blink::WebString> cors_exposed_header_names( 993 blink::WebVector<blink::WebString> cors_exposed_header_names(
975 info.cors_exposed_header_names.size()); 994 info.cors_exposed_header_names.size());
976 std::transform( 995 std::transform(
977 info.cors_exposed_header_names.begin(), 996 info.cors_exposed_header_names.begin(),
978 info.cors_exposed_header_names.end(), cors_exposed_header_names.begin(), 997 info.cors_exposed_header_names.end(), cors_exposed_header_names.begin(),
979 [](const std::string& h) { return blink::WebString::fromLatin1(h); }); 998 [](const std::string& h) { return blink::WebString::fromLatin1(h); });
980 response->setCorsExposedHeaderNames(cors_exposed_header_names); 999 response->setCorsExposedHeaderNames(cors_exposed_header_names);
1000 response->addToEncodedDataLength(info.encoded_data_length);
981 1001
982 SetSecurityStyleAndDetails(url, info, response, report_security_info); 1002 SetSecurityStyleAndDetails(url, info, response, report_security_info);
983 1003
984 WebURLResponseExtraDataImpl* extra_data = 1004 WebURLResponseExtraDataImpl* extra_data =
985 new WebURLResponseExtraDataImpl(info.npn_negotiated_protocol); 1005 new WebURLResponseExtraDataImpl(info.npn_negotiated_protocol);
986 response->setExtraData(extra_data); 1006 response->setExtraData(extra_data);
987 extra_data->set_was_fetched_via_spdy(info.was_fetched_via_spdy); 1007 extra_data->set_was_fetched_via_spdy(info.was_fetched_via_spdy);
988 extra_data->set_was_npn_negotiated(info.was_npn_negotiated); 1008 extra_data->set_was_npn_negotiated(info.was_npn_negotiated);
989 extra_data->set_was_alternate_protocol_available( 1009 extra_data->set_was_alternate_protocol_available(
990 info.was_alternate_protocol_available); 1010 info.was_alternate_protocol_available);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 response->clearHTTPHeaderField(webStringName); 1233 response->clearHTTPHeaderField(webStringName);
1214 while (response_headers->EnumerateHeader(&iterator, name, &value)) { 1234 while (response_headers->EnumerateHeader(&iterator, name, &value)) {
1215 response->addHTTPHeaderField(webStringName, 1235 response->addHTTPHeaderField(webStringName,
1216 WebString::fromLatin1(value)); 1236 WebString::fromLatin1(value));
1217 } 1237 }
1218 } 1238 }
1219 return true; 1239 return true;
1220 } 1240 }
1221 1241
1222 } // namespace content 1242 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698