Chromium Code Reviews| Index: chrome/browser/memory/tab_manager.cc |
| diff --git a/chrome/browser/memory/tab_manager.cc b/chrome/browser/memory/tab_manager.cc |
| index 207ae5d7bfd86e6a6951965eb4f1f980d4014ff3..c551175455530b5f700808ae935ade0e5fe66d32 100644 |
| --- a/chrome/browser/memory/tab_manager.cc |
| +++ b/chrome/browser/memory/tab_manager.cc |
| @@ -221,6 +221,17 @@ void TabManager::Start() { |
| } |
| } |
| #endif |
| + std::string purge_and_suspend_time = variations::GetVariationParamValue( |
|
chrisha
2016/11/24 17:13:09
Should we have a default time that this is initial
tasak
2016/11/25 01:15:24
As far as I understand, base::TimeDelta() initiali
chrisha
2016/11/29 14:13:57
Okay, that makes sense. I was thinking that there'
tasak
2016/12/02 02:49:24
Yes... currently the zero means that the purge+sus
|
| + "PurgeAndSuspend", "purge-and-suspend-time"); |
| + if (!purge_and_suspend_time.empty()) { |
| + int time_to_first_suspension_sec = 0; |
| + if (base::StringToInt(purge_and_suspend_time, |
| + &time_to_first_suspension_sec)) { |
| + if (time_to_first_suspension_sec > 0) |
| + time_to_first_suspension_ = |
| + base::TimeDelta::FromSeconds(time_to_first_suspension_sec); |
| + } |
| + } |
| } |
| void TabManager::Stop() { |
| @@ -731,21 +742,10 @@ TabManager::PurgeAndSuspendState TabManager::GetNextPurgeAndSuspendState( |
| } |
| void TabManager::PurgeAndSuspendBackgroundedTabs() { |
| - const base::CommandLine& command_line = |
| - *base::CommandLine::ForCurrentProcess(); |
| - if (!command_line.HasSwitch(switches::kPurgeAndSuspendTime)) |
| - return; |
| - int purge_and_suspend_time = 0; |
| - if (!base::StringToInt( |
| - command_line.GetSwitchValueASCII(switches::kPurgeAndSuspendTime), |
| - &purge_and_suspend_time)) { |
| - return; |
| - } |
| - if (purge_and_suspend_time <= 0) |
| + if (time_to_first_suspension_.InSeconds() <= 0) |
|
chrisha
2016/11/24 17:13:09
Do we need this check? This function simply should
tasak
2016/11/25 01:15:24
I would like to confirm. You mean, we should check
tasak
2016/11/25 01:19:44
So my first patch is trying to always record B.
I
chrisha
2016/11/29 14:13:57
I'm not sure I follow this entire chain of logic?
tasak
2016/12/02 02:49:24
I see.... I'm trying to keep the existing behavior
|
| return; |
| + |
| base::TimeTicks current_time = NowTicks(); |
| - base::TimeDelta time_to_first_suspension = |
| - base::TimeDelta::FromSeconds(purge_and_suspend_time); |
| auto tab_stats = GetUnsortedTabStats(); |
| for (auto& tab : tab_stats) { |
| if (!tab.render_process_host->IsProcessBackgrounded()) |
| @@ -766,7 +766,7 @@ void TabManager::PurgeAndSuspendBackgroundedTabs() { |
| tab.last_hidden < |
| GetWebContentsData(content)->LastPurgeAndSuspendModifiedTime()); |
| PurgeAndSuspendState next_state = GetNextPurgeAndSuspendState( |
| - content, current_time, time_to_first_suspension); |
| + content, current_time, time_to_first_suspension_); |
| if (current_state == next_state) |
| continue; |