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

Unified Diff: chrome/browser/memory/tab_manager.h

Issue 2711093002: Purge once random minutes(between 30min and 60min) after backgrounded. (Closed)
Patch Set: s/RUNNING/NOT_PURGED/g Created 3 years, 10 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 | « no previous file | chrome/browser/memory/tab_manager.cc » ('j') | chrome/browser/memory/tab_manager.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/memory/tab_manager.h
diff --git a/chrome/browser/memory/tab_manager.h b/chrome/browser/memory/tab_manager.h
index c384b7e054b07fa3eb20ad6b794bd748fcaf5665..98756c14529b534fd973ab654868992a54b7d540 100644
--- a/chrome/browser/memory/tab_manager.h
+++ b/chrome/browser/memory/tab_manager.h
@@ -159,9 +159,8 @@ class TabManager : public TabStripModelObserver {
static int64_t IdFromWebContents(content::WebContents* web_contents);
private:
- FRIEND_TEST_ALL_PREFIXES(TabManagerTest,
- ActivateTabResetPurgeAndSuspendState);
- FRIEND_TEST_ALL_PREFIXES(TabManagerTest, NextPurgeAndSuspendState);
+ FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ActivateTabResetPurgeState);
+ FRIEND_TEST_ALL_PREFIXES(TabManagerTest, NextPurgeState);
FRIEND_TEST_ALL_PREFIXES(TabManagerTest, AutoDiscardable);
FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce);
FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications);
@@ -176,7 +175,7 @@ class TabManager : public TabStripModelObserver {
FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ProtectVideoTabs);
FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ReloadDiscardedTabContextMenu);
FRIEND_TEST_ALL_PREFIXES(TabManagerTest, TabManagerBasics);
- FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, PurgeAndSuspendState);
+ FRIEND_TEST_ALL_PREFIXES(TabManagerWebContentsDataTest, PurgeState);
// The time of the first purging after a renderer is backgrounded.
// The initial value was chosen because most of users activate backgrounded
@@ -185,7 +184,7 @@ class TabManager : public TabStripModelObserver {
base::TimeDelta::FromMinutes(30);
// This is needed so WebContentsData can call OnDiscardedStateChange, and
- // can use PurgeAndSuspendState.
+ // can use PurgeState.
friend class WebContentsData;
// Called by WebContentsData whenever the discard state of a WebContents
@@ -258,38 +257,25 @@ class TabManager : public TabStripModelObserver {
// that need to be run periodically (see comment in implementation).
void UpdateTimerCallback();
- // Initially PurgeAndSuspendState is RUNNING.
- // RUNNING => SUSPENDED
+ // Initially PurgeState is NOT_PURGED.
+ // NOT_PURGED => PURGED
// - A tab has been backgrounded for more than purge-and-suspend-time
// seconds.
- // SUSPENDED => RESUMED
- // - A suspended tab is still suspended (i.e. last active time < last
- // purge-and-suspend modified time), and
- // - kMaxTimeRendererAllowedToBeSuspendedBeforeResume time passes since
- // since the tab was suspended.
- // RESUMED => SUSPENDED
- // - A resumed tab is still backgrounded (i.e. last active time < last
- // purge-and-suspend modified time), and
- // - kSuspendedRendererLengthOfResumption time passes since the tab was
- // resumed.
- // SUSPENDED, RESUMED, RUNNING => RUNNING
- // - When ActiveTabChaged, the newly activated tab's state will be RUNNING.
- enum PurgeAndSuspendState {
- RUNNING,
- RESUMED,
- SUSPENDED,
+ // PURGED => NOT_PURGED
+ // - When ActiveTabChaged, the newly activated tab's state will be NOT_PURGED.
Wez 2017/02/27 22:20:56 typo: ActiveTabChanged The naming here implies th
tasak 2017/02/28 09:45:37 The new code doesn't purge every 20 minutes, becau
Wez 2017/03/02 02:28:32 I thought the idea was to re-purge each background
tasak 2017/03/02 09:22:47 As far as I understand, we have a strong concern t
+ enum PurgeState {
Wez 2017/02/27 22:20:56 Note that as per style-guide, this and the other e
tasak 2017/02/28 09:45:37 Removed.
+ NOT_PURGED,
+ PURGED,
};
// Returns WebContents whose contents id matches the given tab_contents_id.
content::WebContents* GetWebContentsById(int64_t tab_contents_id) const;
Wez 2017/02/27 22:20:55 Why is this getter placed randomly in-between the
tasak 2017/02/28 09:45:37 Removed.
// Returns the next state of the purge and suspend.
Wez 2017/02/27 22:20:55 The function is called GetNextPurgeState() so the
tasak 2017/02/28 09:45:37 Replaced the method with ShouldPurgeAtTime. On 20
Wez 2017/03/02 02:28:32 The class has a set_test_tick_clock() method, thou
tasak 2017/03/02 09:22:46 I see. Done.
- PurgeAndSuspendState GetNextPurgeAndSuspendState(
- content::WebContents* content,
- base::TimeTicks current_time,
- const base::TimeDelta& time_to_first_suspension) const;
+ PurgeState GetNextPurgeState(content::WebContents* content,
+ base::TimeTicks current_time) const;
- // Purges and suspends renderers in backgrounded tabs.
- void PurgeAndSuspendBackgroundedTabs();
+ // Purges renderers in backgrounded tabs.
Wez 2017/02/27 22:20:56 Again, the reader can tell that from the name; wha
tasak 2017/02/28 09:45:37 Done.
+ void PurgeBackgroundedTabs();
// Does the actual discard by destroying the WebContents in |model| at |index|
// and replacing it by an empty one. Returns the new WebContents or NULL if
@@ -372,8 +358,8 @@ class TabManager : public TabStripModelObserver {
// backgrounded.
base::TimeDelta minimum_protection_time_;
- // A backgrounded renderer will be suspended when this time passes.
- base::TimeDelta time_to_first_suspension_;
+ // A backgrounded renderer will be purged when this time passes.
+ base::TimeDelta time_to_first_purge_;
Wez 2017/02/27 22:20:56 This doesn't change over the lifetime of the TabMa
tasak 2017/02/28 09:45:39 So is it possible to initialize the value by using
#if defined(OS_CHROMEOS)
std::unique_ptr<TabManagerDelegate> delegate_;
« no previous file with comments | « no previous file | chrome/browser/memory/tab_manager.cc » ('j') | chrome/browser/memory/tab_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698