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..1c5561b631eb95273d7b5bcb1156e96da1965799 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_ = 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 +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 multiple discards are allowed. |
| + discard_once_ = !AllowMultipleDiscards(); |
| + |
| 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,20 @@ bool TabManager::DiscardTabImpl() { |
| return false; |
| } |
| +// Check the variation parameter to see if a tab be discarded more than once. |
| +// Default is to only discard once per tab. |
| +bool TabManager::AllowMultipleDiscards() { |
|
Georges Khalil
2016/05/17 13:49:07
Rename this to ShouldOnlyDiscardOnce and flip logi
Anderson Silva
2016/05/17 15:12:02
Acknowledged.
|
| +#if defined(OS_CHROMEOS) |
| + // On Chrome OS, tab manager is always started and tabs can be discarded more |
| + // than once. |
| + return true; |
| +#endif |
| + |
| + std::string allow_multiple_discards = variations::GetVariationParamValue( |
| + features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); |
| + return (allow_multiple_discards == "true"); |
| +} |
| + |
| // Things to collect on the browser thread (because TabStripModel isn't thread |
| // safe): |
| // 1) whether or not a tab is pinned |