diff options
9 files changed, 45 insertions, 43 deletions
diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc index 09d8134..b0cadbb 100644 --- a/chrome/browser/prerender/prerender_manager.cc +++ b/chrome/browser/prerender/prerender_manager.cc @@ -470,7 +470,7 @@ bool PrerenderManager::MaybeUsePrerenderedPage(const GURL& url, // there is a pending entry, it may not commit. // TODO(creis): If there is a pending navigation and no last committed // entry, we might be able to transfer the network request instead. - if (!new_web_contents->GetController().CanPruneAllButVisible()) { + if (!new_web_contents->GetController().CanPruneAllButLastCommitted()) { // Abort this prerender so it is not used later. http://crbug.com/292121 prerender_data->contents()->Destroy(FINAL_STATUS_NAVIGATION_UNCOMMITTED); return false; diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc index 9d6151a..196688b 100644 --- a/chrome/browser/ui/browser_commands.cc +++ b/chrome/browser/ui/browser_commands.cc @@ -1057,8 +1057,8 @@ void ViewSource(Browser* browser, // Note that Clone does not copy the pending or transient entries, so the // active entry in view_source_contents will be the last committed entry. WebContents* view_source_contents = contents->Clone(); - DCHECK(view_source_contents->GetController().CanPruneAllButVisible()); - view_source_contents->GetController().PruneAllButVisible(); + DCHECK(view_source_contents->GetController().CanPruneAllButLastCommitted()); + view_source_contents->GetController().PruneAllButLastCommitted(); NavigationEntry* active_entry = view_source_contents->GetController().GetActiveEntry(); if (!active_entry) diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc index c81a763..71a474a 100644 --- a/chrome/browser/ui/browser_instant_controller.cc +++ b/chrome/browser/ui/browser_instant_controller.cc @@ -80,7 +80,7 @@ bool BrowserInstantController::MaybeSwapInInstantNTPContents( // source contents. // TODO(sreeram): Always using the local URL is wrong in the case of the // first tab in a window where we might want to use the remote URL. Fix. - if (!instant_ntp->GetController().CanPruneAllButVisible()) { + if (!instant_ntp->GetController().CanPruneAllButLastCommitted()) { source_contents->GetController().LoadURL(chrome::GetLocalInstantURL( profile()), content::Referrer(), content::PAGE_TRANSITION_GENERATED, std::string()); @@ -94,10 +94,10 @@ bool BrowserInstantController::MaybeSwapInInstantNTPContents( } } else { // If the Instant NTP hasn't yet committed an entry, we can't call - // PruneAllButVisible. In that case, there shouldn't be any entries to - // prune anyway. - if (instant_ntp->GetController().CanPruneAllButVisible()) - instant_ntp->GetController().PruneAllButVisible(); + // PruneAllButLastCommitted. In that case, there shouldn't be any entries + // to prune anyway. + if (instant_ntp->GetController().CanPruneAllButLastCommitted()) + instant_ntp->GetController().PruneAllButLastCommitted(); else CHECK(!instant_ntp->GetController().GetLastCommittedEntry()); diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc index 5883f93..94e4b76 100644 --- a/content/browser/android/content_view_core_impl.cc +++ b/content/browser/android/content_view_core_impl.cc @@ -1202,8 +1202,8 @@ void ContentViewCoreImpl::ContinuePendingReload(JNIEnv* env, jobject obj) { void ContentViewCoreImpl::ClearHistory(JNIEnv* env, jobject obj) { // TODO(creis): Do callers of this need to know if it fails? - if (web_contents_->GetController().CanPruneAllButVisible()) - web_contents_->GetController().PruneAllButVisible(); + if (web_contents_->GetController().CanPruneAllButLastCommitted()) + web_contents_->GetController().PruneAllButLastCommitted(); } void ContentViewCoreImpl::AddJavascriptInterface( diff --git a/content/browser/frame_host/navigation_controller_impl.cc b/content/browser/frame_host/navigation_controller_impl.cc index fb82791..814d56b 100644 --- a/content/browser/frame_host/navigation_controller_impl.cc +++ b/content/browser/frame_host/navigation_controller_impl.cc @@ -1229,7 +1229,7 @@ void NavigationControllerImpl::CopyStateFrom( void NavigationControllerImpl::CopyStateFromAndPrune( NavigationController* temp) { // It is up to callers to check the invariants before calling this. - CHECK(CanPruneAllButVisible()); + CHECK(CanPruneAllButLastCommitted()); NavigationControllerImpl* source = static_cast<NavigationControllerImpl*>(temp); @@ -1246,7 +1246,7 @@ void NavigationControllerImpl::CopyStateFromAndPrune( delegate_->GetMaxPageIDForSiteInstance(site_instance.get()); // Remove all the entries leaving the active entry. - PruneAllButVisibleInternal(); + PruneAllButLastCommittedInternal(); // We now have one entry, possibly with a new pending entry. Ensure that // adding the entries from source won't put us over the limit. @@ -1283,7 +1283,7 @@ void NavigationControllerImpl::CopyStateFromAndPrune( } } -bool NavigationControllerImpl::CanPruneAllButVisible() { +bool NavigationControllerImpl::CanPruneAllButLastCommitted() { // If there is no last committed entry, we cannot prune. Even if there is a // pending entry, it may not commit, leaving this WebContents blank, despite // possibly giving it new entries via CopyStateFromAndPrune. @@ -1304,8 +1304,8 @@ bool NavigationControllerImpl::CanPruneAllButVisible() { return true; } -void NavigationControllerImpl::PruneAllButVisible() { - PruneAllButVisibleInternal(); +void NavigationControllerImpl::PruneAllButLastCommitted() { + PruneAllButLastCommittedInternal(); // We should still have a last committed entry. DCHECK_NE(-1, last_committed_entry_index_); @@ -1321,9 +1321,9 @@ void NavigationControllerImpl::PruneAllButVisible() { entry->site_instance(), 0, entry->GetPageID()); } -void NavigationControllerImpl::PruneAllButVisibleInternal() { +void NavigationControllerImpl::PruneAllButLastCommittedInternal() { // It is up to callers to check the invariants before calling this. - CHECK(CanPruneAllButVisible()); + CHECK(CanPruneAllButLastCommitted()); // Erase all entries but the last committed entry. There may still be a // new pending entry after this. diff --git a/content/browser/frame_host/navigation_controller_impl.h b/content/browser/frame_host/navigation_controller_impl.h index 916bf78..eb566c2 100644 --- a/content/browser/frame_host/navigation_controller_impl.h +++ b/content/browser/frame_host/navigation_controller_impl.h @@ -90,8 +90,8 @@ class CONTENT_EXPORT NavigationControllerImpl const NavigationController& source) OVERRIDE; virtual void CopyStateFromAndPrune( NavigationController* source) OVERRIDE; - virtual bool CanPruneAllButVisible() OVERRIDE; - virtual void PruneAllButVisible() OVERRIDE; + virtual bool CanPruneAllButLastCommitted() OVERRIDE; + virtual void PruneAllButLastCommitted() OVERRIDE; virtual void ClearAllScreenshots() OVERRIDE; // The session storage namespace that all child RenderViews belonging to @@ -301,10 +301,11 @@ class CONTENT_EXPORT NavigationControllerImpl void PruneOldestEntryIfFull(); // Removes all entries except the last committed entry. If there is a new - // pending navigation it is preserved. In contrast to PruneAllButVisible() - // this does not update the session history of the RenderView. Callers - // must ensure that |CanPruneAllButVisible| returns true before calling this. - void PruneAllButVisibleInternal(); + // pending navigation it is preserved. In contrast to + // PruneAllButLastCommitted() this does not update the session history of the + // RenderView. Callers must ensure that |CanPruneAllButLastCommitted| returns + // true before calling this. + void PruneAllButLastCommittedInternal(); // Returns true if the navigation is likley to be automatic rather than // user-initiated. diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc index 4126c97..0676557 100644 --- a/content/browser/frame_host/navigation_controller_impl_unittest.cc +++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc @@ -3467,8 +3467,8 @@ TEST_F(NavigationControllerTest, HistoryNavigate) { EXPECT_TRUE(message == NULL); } -// Test call to PruneAllButVisible for the only entry. -TEST_F(NavigationControllerTest, PruneAllButVisibleForSingle) { +// Test call to PruneAllButLastCommitted for the only entry. +TEST_F(NavigationControllerTest, PruneAllButLastCommittedForSingle) { NavigationControllerImpl& controller = controller_impl(); const GURL url1("http://foo1"); NavigateAndCommit(url1); @@ -3477,14 +3477,14 @@ TEST_F(NavigationControllerTest, PruneAllButVisibleForSingle) { GetSiteInstanceFromEntry(controller.GetEntryAtIndex(0)), 0, controller.GetEntryAtIndex(0)->GetPageID()); - controller.PruneAllButVisible(); + controller.PruneAllButLastCommitted(); EXPECT_EQ(-1, controller.GetPendingEntryIndex()); EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url1); } -// Test call to PruneAllButVisible for first entry. -TEST_F(NavigationControllerTest, PruneAllButVisibleForFirst) { +// Test call to PruneAllButLastCommitted for first entry. +TEST_F(NavigationControllerTest, PruneAllButLastCommittedForFirst) { NavigationControllerImpl& controller = controller_impl(); const GURL url1("http://foo/1"); const GURL url2("http://foo/2"); @@ -3501,14 +3501,14 @@ TEST_F(NavigationControllerTest, PruneAllButVisibleForFirst) { GetSiteInstanceFromEntry(controller.GetEntryAtIndex(0)), 0, controller.GetEntryAtIndex(0)->GetPageID()); - controller.PruneAllButVisible(); + controller.PruneAllButLastCommitted(); EXPECT_EQ(-1, controller.GetPendingEntryIndex()); EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url1); } -// Test call to PruneAllButVisible for intermediate entry. -TEST_F(NavigationControllerTest, PruneAllButVisibleForIntermediate) { +// Test call to PruneAllButLastCommitted for intermediate entry. +TEST_F(NavigationControllerTest, PruneAllButLastCommittedForIntermediate) { NavigationControllerImpl& controller = controller_impl(); const GURL url1("http://foo/1"); const GURL url2("http://foo/2"); @@ -3524,15 +3524,15 @@ TEST_F(NavigationControllerTest, PruneAllButVisibleForIntermediate) { GetSiteInstanceFromEntry(controller.GetEntryAtIndex(1)), 0, controller.GetEntryAtIndex(1)->GetPageID()); - controller.PruneAllButVisible(); + controller.PruneAllButLastCommitted(); EXPECT_EQ(-1, controller.GetPendingEntryIndex()); EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url2); } -// Test call to PruneAllButVisible for a pending entry that is not yet in the -// list of entries. -TEST_F(NavigationControllerTest, PruneAllButVisibleForPendingNotInList) { +// Test call to PruneAllButLastCommitted for a pending entry that is not yet in +// the list of entries. +TEST_F(NavigationControllerTest, PruneAllButLastCommittedForPendingNotInList) { NavigationControllerImpl& controller = controller_impl(); const GURL url1("http://foo/1"); const GURL url2("http://foo/2"); @@ -3549,7 +3549,7 @@ TEST_F(NavigationControllerTest, PruneAllButVisibleForPendingNotInList) { contents()->ExpectSetHistoryLengthAndPrune( NULL, 0, controller.GetPendingEntry()->GetPageID()); - controller.PruneAllButVisible(); + controller.PruneAllButLastCommitted(); // We should only have the last committed and pending entries at this point, // and the pending entry should still not be in the entry list. diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc index ade955f..94e0146 100644 --- a/content/browser/web_contents/web_contents_impl_unittest.cc +++ b/content/browser/web_contents/web_contents_impl_unittest.cc @@ -2101,7 +2101,7 @@ TEST_F(WebContentsImplTest, CopyStateFromAndPruneTargetInterstitial) { // Ensure that we do not allow calling CopyStateFromAndPrune when an // interstitial is showing in the target. - EXPECT_FALSE(other_controller.CanPruneAllButVisible()); + EXPECT_FALSE(other_controller.CanPruneAllButLastCommitted()); } // Regression test for http://crbug.com/168611 - the URLs passed by the diff --git a/content/public/browser/navigation_controller.h b/content/public/browser/navigation_controller.h index 99ed8ca..7099164 100644 --- a/content/public/browser/navigation_controller.h +++ b/content/public/browser/navigation_controller.h @@ -406,11 +406,11 @@ class NavigationController { // result: A B C *G* // If there is a pending entry after *G* in |this|, it is also preserved. // This ignores any pending or transient entries in |source|. Callers must - // ensure that |CanPruneAllButVisible| returns true before calling this, or it - // will crash. + // ensure that |CanPruneAllButLastCommitted| returns true before calling this, + // or it will crash. virtual void CopyStateFromAndPrune(NavigationController* source) = 0; - // Returns whether it is safe to call PruneAllButVisible or + // Returns whether it is safe to call PruneAllButLastCommitted or // CopyStateFromAndPrune. There must be a last committed entry, no transient // entry, and if there is a pending entry, it must be new and not an existing // entry. @@ -426,12 +426,13 @@ class NavigationController { // sensible place to put the pending entry when it did commit, after all other // entries are pruned. For example, it could be going back several entries. // (New pending entries are safe, because they can always commit to the end.) - virtual bool CanPruneAllButVisible() = 0; + virtual bool CanPruneAllButLastCommitted() = 0; // Removes all the entries except the last committed entry. If there is a new // pending navigation it is preserved. Callers must ensure - // |CanPruneAllButVisible| returns true before calling this, or it will crash. - virtual void PruneAllButVisible() = 0; + // |CanPruneAllButLastCommitted| returns true before calling this, or it will + // crash. + virtual void PruneAllButLastCommitted() = 0; // Clears all screenshots associated with navigation entries in this // controller. Useful to reduce memory consumption in low-memory situations. |