Chromium Code Reviews| Index: content/browser/browser_main_loop.cc |
| diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc |
| index 17c6ebedb1ff5c38473b8ce8f60fdef1305d5d12..7433260f85bf3fb1137e7911527ff16a8af87a1b 100644 |
| --- a/content/browser/browser_main_loop.cc |
| +++ b/content/browser/browser_main_loop.cc |
| @@ -17,6 +17,7 @@ |
| #include "base/profiler/scoped_profile.h" |
| #include "base/run_loop.h" |
| #include "base/strings/string_number_conversions.h" |
| +#include "base/strings/string_split.h" |
| #include "base/system_monitor/system_monitor.h" |
| #include "base/thread_task_runner_handle.h" |
| #include "base/threading/thread_restrictions.h" |
| @@ -101,6 +102,7 @@ |
| #include <commctrl.h> |
| #include <shellapi.h> |
| +#include "base/win/memory_pressure_monitor.h" |
| #include "content/browser/system_message_window_win.h" |
| #include "content/common/sandbox_win.h" |
| #include "net/base/winsock_init.h" |
| @@ -299,6 +301,37 @@ NOINLINE void ResetThread_IndexedDb(scoped_ptr<base::Thread> thread) { |
| MSVC_POP_WARNING() |
| MSVC_ENABLE_OPTIMIZE(); |
| +#if defined(OS_WIN) |
| +// Creates a memory pressure monitor using automatic thresholds, or those |
| +// specified on the command-line. Ownership is passed to the caller. |
| +base::win::MemoryPressureMonitor* CreateWinMemoryPressureMonitor( |
| + const base::CommandLine& parsed_command_line) { |
| + std::vector<std::string> thresholds; |
| + base::SplitString( |
| + parsed_command_line.GetSwitchValueASCII( |
| + switches::kMemoryPressureThresholdsMb), |
| + ',', |
| + &thresholds); |
| + |
| + int moderate_threshold_mb = 0; |
| + int critical_threshold_mb = 0; |
| + if (thresholds.size() == 2 && |
| + base::StringToInt(thresholds[0], &moderate_threshold_mb) && |
| + base::StringToInt(thresholds[1], &critical_threshold_mb) && |
| + moderate_threshold_mb >= critical_threshold_mb && |
| + critical_threshold_mb >= 0) { |
| + VLOG(0) << "Using custom thresholds for MemoryPressureMonitor (moderate=" |
|
grt (UTC plus 2)
2015/05/07 02:12:12
this sort of always-on logging (VLOG vs DVLOG) is
chrisha
2015/05/07 21:17:36
Removed.
|
| + << moderate_threshold_mb << "MB, critical=" |
| + << critical_threshold_mb << "MB)"; |
| + return new base::win::MemoryPressureMonitor(moderate_threshold_mb, |
| + critical_threshold_mb); |
| + } |
| + |
| + // In absence of valid switches use the automatic defaults. |
| + return new base::win::MemoryPressureMonitor(); |
| +} |
| +#endif // defined(OS_WIN) |
| + |
| } // namespace |
| // The currently-running BrowserMainLoop. There can be one or zero. |
| @@ -613,6 +646,9 @@ int BrowserMainLoop::PreCreateThreads() { |
| } |
| #elif defined(OS_MACOSX) && !defined(OS_IOS) |
| memory_pressure_monitor_.reset(new base::MemoryPressureMonitorMac()); |
| +#elif defined(OS_WIN) |
| + memory_pressure_monitor_.reset(CreateWinMemoryPressureMonitor( |
| + parsed_command_line_)); |
| #endif |
| #if defined(ENABLE_PLUGINS) |