diff options
author | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-14 16:49:19 +0000 |
---|---|---|
committer | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-14 16:49:19 +0000 |
commit | 9e1ad4b286a342d27726908a0df47b4e54e9b50e (patch) | |
tree | 2de9bd6fcfbbe2158c1e1712265c81b33185dffb /content/browser/tab_contents/navigation_controller.cc | |
parent | 5dcda9d959b5a3062976d98ae0eab575cfb321d4 (diff) | |
download | chromium_src-9e1ad4b286a342d27726908a0df47b4e54e9b50e.zip chromium_src-9e1ad4b286a342d27726908a0df47b4e54e9b50e.tar.gz chromium_src-9e1ad4b286a342d27726908a0df47b4e54e9b50e.tar.bz2 |
A number of issues weren't addressed with the earlier patch for prerender + browsing history, particularly for instant pages.
- The "remove first entry" option used by instant was not being handled correctly when there was only one committed entry in the NavigationController.
- Renderer-issued navigations which were committed in the browser but not yet known by the browser/NavigationController were being incorrectly pruned. This did not happen regularly in the prerender case, but does in the instant case, particularly when changing what's typed in the omnibox.
- Some additional sanity testing to make sure that the message is sent to the correct render process.
- Additional unit tests are added.
BUG=89798
TEST=NavigationControllerTest.CopyStateFromAndPrune*, RenderViewTest.SetHistoryLengthAndPrune.
Review URL: http://codereview.chromium.org/7618016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96724 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/tab_contents/navigation_controller.cc')
-rw-r--r-- | content/browser/tab_contents/navigation_controller.cc | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/content/browser/tab_contents/navigation_controller.cc b/content/browser/tab_contents/navigation_controller.cc index 0144fef..315a4711 100644 --- a/content/browser/tab_contents/navigation_controller.cc +++ b/content/browser/tab_contents/navigation_controller.cc @@ -883,6 +883,14 @@ void NavigationController::CopyStateFrom(const NavigationController& source) { void NavigationController::CopyStateFromAndPrune(NavigationController* source, bool remove_first_entry) { + // The SiteInstance and page_id of the last committed entry needs to be + // remembered at this point, in case there is only one committed entry + // and it is pruned. + NavigationEntry* last_committed = GetLastCommittedEntry(); + SiteInstance* site_instance = + last_committed ? last_committed->site_instance() : NULL; + int32 minimum_page_id = last_committed ? last_committed->page_id() : -1; + // This code is intended for use when the last entry is the active entry. DCHECK((transient_entry_index_ != -1 && transient_entry_index_ == entry_count() - 1) || @@ -891,6 +899,16 @@ void NavigationController::CopyStateFromAndPrune(NavigationController* source, (!pending_entry_ && last_committed_entry_index_ == entry_count() - 1)); if (remove_first_entry && entry_count()) { + // If there is only one committed entry and |remove_first_entry| is true, + // it needs to be pruned. This is accomplished by specifying a larger + // |minimum_page_id| than the committed entry's page_id in the + // ViewMsg_SetHistoryLengthAndPrune message. However, any pages which are + // committed between now and when the RenderView handles the message will + // need to be retained. Both constraints can be met by incrementing the + // |minimum_page_id| by 1. + DCHECK(minimum_page_id >= 0); + if (entry_count() == 1) + ++minimum_page_id; // Save then restore the pending entry (RemoveEntryAtIndexInternal chucks // the pending entry). NavigationEntry* pending_entry = pending_entry_; @@ -932,8 +950,9 @@ void NavigationController::CopyStateFromAndPrune(NavigationController* source, last_committed_entry_index_--; } - // Update the history in the RenderView. - tab_contents_->SetHistoryLengthAndClear(max_source_index); + tab_contents_->SetHistoryLengthAndPrune(site_instance, + max_source_index, + minimum_page_id); } void NavigationController::PruneAllButActive() { |