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

Side by Side Diff: content/browser/frame_host/navigation_handle_impl.cc

Issue 2954623003: PlzNavigate: implement REUSE_COMMITTED_OR_PENDING_SITE for redirects (Closed)
Patch Set: Addressed Charlie's comments Created 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/frame_host/navigation_handle_impl.h" 5 #include "content/browser/frame_host/navigation_handle_impl.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 NavigationThrottle::ThrottleCheckResult 448 NavigationThrottle::ThrottleCheckResult
449 NavigationHandleImpl::CallWillRedirectRequestForTesting( 449 NavigationHandleImpl::CallWillRedirectRequestForTesting(
450 const GURL& new_url, 450 const GURL& new_url,
451 bool new_method_is_post, 451 bool new_method_is_post,
452 const GURL& new_referrer_url, 452 const GURL& new_referrer_url,
453 bool new_is_external_protocol) { 453 bool new_is_external_protocol) {
454 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; 454 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER;
455 WillRedirectRequest(new_url, new_method_is_post ? "POST" : "GET", 455 WillRedirectRequest(new_url, new_method_is_post ? "POST" : "GET",
456 new_referrer_url, new_is_external_protocol, 456 new_referrer_url, new_is_external_protocol,
457 scoped_refptr<net::HttpResponseHeaders>(), 457 scoped_refptr<net::HttpResponseHeaders>(),
458 net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN, 458 net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN, nullptr,
459 base::Bind(&UpdateThrottleCheckResult, &result)); 459 base::Bind(&UpdateThrottleCheckResult, &result));
460 460
461 // Reset the callback to ensure it will not be called later. 461 // Reset the callback to ensure it will not be called later.
462 complete_callback_.Reset(); 462 complete_callback_.Reset();
463 return result; 463 return result;
464 } 464 }
465 465
466 NavigationThrottle::ThrottleCheckResult 466 NavigationThrottle::ThrottleCheckResult
467 NavigationHandleImpl::CallWillProcessResponseForTesting( 467 NavigationHandleImpl::CallWillProcessResponseForTesting(
468 content::RenderFrameHost* render_frame_host, 468 content::RenderFrameHost* render_frame_host,
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 } 608 }
609 } 609 }
610 610
611 void NavigationHandleImpl::WillRedirectRequest( 611 void NavigationHandleImpl::WillRedirectRequest(
612 const GURL& new_url, 612 const GURL& new_url,
613 const std::string& new_method, 613 const std::string& new_method,
614 const GURL& new_referrer_url, 614 const GURL& new_referrer_url,
615 bool new_is_external_protocol, 615 bool new_is_external_protocol,
616 scoped_refptr<net::HttpResponseHeaders> response_headers, 616 scoped_refptr<net::HttpResponseHeaders> response_headers,
617 net::HttpResponseInfo::ConnectionInfo connection_info, 617 net::HttpResponseInfo::ConnectionInfo connection_info,
618 RenderProcessHost* post_redirect_process,
618 const ThrottleChecksFinishedCallback& callback) { 619 const ThrottleChecksFinishedCallback& callback) {
619 TRACE_EVENT_ASYNC_STEP_INTO1("navigation", "NavigationHandle", this, 620 TRACE_EVENT_ASYNC_STEP_INTO1("navigation", "NavigationHandle", this,
620 "WillRedirectRequest", "url", 621 "WillRedirectRequest", "url",
621 new_url.possibly_invalid_spec()); 622 new_url.possibly_invalid_spec());
622 623
623 // Update the navigation parameters. 624 // Update the navigation parameters.
624 url_ = new_url; 625 url_ = new_url;
625 method_ = new_method; 626 method_ = new_method;
626 UpdateSiteURL(); 627 UpdateSiteURL(post_redirect_process);
627 628
628 if (!(transition_ & ui::PAGE_TRANSITION_CLIENT_REDIRECT)) { 629 if (!(transition_ & ui::PAGE_TRANSITION_CLIENT_REDIRECT)) {
629 sanitized_referrer_.url = new_referrer_url; 630 sanitized_referrer_.url = new_referrer_url;
630 sanitized_referrer_ = 631 sanitized_referrer_ =
631 Referrer::SanitizeForRequest(url_, sanitized_referrer_); 632 Referrer::SanitizeForRequest(url_, sanitized_referrer_);
632 } 633 }
633 634
634 is_external_protocol_ = new_is_external_protocol; 635 is_external_protocol_ = new_is_external_protocol;
635 response_headers_ = response_headers; 636 response_headers_ = response_headers;
636 connection_info_ = connection_info; 637 connection_info_ = connection_info;
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 node = node->parent()) { 1147 node = node->parent()) {
1147 if (node->current_url().EqualsIgnoringRef(url_)) { 1148 if (node->current_url().EqualsIgnoringRef(url_)) {
1148 if (found_self_reference) 1149 if (found_self_reference)
1149 return true; 1150 return true;
1150 found_self_reference = true; 1151 found_self_reference = true;
1151 } 1152 }
1152 } 1153 }
1153 return false; 1154 return false;
1154 } 1155 }
1155 1156
1156 void NavigationHandleImpl::UpdateSiteURL() { 1157 void NavigationHandleImpl::UpdateSiteURL(
1158 RenderProcessHost* post_redirect_process) {
1157 GURL new_site_url = SiteInstance::GetSiteForURL( 1159 GURL new_site_url = SiteInstance::GetSiteForURL(
1158 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), 1160 frame_tree_node_->navigator()->GetController()->GetBrowserContext(),
1159 url_); 1161 url_);
1160 if (new_site_url == site_url_) 1162 int post_redirect_process_id = post_redirect_process
1163 ? post_redirect_process->GetID()
1164 : ChildProcessHost::kInvalidUniqueID;
1165 if (new_site_url == site_url_ &&
1166 post_redirect_process_id == expected_render_process_host_id_) {
1161 return; 1167 return;
1168 }
1162 1169
1163 // When redirecting cross-site, stop telling the speculative 1170 // Stop expecting a navigation to the current site URL in the current expected
1164 // RenderProcessHost to expect a navigation commit. 1171 // process.
1165 SetExpectedProcess(nullptr); 1172 SetExpectedProcess(nullptr);
1173
1174 // Update the site URL and the expected process.
1166 site_url_ = new_site_url; 1175 site_url_ = new_site_url;
1176 SetExpectedProcess(post_redirect_process);
1167 } 1177 }
1168 1178
1169 } // namespace content 1179 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_handle_impl.h ('k') | content/browser/frame_host/navigation_handle_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698