Avoid discarding freshly created background tabs
The Chrome OS out-of-memory tab discarder uses the "last selected" time as a signal for which tab to discard. This starts at 0 for freshly created background tabs, like those created with a control-click. The user probably doesn't want to discard those tabs, since they just opened them.
Since the only other user of WebContents::GetLastSelectedTime() is devtools, which uses it for a similar kind of sorting based on activity, rename the method to GetLastActiveTime() and start the value with the tab creation time.
BUG=338735
TEST=content_unittests WebContentsImpl.GetLastActiveTime
[email protected] for rename touching android_webview
Review URL: https://codereview.chromium.org/138913021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251154 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index 37679f1..c950266 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -233,7 +233,7 @@
virtual base::TerminationStatus GetCrashedStatus() const OVERRIDE;
virtual bool IsBeingDestroyed() const OVERRIDE;
virtual void NotifyNavigationStateChanged(unsigned changed_flags) OVERRIDE;
- virtual base::TimeTicks GetLastSelectedTime() const OVERRIDE;
+ virtual base::TimeTicks GetLastActiveTime() const OVERRIDE;
virtual void WasShown() OVERRIDE;
virtual void WasHidden() OVERRIDE;
virtual bool NeedToFireBeforeUnload() OVERRIDE;
@@ -626,6 +626,7 @@
CrossSiteCantPreemptAfterUnload);
FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, PendingContents);
FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FrameTreeShape);
+ FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, GetLastActiveTime);
FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
FRIEND_TEST_ALL_PREFIXES(RenderFrameHostManagerTest, PageDoesBackAndReload);
@@ -988,8 +989,9 @@
// Settings that get passed to the renderer process.
RendererPreferences renderer_preferences_;
- // The time that this tab was last selected.
- base::TimeTicks last_selected_time_;
+ // The time that this WebContents was last made active. The initial value is
+ // the WebContents creation time.
+ base::TimeTicks last_active_time_;
// See description above setter.
bool closed_by_user_gesture_;