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

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

Issue 2389683002: Modify PurgeAndSuspend to see WebContents (Closed)
Patch Set: Add unittest 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 | « chrome/browser/memory/tab_manager.h ('k') | chrome/browser/memory/tab_manager_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/memory/tab_manager.cc
diff --git a/chrome/browser/memory/tab_manager.cc b/chrome/browser/memory/tab_manager.cc
index 582b2e667099f6fa0085f6721c4b9c69a37709c8..0c2791c84d987e96ca53789920c1d43b95e58170 100644
--- a/chrome/browser/memory/tab_manager.cc
+++ b/chrome/browser/memory/tab_manager.cc
@@ -670,6 +670,23 @@ void TabManager::UpdateTimerCallback() {
PurgeAndSuspendBackgroundedTabs();
}
+bool TabManager::CanPurgeAndSuspendBackgroundedTab(
+ int64_t target_web_contents_id) const {
+ TabStripModel* model;
+ int idx = FindTabStripModelById(target_web_contents_id, &model);
+ if (idx == -1)
+ return false;
+
+ WebContents* web_contents = model->GetWebContentsAt(idx);
+
+ // Do not suspend tabs that are playing either playing audio or accessing the
+ // microphone or camera as it's too distruptive to the user experience.
+ if (IsMediaTab(web_contents))
+ return false;
+
+ return true;
+}
+
void TabManager::PurgeAndSuspendBackgroundedTabs() {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
@@ -695,6 +712,8 @@ void TabManager::PurgeAndSuspendBackgroundedTabs() {
// timers if we want necessary and sufficient signals.
if (tab.last_active > purge_and_suspend_time_threshold)
continue;
+ if (!CanPurgeAndSuspendBackgroundedTab(tab.tab_contents_id))
+ continue;
tab.render_process_host->PurgeAndSuspend();
}
}
« no previous file with comments | « chrome/browser/memory/tab_manager.h ('k') | chrome/browser/memory/tab_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698