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

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

Issue 2389683002: Modify PurgeAndSuspend to see WebContents (Closed)
Patch Set: 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') | no next file » | 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..e7a27b896fe08953bbe1c5a7df847445fa5d15c7 100644
--- a/chrome/browser/memory/tab_manager.cc
+++ b/chrome/browser/memory/tab_manager.cc
@@ -670,6 +670,31 @@ 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;
+
+ if (web_contents->GetContentsMimeType() == "application/pdf")
haraken 2016/10/03 06:32:35 I don't think this check is needed. It will be saf
tasak 2016/10/03 07:08:54 Done.
+ return false;
+
+ // Do not purge and suspend a tab that was explicitly disallowed to.
+ // Note: reused tab discarding logic.
+ if (!IsTabAutoDiscardable(web_contents))
+ return false;
+
haraken 2016/10/03 06:32:35 I'd add the minimum_protection_time_ check we have
tasak 2016/10/03 07:08:54 Done.
+ return true;
+}
+
void TabManager::PurgeAndSuspendBackgroundedTabs() {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
@@ -695,6 +720,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') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698