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

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

Issue 2387603003: Resume a backgrounded renderer that was purged and suspended (Closed)
Patch Set: Added transition: => RUNNING Created 4 years, 2 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 9dc86df35fb7da85d33e17f02a3eae04f168d72e..aeff4a9e274f11a78fb1a345ccd0b1463be2e268 100644
--- a/chrome/browser/memory/tab_manager.h
+++ b/chrome/browser/memory/tab_manager.h
@@ -174,8 +174,9 @@ class TabManager : public TabStripModelObserver {
FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ReloadDiscardedTabContextMenu);
FRIEND_TEST_ALL_PREFIXES(TabManagerTest, TabManagerBasics);
- // This is needed so WebContentsData can call OnDiscardedStateChange.
- friend class WebContensData;
+ // This is needed so WebContentsData can call OnDiscardedStateChange, and
+ // can use PurgeAndSuspendState.
+ friend class WebContentsData;
// Called by WebContentsData whenever the discard state of a WebContents
// changes, so that observers can be informed.
@@ -247,6 +248,38 @@ class TabManager : public TabStripModelObserver {
// that need to be run periodically (see comment in implementation).
void UpdateTimerCallback();
+ // Returns WebContents whose contents id matches the given tab-contents-id.
+ content::WebContents* GetWebContentsByContentsId(int64_t tab_contents_id);
+
+ // Initially PurgeAndSuspendState is RUNNING.
+ // RUNNING => SUSPENDED
+ // - Some 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 activted tab's state will be RUNNING.
haraken 2016/10/20 16:52:16 activated
+ enum PurgeAndSuspendState {
+ RUNNING,
+ RESUMED,
+ SUSPENDED,
+ };
+ // Determines whether to update purge-and-suspend state and returns the
+ // next state.
+ bool ShouldUpdatePurgeAndSuspendState(
+ const base::TimeTicks& current_time,
+ const TabStats& tab,
+ const base::TimeDelta& purge_and_suspend_threshold,
+ PurgeAndSuspendState* next_state);
+
// Purges and suspends renderers in backgrounded tabs.
void PurgeAndSuspendBackgroundedTabs();
« 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