| OLD | NEW |
| 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 Loading... |
| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 184 |
| 184 // MemoryPressureMonitor is not implemented on Linux so far and tabs are never | 185 // MemoryPressureMonitor is not implemented on Linux so far and tabs are never |
| 185 // discarded. | 186 // discarded. |
| 186 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) | 187 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) |
| 187 if (!recent_tab_discard_timer_.IsRunning()) { | 188 if (!recent_tab_discard_timer_.IsRunning()) { |
| 188 recent_tab_discard_timer_.Start( | 189 recent_tab_discard_timer_.Start( |
| 189 FROM_HERE, TimeDelta::FromSeconds(kRecentTabDiscardIntervalSeconds), | 190 FROM_HERE, TimeDelta::FromSeconds(kRecentTabDiscardIntervalSeconds), |
| 190 this, &TabManager::RecordRecentTabDiscard); | 191 this, &TabManager::RecordRecentTabDiscard); |
| 191 } | 192 } |
| 192 start_time_ = NowTicks(); | 193 start_time_ = NowTicks(); |
| 193 // Create a |MemoryPressureListener| to listen for memory events. | 194 // Create a |MemoryPressureListener| to listen for memory events when |
| 195 // MemoryCoordinator is disabled. When MemoryCoordinator is enabled |
| 196 // it asks TabManager to do tab discarding. |
| 194 base::MemoryPressureMonitor* monitor = base::MemoryPressureMonitor::Get(); | 197 base::MemoryPressureMonitor* monitor = base::MemoryPressureMonitor::Get(); |
| 195 if (monitor) { | 198 if (monitor && !base::FeatureList::IsEnabled(features::kMemoryCoordinator)) { |
| 196 memory_pressure_listener_.reset(new base::MemoryPressureListener( | 199 memory_pressure_listener_.reset(new base::MemoryPressureListener( |
| 197 base::Bind(&TabManager::OnMemoryPressure, base::Unretained(this)))); | 200 base::Bind(&TabManager::OnMemoryPressure, base::Unretained(this)))); |
| 198 base::MemoryPressureListener::MemoryPressureLevel level = | 201 base::MemoryPressureListener::MemoryPressureLevel level = |
| 199 monitor->GetCurrentPressureLevel(); | 202 monitor->GetCurrentPressureLevel(); |
| 200 if (level == base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { | 203 if (level == base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { |
| 201 OnMemoryPressure(level); | 204 OnMemoryPressure(level); |
| 202 } | 205 } |
| 203 } | 206 } |
| 204 #endif | 207 #endif |
| 205 // purge-and-suspend param is used for Purge+Suspend finch experiment | 208 // purge-and-suspend param is used for Purge+Suspend finch experiment |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 browser_info.window_is_minimized = browser->window()->IsMinimized(); | 900 browser_info.window_is_minimized = browser->window()->IsMinimized(); |
| 898 browser_info.window_bounds = browser->window()->GetBounds(); | 901 browser_info.window_bounds = browser->window()->GetBounds(); |
| 899 browser_info.browser_is_app = browser->is_app(); | 902 browser_info.browser_is_app = browser->is_app(); |
| 900 browser_info_list.push_back(browser_info); | 903 browser_info_list.push_back(browser_info); |
| 901 } | 904 } |
| 902 | 905 |
| 903 return browser_info_list; | 906 return browser_info_list; |
| 904 } | 907 } |
| 905 | 908 |
| 906 } // namespace resource_coordinator | 909 } // namespace resource_coordinator |
| OLD | NEW |