Renamed CanPruneAllButVisible and PruneAllButVisible in the Navigation Controller to CanPruneAllButLastCommitted and PruneAllButLastCommitted, respectively.
Review URL: https://codereview.chromium.org/69013004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234693 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
chrome/browser
content
browser
android
frame_host
web_contents
public
browser
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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());
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
Reference in New Issue
Block a user