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 f89f8e485d3ec9b492c5bac5f113e00e77bf5392..262f5fea4455adf0922f5731faf0f58e2b4bee45 100644 |
| --- a/chrome/browser/memory/tab_manager.cc |
| +++ b/chrome/browser/memory/tab_manager.cc |
| @@ -159,21 +159,27 @@ TabManager::~TabManager() { |
| Stop(); |
| } |
| +// Check the variation parameter to see if a tab be discarded more than once. |
| +// Default is to only discard once per tab. |
| +bool TabManager::CheckMultipleDiscards() { |
| +#if defined(OS_WIN) || defined(OS_MACOSX) |
| + std::string allow_multiple_discards = variations::GetVariationParamValue( |
| + features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); |
| + return (allow_multiple_discards == "true"); |
| + |
| +#elif defined(OS_CHROMEOS) |
| + // On Chrome OS, tab manager is always started and tabs can be discarded more |
| + // than once. |
| + return false; |
| +#endif |
|
Georges Khalil
2016/05/16 18:41:22
Let's simplify this. For CHROMEOS, always return f
Anderson Silva
2016/05/16 19:39:06
I've also thought about that. I didn't do it thoug
|
| +} |
| + |
| void TabManager::Start() { |
| #if defined(OS_WIN) || defined(OS_MACOSX) |
| // If the feature is not enabled, do nothing. |
| if (!base::FeatureList::IsEnabled(features::kAutomaticTabDiscarding)) |
| return; |
| - // Check the variation parameter to see if a tab be discarded more than once. |
| - // Default is to only discard once per tab. |
| - std::string allow_multiple_discards = variations::GetVariationParamValue( |
| - features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); |
| - if (allow_multiple_discards == "true") |
| - discard_once_ = true; |
| - else |
| - discard_once_ = false; |
| - |
| // Check the variation parameter to see if a tab is to be protected for an |
| // amount of time after being backgrounded. The value is in seconds. |
| std::string minimum_protection_time_string = |
| @@ -188,13 +194,11 @@ void TabManager::Start() { |
| base::TimeDelta::FromSeconds(minimum_protection_time_seconds); |
| } |
| } |
| - |
| -#elif defined(OS_CHROMEOS) |
| - // On Chrome OS, tab manager is always started and tabs can be discarded more |
| - // than once. |
| - discard_once_ = false; |
| #endif |
|
Georges Khalil
2016/05/16 18:41:22
Pasted by mistake?
Anderson Silva
2016/05/16 19:39:06
No, that's actually because of the #if defined WIN
|
| + // Check if multiple discards are allowed. |
| + discard_once_ = CheckMultipleDiscards(); |
|
Georges Khalil
2016/05/16 18:41:22
The logic here is inverted, as discard_once_ would
Anderson Silva
2016/05/16 19:39:06
You're right. But then I think we might have an is
|
| + |
| if (!update_timer_.IsRunning()) { |
| update_timer_.Start(FROM_HERE, |
| TimeDelta::FromSeconds(kAdjustmentIntervalSeconds), |
| @@ -561,8 +565,8 @@ void TabManager::PurgeAndSuspendBackgroundedTabs() { |
| } |
| if (purge_and_suspend_time <= 0) |
| return; |
| - auto purge_and_suspend_time_threshold = NowTicks() - |
| - base::TimeDelta::FromSeconds(purge_and_suspend_time); |
| + auto purge_and_suspend_time_threshold = |
| + NowTicks() - base::TimeDelta::FromSeconds(purge_and_suspend_time); |
| auto tab_stats = GetUnsortedTabStats(); |
| for (auto& tab : tab_stats) { |
| if (!tab.render_process_host->IsProcessBackgrounded()) |