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

Unified Diff: content/browser/tab_contents/navigation_controller.cc

Issue 7649009: Merge of 97624 to 835 branch. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/835/src/
Patch Set: Created 9 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
« no previous file with comments | « chrome/test/render_view_test.cc ('k') | content/browser/tab_contents/navigation_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/tab_contents/navigation_controller.cc
===================================================================
--- content/browser/tab_contents/navigation_controller.cc (revision 96734)
+++ content/browser/tab_contents/navigation_controller.cc (working copy)
@@ -888,6 +888,14 @@
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) ||
@@ -896,6 +904,16 @@
(!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_;
@@ -937,8 +955,9 @@
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() {
« no previous file with comments | « chrome/test/render_view_test.cc ('k') | content/browser/tab_contents/navigation_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698