From 9a890458d2438e8fe9b3bcc8a6c9bee4888d1a63 Mon Sep 17 00:00:00 2001 From: "jamescook@chromium.org" Date: Thu, 13 Feb 2014 22:21:02 +0000 Subject: 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 TBR=torne@chromium.org 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 --- content/browser/web_contents/web_contents_impl.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'content/browser/web_contents/web_contents_impl.h') 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 @@ class CONTENT_EXPORT WebContentsImpl 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 @@ class CONTENT_EXPORT WebContentsImpl 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 @@ class CONTENT_EXPORT WebContentsImpl // 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_; -- cgit v1.1