summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshrike <shrike@chromium.org>2015-10-26 15:46:13 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-26 22:47:40 +0000
commitc4d79a5203c67b96e86168ee62c657ef9053996a (patch)
treee082806ac71dcb0a52ab59050fc10aabbf11aa4d
parentaff7d9d8b12a05fd87eaaef0c3206342ecdd82c8 (diff)
downloadchromium_src-c4d79a5203c67b96e86168ee62c657ef9053996a.zip
chromium_src-c4d79a5203c67b96e86168ee62c657ef9053996a.tar.gz
chromium_src-c4d79a5203c67b96e86168ee62c657ef9053996a.tar.bz2
With this change, Intelligent Session Restore checks the memory pressure
level before restoring each tab and aborts tab restore if pressure exists. This is especially important on the Mac where the delay between memory pressure events and receiving notifications of those events can be so long that tab restore completes before the notification arrives. BUG=547215 Review URL: https://codereview.chromium.org/1421903002 Cr-Commit-Position: refs/heads/master@{#356157}
-rw-r--r--chrome/browser/sessions/tab_loader.cc31
1 files changed, 18 insertions, 13 deletions
diff --git a/chrome/browser/sessions/tab_loader.cc b/chrome/browser/sessions/tab_loader.cc
index 05ec0bf..f645c86 100644
--- a/chrome/browser/sessions/tab_loader.cc
+++ b/chrome/browser/sessions/tab_loader.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include <string>
+#include "base/memory/memory_pressure_monitor.h"
#include "base/metrics/histogram.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/sessions/session_restore_stats_collector.h"
@@ -22,12 +23,6 @@
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
-#if defined(OS_WIN)
-#include "base/memory/memory_pressure_monitor_win.h"
-#elif defined(OS_MACOSX) && !defined(OS_IOS)
-#include "base/memory/memory_pressure_monitor_mac.h"
-#endif
-
using content::NavigationController;
using content::RenderWidgetHost;
using content::WebContents;
@@ -152,6 +147,19 @@ void TabLoader::LoadNextTab() {
// loading.
CHECK(delegate_);
if (!tabs_to_load_.empty()) {
+ // Check the memory pressure before restoring the next tab, and abort if
+ // there is pressure. This is important on the Mac because of the sometimes
+ // large delay between a memory pressure event and receiving a notification
+ // of that event (in that case tab restore can trigger memory pressure but
+ // will complete before the notification arrives).
+ base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level =
+ CurrentMemoryPressureLevel();
+ if (memory_pressure_level !=
+ base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE) {
+ OnMemoryPressure(memory_pressure_level);
+ return;
+ }
+
NavigationController* controller = tabs_to_load_.front();
DCHECK(controller);
tabs_loading_.insert(controller);
@@ -233,14 +241,11 @@ base::MemoryPressureListener::MemoryPressureLevel
// Check for explicit memory pressure integration.
std::string react_to_memory_pressure = variations::GetVariationParamValue(
"IntelligentSessionRestore", "ReactToMemoryPressure");
- if (react_to_memory_pressure == "true") {
-#if defined(OS_WIN)
- return base::win::MemoryPressureMonitor::Get()->GetCurrentPressureLevel();
-#else
- return base::mac::MemoryPressureMonitor::Get()->GetCurrentPressureLevel();
-#endif
- }
+ if (react_to_memory_pressure != "true")
+ return base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE;
#endif // defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS))
+ if (base::MemoryPressureMonitor::Get())
+ return base::MemoryPressureMonitor::Get()->GetCurrentPressureLevel();
return base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE;
}