| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/sessions/tab_loader.h" | 5 #include "chrome/browser/sessions/tab_loader.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/base_features.h" |
| 10 #include "base/memory/memory_coordinator_client_registry.h" | 11 #include "base/memory/memory_coordinator_client_registry.h" |
| 11 #include "base/memory/memory_coordinator_proxy.h" | 12 #include "base/memory/memory_coordinator_proxy.h" |
| 12 #include "base/memory/memory_pressure_monitor.h" | 13 #include "base/memory/memory_pressure_monitor.h" |
| 13 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 14 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 16 #include "chrome/browser/sessions/session_restore_stats_collector.h" | 17 #include "chrome/browser/sessions/session_restore_stats_collector.h" |
| 17 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "components/favicon/content/content_favicon_driver.h" | 21 #include "components/favicon/content/content_favicon_driver.h" |
| 21 #include "components/variations/variations_associated_data.h" | 22 #include "components/variations/variations_associated_data.h" |
| 22 #include "content/public/browser/navigation_controller.h" | 23 #include "content/public/browser/navigation_controller.h" |
| 23 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 24 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
| 25 #include "content/public/browser/render_widget_host.h" | 26 #include "content/public/browser/render_widget_host.h" |
| 26 #include "content/public/browser/render_widget_host_view.h" | 27 #include "content/public/browser/render_widget_host_view.h" |
| 27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 28 #include "content/public/common/content_features.h" | |
| 29 | 29 |
| 30 using content::NavigationController; | 30 using content::NavigationController; |
| 31 using content::RenderWidgetHost; | 31 using content::RenderWidgetHost; |
| 32 using content::WebContents; | 32 using content::WebContents; |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 size_t g_max_loaded_tab_count_for_testing = 0; | 36 size_t g_max_loaded_tab_count_for_testing = 0; |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 void TabLoader::HandleTabClosedOrLoaded(NavigationController* controller) { | 252 void TabLoader::HandleTabClosedOrLoaded(NavigationController* controller) { |
| 253 RemoveTab(controller); | 253 RemoveTab(controller); |
| 254 if (delegate_) | 254 if (delegate_) |
| 255 LoadNextTab(); | 255 LoadNextTab(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 bool TabLoader::ShouldStopLoadingTabs() const { | 258 bool TabLoader::ShouldStopLoadingTabs() const { |
| 259 if (g_max_loaded_tab_count_for_testing != 0 && | 259 if (g_max_loaded_tab_count_for_testing != 0 && |
| 260 started_to_load_count_ >= g_max_loaded_tab_count_for_testing) | 260 started_to_load_count_ >= g_max_loaded_tab_count_for_testing) |
| 261 return true; | 261 return true; |
| 262 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) | 262 if (base::FeatureList::IsEnabled(base::features::kMemoryCoordinator)) |
| 263 return base::MemoryCoordinatorProxy::GetInstance()->GetCurrentMemoryState() | 263 return base::MemoryCoordinatorProxy::GetInstance()->GetCurrentMemoryState() |
| 264 != base::MemoryState::NORMAL; | 264 != base::MemoryState::NORMAL; |
| 265 if (base::MemoryPressureMonitor::Get()) { | 265 if (base::MemoryPressureMonitor::Get()) { |
| 266 return base::MemoryPressureMonitor::Get()->GetCurrentPressureLevel() != | 266 return base::MemoryPressureMonitor::Get()->GetCurrentPressureLevel() != |
| 267 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE; | 267 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE; |
| 268 } | 268 } |
| 269 return false; | 269 return false; |
| 270 } | 270 } |
| 271 | 271 |
| 272 void TabLoader::OnMemoryPressure( | 272 void TabLoader::OnMemoryPressure( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 // memory pressure. | 308 // memory pressure. |
| 309 stats_collector_->DeferTab(tab); | 309 stats_collector_->DeferTab(tab); |
| 310 } | 310 } |
| 311 // By calling |LoadNextTab| explicitly, we make sure that the | 311 // By calling |LoadNextTab| explicitly, we make sure that the |
| 312 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. | 312 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. |
| 313 LoadNextTab(); | 313 LoadNextTab(); |
| 314 } | 314 } |
| 315 | 315 |
| 316 // static | 316 // static |
| 317 TabLoader* TabLoader::shared_tab_loader_ = nullptr; | 317 TabLoader* TabLoader::shared_tab_loader_ = nullptr; |
| OLD | NEW |