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

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

Issue 2943953002: Don't disable MemoryPressureListener when MemoryCoordinator is enabled (Closed)
Patch Set: Fix namespace Created 3 years, 6 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 | content/browser/browser_main_loop.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/resource_coordinator/tab_manager.h" 5 #include "chrome/browser/resource_coordinator/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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "chrome/common/chrome_constants.h" 44 #include "chrome/common/chrome_constants.h"
45 #include "chrome/common/chrome_features.h" 45 #include "chrome/common/chrome_features.h"
46 #include "chrome/common/chrome_switches.h" 46 #include "chrome/common/chrome_switches.h"
47 #include "chrome/common/url_constants.h" 47 #include "chrome/common/url_constants.h"
48 #include "components/metrics/system_memory_stats_recorder.h" 48 #include "components/metrics/system_memory_stats_recorder.h"
49 #include "components/variations/variations_associated_data.h" 49 #include "components/variations/variations_associated_data.h"
50 #include "content/public/browser/browser_thread.h" 50 #include "content/public/browser/browser_thread.h"
51 #include "content/public/browser/navigation_controller.h" 51 #include "content/public/browser/navigation_controller.h"
52 #include "content/public/browser/render_process_host.h" 52 #include "content/public/browser/render_process_host.h"
53 #include "content/public/browser/web_contents.h" 53 #include "content/public/browser/web_contents.h"
54 #include "content/public/common/content_features.h"
54 #include "content/public/common/page_importance_signals.h" 55 #include "content/public/common/page_importance_signals.h"
55 56
56 #if defined(OS_CHROMEOS) 57 #if defined(OS_CHROMEOS)
57 #include "ash/multi_profile_uma.h" 58 #include "ash/multi_profile_uma.h"
58 #include "ash/shell_port.h" 59 #include "ash/shell_port.h"
59 #include "chrome/browser/resource_coordinator/tab_manager_delegate_chromeos.h" 60 #include "chrome/browser/resource_coordinator/tab_manager_delegate_chromeos.h"
60 #include "components/user_manager/user_manager.h" 61 #include "components/user_manager/user_manager.h"
61 #endif 62 #endif
62 63
63 using base::TimeDelta; 64 using base::TimeDelta;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 159
159 // MemoryPressureMonitor is not implemented on Linux so far and tabs are never 160 // MemoryPressureMonitor is not implemented on Linux so far and tabs are never
160 // discarded. 161 // discarded.
161 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) 162 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
162 if (!recent_tab_discard_timer_.IsRunning()) { 163 if (!recent_tab_discard_timer_.IsRunning()) {
163 recent_tab_discard_timer_.Start( 164 recent_tab_discard_timer_.Start(
164 FROM_HERE, TimeDelta::FromSeconds(kRecentTabDiscardIntervalSeconds), 165 FROM_HERE, TimeDelta::FromSeconds(kRecentTabDiscardIntervalSeconds),
165 this, &TabManager::RecordRecentTabDiscard); 166 this, &TabManager::RecordRecentTabDiscard);
166 } 167 }
167 start_time_ = NowTicks(); 168 start_time_ = NowTicks();
168 // Create a |MemoryPressureListener| to listen for memory events. 169 // Create a |MemoryPressureListener| to listen for memory events when
170 // MemoryCoordinator is disabled. When MemoryCoordinator is enabled
171 // it asks TabManager to tab discarding.
fmeawad 2017/06/19 19:54:59 nit: to "do" tab discarding?
bashi 2017/06/21 23:46:23 Done. Thanks!
169 base::MemoryPressureMonitor* monitor = base::MemoryPressureMonitor::Get(); 172 base::MemoryPressureMonitor* monitor = base::MemoryPressureMonitor::Get();
170 if (monitor) { 173 if (monitor && !base::FeatureList::IsEnabled(features::kMemoryCoordinator)) {
171 memory_pressure_listener_.reset(new base::MemoryPressureListener( 174 memory_pressure_listener_.reset(new base::MemoryPressureListener(
172 base::Bind(&TabManager::OnMemoryPressure, base::Unretained(this)))); 175 base::Bind(&TabManager::OnMemoryPressure, base::Unretained(this))));
173 base::MemoryPressureListener::MemoryPressureLevel level = 176 base::MemoryPressureListener::MemoryPressureLevel level =
174 monitor->GetCurrentPressureLevel(); 177 monitor->GetCurrentPressureLevel();
175 if (level == base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { 178 if (level == base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
176 OnMemoryPressure(level); 179 OnMemoryPressure(level);
177 } 180 }
178 } 181 }
179 #endif 182 #endif
180 // purge-and-suspend param is used for Purge+Suspend finch experiment 183 // purge-and-suspend param is used for Purge+Suspend finch experiment
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 // platform. 878 // platform.
876 std::string allow_multiple_discards = variations::GetVariationParamValue( 879 std::string allow_multiple_discards = variations::GetVariationParamValue(
877 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); 880 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards");
878 return (allow_multiple_discards != "true"); 881 return (allow_multiple_discards != "true");
879 #else 882 #else
880 return false; 883 return false;
881 #endif 884 #endif
882 } 885 }
883 886
884 } // namespace resource_coordinator 887 } // namespace resource_coordinator
OLDNEW
« no previous file with comments | « no previous file | content/browser/browser_main_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698