| 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..2f491f4c042f68c7dabd6c717df2906adb35b7f3 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_ = CanOnlyDiscardOnce();
|
| +
|
| 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,23 @@ 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::CanOnlyDiscardOnce() {
|
| +#if defined(OS_WIN) || defined(OS_MACOSX)
|
| + // On Windows and MacOS, default to discarding only once unless otherwise
|
| + // specified by the variation parameter.
|
| + // TODO(georgesak): Add Linux when automatic discarding is enabled for that
|
| + // platform.
|
| + std::string allow_multiple_discards = variations::GetVariationParamValue(
|
| + features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards");
|
| + return (allow_multiple_discards != "true");
|
| +#else
|
| + return false;
|
| +#endif
|
| +}
|
| +
|
| // Things to collect on the browser thread (because TabStripModel isn't thread
|
| // safe):
|
| // 1) whether or not a tab is pinned
|
|
|