Chromium Code Reviews| 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/metrics/field_trial.h" | |
| 10 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 12 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_finder.h" | 14 #include "chrome/browser/ui/browser_finder.h" |
| 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 15 #include "content/public/browser/navigation_controller.h" | 16 #include "content/public/browser/navigation_controller.h" |
| 16 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 17 #include "content/public/browser/notification_types.h" | 18 #include "content/public/browser/notification_types.h" |
| 18 #include "content/public/browser/render_widget_host.h" | 19 #include "content/public/browser/render_widget_host.h" |
| 19 #include "content/public/browser/render_widget_host_view.h" | 20 #include "content/public/browser/render_widget_host_view.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 } | 177 } |
| 177 | 178 |
| 178 void TabLoader::HandleTabClosedOrLoaded(NavigationController* controller) { | 179 void TabLoader::HandleTabClosedOrLoaded(NavigationController* controller) { |
| 179 RemoveTab(controller); | 180 RemoveTab(controller); |
| 180 if (delegate_ && loading_enabled_) | 181 if (delegate_ && loading_enabled_) |
| 181 LoadNextTab(); | 182 LoadNextTab(); |
| 182 } | 183 } |
| 183 | 184 |
| 184 void TabLoader::OnMemoryPressure( | 185 void TabLoader::OnMemoryPressure( |
| 185 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { | 186 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { |
| 187 // On Windows and Mac this mechanism is only experimentally enabled. | |
| 188 #if defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS)) | |
|
sky
2015/05/08 17:37:24
The problem with memory pressure or network discon
| |
| 189 // If memory pressure integration isn't explicitly enabled then ignore these | |
| 190 // calls. | |
| 191 std::string react_to_memory_pressure = variations::GetVariationParamValue( | |
| 192 "IntelligentSessionRestore", "ReactToMemoryPressure"); | |
| 193 if (react_to_memory_pressure != "true") | |
| 194 return; | |
| 195 #endif | |
| 196 | |
| 186 // When receiving a resource pressure level warning, we stop pre-loading more | 197 // When receiving a resource pressure level warning, we stop pre-loading more |
| 187 // tabs since we are running in danger of loading more tabs by throwing out | 198 // tabs since we are running in danger of loading more tabs by throwing out |
| 188 // old ones. | 199 // old ones. |
| 189 if (tabs_to_load_.empty()) | 200 if (tabs_to_load_.empty()) |
| 190 return; | 201 return; |
| 191 // Stop the timer and suppress any tab loads while we clean the list. | 202 // Stop the timer and suppress any tab loads while we clean the list. |
| 192 SetTabLoadingEnabled(false); | 203 SetTabLoadingEnabled(false); |
| 193 while (!tabs_to_load_.empty()) { | 204 while (!tabs_to_load_.empty()) { |
| 194 NavigationController* controller = tabs_to_load_.front(); | 205 NavigationController* controller = tabs_to_load_.front(); |
| 195 tabs_to_load_.pop_front(); | 206 tabs_to_load_.pop_front(); |
| 196 RemoveTab(controller); | 207 RemoveTab(controller); |
| 197 } | 208 } |
| 198 // By calling |LoadNextTab| explicitly, we make sure that the | 209 // By calling |LoadNextTab| explicitly, we make sure that the |
| 199 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. | 210 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. |
| 200 LoadNextTab(); | 211 LoadNextTab(); |
| 201 } | 212 } |
| 202 | 213 |
| 203 // static | 214 // static |
| 204 TabLoader* TabLoader::shared_tab_loader_ = nullptr; | 215 TabLoader* TabLoader::shared_tab_loader_ = nullptr; |
| OLD | NEW |