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

Unified Diff: content/browser/frame_host/render_frame_host_manager.cc

Issue 475783002: PlzNavigate: add cancel navigation logic for uncommitted requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Nasko's comments Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/render_frame_host_manager.cc
diff --git a/content/browser/frame_host/render_frame_host_manager.cc b/content/browser/frame_host/render_frame_host_manager.cc
index 5e0872c30b7469b44c38154fefdba2631c72a852..0d3b26a9c3f4d7d23537122b65acfdc1eaa5c26e 100644
--- a/content/browser/frame_host/render_frame_host_manager.cc
+++ b/content/browser/frame_host/render_frame_host_manager.cc
@@ -571,6 +571,9 @@ void RenderFrameHostManager::OnBeginNavigation(
// crashed) not to display a sad tab while navigating.
// TODO(clamy): Spawn a speculative renderer process if we do not have one to
// use for the navigation.
+
+ // The previous existing NavigationRequest instance will be destroyed at this
+ // point, which might cause the cancellation of that request.
navigation_request_.reset(new NavigationRequest(
info, frame_tree_node_->frame_tree_node_id()));
navigation_request_->BeginNavigation(params.request_body);
@@ -581,6 +584,14 @@ void RenderFrameHostManager::CommitNavigation(
const NavigationBeforeCommitInfo& info) {
CHECK(CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation));
+ DCHECK(navigation_request_.get());
+ // Ignores navigation commits if the request ID doesn't match the current
+ // active request.
+ if (navigation_request_->navigation_request_id() !=
+ info.navigation_request_id) {
+ return;
+ }
+
// Pick the right RenderFrameHost to commit the navigation.
SiteInstance* current_instance = render_frame_host_->GetSiteInstance();
// TODO(clamy): Replace the default values by the right ones. This may require

Powered by Google App Engine
This is Rietveld 408576698