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 eef6d4d0351e243cab575989a2875caf4a4bf729..966c6163305129ee43e6b1c21f64e2e314eb79b2 100644 |
| --- a/chrome/browser/memory/tab_manager.cc |
| +++ b/chrome/browser/memory/tab_manager.cc |
| @@ -165,15 +165,6 @@ void TabManager::Start() { |
| 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_ = false; |
| - else |
| - discard_once_ = true; |
| - |
| // 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 +179,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 |
| + // Check if only one discard is allowed. |
| + discard_once_ = ShouldOnlyDiscardOnce(); |
| + |
| if (!update_timer_.IsRunning()) { |
| update_timer_.Start(FROM_HERE, |
| TimeDelta::FromSeconds(kAdjustmentIntervalSeconds), |
| @@ -561,8 +550,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()) |
| @@ -858,6 +847,21 @@ bool TabManager::DiscardTabImpl() { |
| return false; |
| } |
| +// Check the variation parameter to see if a tab can be discarded only once or |
| +// multiple times. |
| +// Default is to only discard once per tab. |
| +bool TabManager::ShouldOnlyDiscardOnce() { |
| +#if defined(OS_CHROMEOS) |
| + // On Chrome OS, tab manager is always started and tabs can be discarded more |
|
Georges Khalil
2016/05/17 15:18:01
nit: change this comment to
On Chrome OS, tabs ca
Anderson Silva
2016/05/17 15:34:06
Acknowledged.
|
| + // than once. |
| + return false; |
| +#endif |
|
Georges Khalil
2016/05/17 15:18:01
You need an #elif otherwise you'll get a warning o
Anderson Silva
2016/05/17 15:34:06
Acknowledged.
|
| + |
| + std::string allow_multiple_discards = variations::GetVariationParamValue( |
| + features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); |
| + return (allow_multiple_discards == "false"); |
|
Georges Khalil
2016/05/17 15:18:01
This should be:
return (allow_multiple_discards !=
Anderson Silva
2016/05/17 15:34:07
Acknowledged.
|
| +} |
| + |
| // Things to collect on the browser thread (because TabStripModel isn't thread |
| // safe): |
| // 1) whether or not a tab is pinned |