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

Side by Side Diff: chrome/browser/memory/tab_manager.cc

Issue 2373653002: [TabManager] Enable tab discarding by default. (Closed)
Patch Set: . Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/memory/tab_manager_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/memory/tab_manager.h" 5 #include "chrome/browser/memory/tab_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 } // namespace 129 } // namespace
130 130
131 //////////////////////////////////////////////////////////////////////////////// 131 ////////////////////////////////////////////////////////////////////////////////
132 // TabManager 132 // TabManager
133 133
134 TabManager::TabManager() 134 TabManager::TabManager()
135 : discard_count_(0), 135 : discard_count_(0),
136 recent_tab_discard_(false), 136 recent_tab_discard_(false),
137 discard_once_(false), 137 discard_once_(false),
138 minimum_protection_time_(base::TimeDelta::FromMinutes(10)),
138 browser_tab_strip_tracker_(this, nullptr, nullptr), 139 browser_tab_strip_tracker_(this, nullptr, nullptr),
139 test_tick_clock_(nullptr), 140 test_tick_clock_(nullptr),
140 under_memory_pressure_(false), 141 under_memory_pressure_(false),
141 weak_ptr_factory_(this) { 142 weak_ptr_factory_(this) {
142 #if defined(OS_CHROMEOS) 143 #if defined(OS_CHROMEOS)
143 delegate_.reset(new TabManagerDelegate(weak_ptr_factory_.GetWeakPtr())); 144 delegate_.reset(new TabManagerDelegate(weak_ptr_factory_.GetWeakPtr()));
144 #endif 145 #endif
145 browser_tab_strip_tracker_.Init( 146 browser_tab_strip_tracker_.Init(
146 BrowserTabStripTracker::InitWith::ALL_BROWERS); 147 BrowserTabStripTracker::InitWith::ALL_BROWERS);
147 148
148 // Set up default callbacks. These may be overridden post-construction as 149 // Set up default callbacks. These may be overridden post-construction as
149 // testing seams. 150 // testing seams.
150 get_current_pressure_level_ = base::Bind(&GetCurrentPressureLevel); 151 get_current_pressure_level_ = base::Bind(&GetCurrentPressureLevel);
151 notify_renderer_process_ = base::Bind(&NotifyRendererProcess); 152 notify_renderer_process_ = base::Bind(&NotifyRendererProcess);
152 } 153 }
153 154
154 TabManager::~TabManager() { 155 TabManager::~TabManager() {
155 Stop(); 156 Stop();
156 } 157 }
157 158
158 void TabManager::Start() { 159 void TabManager::Start() {
159 #if defined(OS_WIN) || defined(OS_MACOSX) 160 #if defined(OS_WIN) || defined(OS_MACOSX)
160 // If the feature is not enabled, do nothing. 161 // Note that discarding is now enabled by default. This check is kept as a
162 // kill switch.
163 // TODO(georgesak): remote this when deemed not needed anymore.
161 if (!base::FeatureList::IsEnabled(features::kAutomaticTabDiscarding)) 164 if (!base::FeatureList::IsEnabled(features::kAutomaticTabDiscarding))
162 return; 165 return;
163 166
164 // Check the variation parameter to see if a tab is to be protected for an 167 // Check the variation parameter to see if a tab is to be protected for an
165 // amount of time after being backgrounded. The value is in seconds. 168 // amount of time after being backgrounded. The value is in seconds. Default
169 // is 10 minutes if the variation is absent.
166 std::string minimum_protection_time_string = 170 std::string minimum_protection_time_string =
167 variations::GetVariationParamValue(features::kAutomaticTabDiscarding.name, 171 variations::GetVariationParamValue(features::kAutomaticTabDiscarding.name,
168 "MinimumProtectionTime"); 172 "MinimumProtectionTime");
169 if (!minimum_protection_time_string.empty()) { 173 if (!minimum_protection_time_string.empty()) {
170 unsigned int minimum_protection_time_seconds = 0; 174 unsigned int minimum_protection_time_seconds = 0;
171 if (base::StringToUint(minimum_protection_time_string, 175 if (base::StringToUint(minimum_protection_time_string,
172 &minimum_protection_time_seconds)) { 176 &minimum_protection_time_seconds)) {
173 if (minimum_protection_time_seconds > 0) 177 if (minimum_protection_time_seconds > 0)
174 minimum_protection_time_ = 178 minimum_protection_time_ =
175 base::TimeDelta::FromSeconds(minimum_protection_time_seconds); 179 base::TimeDelta::FromSeconds(minimum_protection_time_seconds);
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 // platform. 939 // platform.
936 std::string allow_multiple_discards = variations::GetVariationParamValue( 940 std::string allow_multiple_discards = variations::GetVariationParamValue(
937 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); 941 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards");
938 return (allow_multiple_discards != "true"); 942 return (allow_multiple_discards != "true");
939 #else 943 #else
940 return false; 944 return false;
941 #endif 945 #endif
942 } 946 }
943 947
944 } // namespace memory 948 } // namespace memory
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/memory/tab_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698