Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6314)

Unified Diff: chrome/browser/memory/tab_manager.cc

Issue 1978343002: [TabManager] Start function refactoring. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« chrome/browser/memory/tab_manager.h ('K') | « chrome/browser/memory/tab_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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())
« chrome/browser/memory/tab_manager.h ('K') | « chrome/browser/memory/tab_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698