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(); |
} |
} |