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

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

Issue 1661423002: Solidify Entry discarding logic (NavigationHandle keeps its ID) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge @377292 Created 4 years, 10 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/navigation_controller_impl.cc
diff --git a/content/browser/frame_host/navigation_controller_impl.cc b/content/browser/frame_host/navigation_controller_impl.cc
index c08834bbf987762f19faed38d513cf74523d2155..39272938e3232110652bbcc10c01300d9bde9c17 100644
--- a/content/browser/frame_host/navigation_controller_impl.cc
+++ b/content/browser/frame_host/navigation_controller_impl.cc
@@ -57,6 +57,7 @@
#include "content/browser/frame_host/interstitial_page_impl.h"
#include "content/browser/frame_host/navigation_entry_impl.h"
#include "content/browser/frame_host/navigation_entry_screenshot_manager.h"
+#include "content/browser/frame_host/navigation_handle_impl.h"
#include "content/browser/frame_host/navigator.h"
#include "content/browser/renderer_host/render_view_host_impl.h" // Temporary
#include "content/browser/site_instance_impl.h"
@@ -1098,12 +1099,19 @@ void NavigationControllerImpl::RendererDidNavigateToNewPage(
scoped_ptr<NavigationEntryImpl> new_entry;
bool update_virtual_url;
// Only make a copy of the pending entry if it is appropriate for the new page
- // that was just loaded. We verify this at a coarse grain by checking that
- // the SiteInstance hasn't been assigned to something else, and by making sure
- // that the pending entry was intended as a new entry (rather than being a
- // history navigation that was interrupted by an unrelated, renderer-initiated
- // navigation).
- if (pending_entry_ && pending_entry_index_ == -1 &&
+ // that was just loaded. Verify this by checking if the entry corresponds
+ // to the current navigation handle. Note that in some tests the render frame
+ // host does not have a valid handle. Additionally, coarsely check that:
+ // 1. The SiteInstance hasn't been assigned to something else.
+ // 2. The pending entry was intended as a new entry, rather than being a
+ // history navigation that was interrupted by an unrelated,
+ // renderer-initiated navigation.
+ // TODO(csharrison): Investigate whether we can remove some of the coarser
+ // checks.
+ NavigationHandleImpl* handle = rfh->navigation_handle();
+ if (pending_entry_ && handle &&
+ handle->pending_nav_entry_id() == pending_entry_->GetUniqueID() &&
+ pending_entry_index_ == -1 &&
(!pending_entry_->site_instance() ||
pending_entry_->site_instance() == rfh->GetSiteInstance())) {
new_entry = pending_entry_->Clone();

Powered by Google App Engine
This is Rietveld 408576698