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

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

Issue 1895773002: Move responsiblity of tab suspending from renderer to TabManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix time Created 4 years, 8 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
Index: chrome/browser/memory/tab_manager.cc
diff --git a/chrome/browser/memory/tab_manager.cc b/chrome/browser/memory/tab_manager.cc
index a2299862de6deec44a10eb2a4db511c985a7d215..a5610185afee6fcff6fefe766f2a3758829756a8 100644
--- a/chrome/browser/memory/tab_manager.cc
+++ b/chrome/browser/memory/tab_manager.cc
@@ -480,7 +480,7 @@ void TabManager::AddTabStats(const TabStripModel* model,
bool is_app,
bool active_model,
TabStatsList* stats_list) {
-for (int i = 0; i < model->count(); i++) {
+ for (int i = 0; i < model->count(); i++) {
WebContents* contents = model->GetWebContentsAt(i);
if (!contents->IsCrashed()) {
TabStats stats;
@@ -532,6 +532,20 @@ void TabManager::UpdateTimerCallback() {
}
last_adjust_time_ = NowTicks();
+#if defined(OS_ANDROID)
Georges Khalil 2016/04/19 13:55:19 Move this to an android delegate, similar to chrom
+ auto tab_stats = GetUnsortedTabStats();
+ for (auto& tab : tab_stats) {
+ if (!tab.render_process_host->IsProcessBackgrounded())
+ continue;
+ if (NowTicks() - tab.last_active <
+ base::TimeDelta::FromSeconds(
+ kSuspendTimersWhenBackgroundedDelayInSeconds)) {
+ continue;
+ }
+ tab.render_process_host->Suspend();
+ }
+#endif
+
#if defined(OS_CHROMEOS)
TabStatsList stats_list = GetTabStats();
// This starts the CrOS specific OOM adjustments in /proc/<pid>/oom_score_adj.

Powered by Google App Engine
This is Rietveld 408576698