Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Side by Side Diff: content/browser/browser_main_loop.cc

Issue 1250093006: Added memory pressure monitor for linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Uncomment ::Get functionality Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/memory/memory_pressure_monitor_win_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/browser_main_loop.h" 5 #include "content/browser/browser_main_loop.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 #include "content/browser/screen_orientation/screen_orientation_delegate_android .h" 91 #include "content/browser/screen_orientation/screen_orientation_delegate_android .h"
92 #include "content/public/browser/screen_orientation_provider.h" 92 #include "content/public/browser/screen_orientation_provider.h"
93 #include "ui/gl/gl_surface.h" 93 #include "ui/gl/gl_surface.h"
94 #endif 94 #endif
95 95
96 #if defined(OS_MACOSX) 96 #if defined(OS_MACOSX)
97 #include "media/base/mac/avfoundation_glue.h" 97 #include "media/base/mac/avfoundation_glue.h"
98 #endif 98 #endif
99 99
100 #if defined(OS_MACOSX) && !defined(OS_IOS) 100 #if defined(OS_MACOSX) && !defined(OS_IOS)
101 #include "base/memory/memory_pressure_monitor_mac.h"
102 #include "content/browser/bootstrap_sandbox_mac.h" 101 #include "content/browser/bootstrap_sandbox_mac.h"
103 #include "content/browser/browser_io_surface_manager_mac.h" 102 #include "content/browser/browser_io_surface_manager_mac.h"
104 #include "content/browser/cocoa/system_hotkey_helper_mac.h" 103 #include "content/browser/cocoa/system_hotkey_helper_mac.h"
105 #include "content/browser/compositor/browser_compositor_view_mac.h" 104 #include "content/browser/compositor/browser_compositor_view_mac.h"
106 #include "content/browser/in_process_io_surface_manager_mac.h" 105 #include "content/browser/in_process_io_surface_manager_mac.h"
107 #include "content/browser/theme_helper_mac.h" 106 #include "content/browser/theme_helper_mac.h"
108 #endif 107 #endif
109 108
110 #if defined(OS_WIN) 109 #if defined(OS_WIN)
111 #include <windows.h> 110 #include <windows.h>
112 #include <commctrl.h> 111 #include <commctrl.h>
113 #include <shellapi.h> 112 #include <shellapi.h>
114 113
115 #include "base/memory/memory_pressure_monitor_win.h"
116 #include "content/browser/system_message_window_win.h" 114 #include "content/browser/system_message_window_win.h"
117 #include "content/common/sandbox_win.h" 115 #include "content/common/sandbox_win.h"
118 #include "net/base/winsock_init.h" 116 #include "net/base/winsock_init.h"
119 #include "ui/base/l10n/l10n_util_win.h" 117 #include "ui/base/l10n/l10n_util_win.h"
120 #endif 118 #endif
121 119
122 #if defined(OS_CHROMEOS) 120 #if defined(OS_CHROMEOS)
123 #include "base/memory/memory_pressure_monitor_chromeos.h"
124 #include "chromeos/chromeos_switches.h" 121 #include "chromeos/chromeos_switches.h"
125 #endif 122 #endif
126 123
127 #if defined(USE_GLIB) 124 #if defined(USE_GLIB)
128 #include <glib-object.h> 125 #include <glib-object.h>
129 #endif 126 #endif
130 127
131 #if defined(OS_LINUX) && defined(USE_UDEV) 128 #if defined(OS_LINUX) && defined(USE_UDEV)
132 #include "content/browser/device_monitor_udev.h" 129 #include "content/browser/device_monitor_udev.h"
133 #elif defined(OS_MACOSX) && !defined(OS_IOS) 130 #elif defined(OS_MACOSX) && !defined(OS_IOS)
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 ',', 322 ',',
326 &thresholds); 323 &thresholds);
327 324
328 int moderate_threshold_mb = 0; 325 int moderate_threshold_mb = 0;
329 int critical_threshold_mb = 0; 326 int critical_threshold_mb = 0;
330 if (thresholds.size() == 2 && 327 if (thresholds.size() == 2 &&
331 base::StringToInt(thresholds[0], &moderate_threshold_mb) && 328 base::StringToInt(thresholds[0], &moderate_threshold_mb) &&
332 base::StringToInt(thresholds[1], &critical_threshold_mb) && 329 base::StringToInt(thresholds[1], &critical_threshold_mb) &&
333 moderate_threshold_mb >= critical_threshold_mb && 330 moderate_threshold_mb >= critical_threshold_mb &&
334 critical_threshold_mb >= 0) { 331 critical_threshold_mb >= 0) {
335 return new base::win::MemoryPressureMonitor(moderate_threshold_mb, 332 return new base::MemoryPressureMonitor(moderate_threshold_mb,
336 critical_threshold_mb); 333 critical_threshold_mb);
337 } 334 }
338 335
339 // In absence of valid switches use the automatic defaults. 336 // In absence of valid switches use the automatic defaults.
340 return new base::win::MemoryPressureMonitor(); 337 return new base::MemoryPressureMonitor();
341 } 338 }
342 #endif // defined(OS_WIN) 339 #endif // defined(OS_WIN)
343 340
344 } // namespace 341 } // namespace
345 342
346 // The currently-running BrowserMainLoop. There can be one or zero. 343 // The currently-running BrowserMainLoop. There can be one or zero.
347 BrowserMainLoop* g_current_browser_main_loop = NULL; 344 BrowserMainLoop* g_current_browser_main_loop = NULL;
348 345
349 // For measuring memory usage after each task. Behind a command line flag. 346 // For measuring memory usage after each task. Behind a command line flag.
350 class BrowserMainLoop::MemoryObserver : public base::MessageLoop::TaskObserver { 347 class BrowserMainLoop::MemoryObserver : public base::MessageLoop::TaskObserver {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 "BrowserMainLoop::CreateThreads:PreCreateThreads"); 651 "BrowserMainLoop::CreateThreads:PreCreateThreads");
655 TRACK_SCOPED_REGION("Startup", "BrowserMainLoop::PreCreateThreads"); 652 TRACK_SCOPED_REGION("Startup", "BrowserMainLoop::PreCreateThreads");
656 653
657 result_code_ = parts_->PreCreateThreads(); 654 result_code_ = parts_->PreCreateThreads();
658 } 655 }
659 656
660 // TODO(chrisha): Abstract away this construction mess to a helper function, 657 // TODO(chrisha): Abstract away this construction mess to a helper function,
661 // once MemoryPressureMonitor is made a concrete class. 658 // once MemoryPressureMonitor is made a concrete class.
662 #if defined(OS_CHROMEOS) 659 #if defined(OS_CHROMEOS)
663 if (chromeos::switches::MemoryPressureHandlingEnabled()) { 660 if (chromeos::switches::MemoryPressureHandlingEnabled()) {
664 memory_pressure_monitor_.reset(new base::chromeos::MemoryPressureMonitor( 661 memory_pressure_monitor_.reset(new base::MemoryPressureMonitor(
665 chromeos::switches::GetMemoryPressureThresholds())); 662 chromeos::switches::GetMemoryPressureThresholds()));
666 } 663 }
667 #elif defined(OS_MACOSX) && !defined(OS_IOS) 664 #elif defined(OS_LINUX) || (defined(OS_MACOSX) && !defined(OS_IOS))
668 memory_pressure_monitor_.reset(new base::mac::MemoryPressureMonitor()); 665 memory_pressure_monitor_.reset(new base::MemoryPressureMonitor());
669 #elif defined(OS_WIN) 666 #elif defined(OS_WIN)
670 memory_pressure_monitor_.reset(CreateWinMemoryPressureMonitor( 667 memory_pressure_monitor_.reset(CreateWinMemoryPressureMonitor(
671 parsed_command_line_)); 668 parsed_command_line_));
672 #endif 669 #endif
673 670
674 #if defined(ENABLE_PLUGINS) 671 #if defined(ENABLE_PLUGINS)
675 // Prior to any processing happening on the io thread, we create the 672 // Prior to any processing happening on the io thread, we create the
676 // plugin service as it is predominantly used from the io thread, 673 // plugin service as it is predominantly used from the io thread,
677 // but must be created on the main thread. The service ctor is 674 // but must be created on the main thread. The service ctor is
678 // inexpensive and does not invoke the io_thread() accessor. 675 // inexpensive and does not invoke the io_thread() accessor.
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 DCHECK(is_tracing_startup_); 1342 DCHECK(is_tracing_startup_);
1346 1343
1347 is_tracing_startup_ = false; 1344 is_tracing_startup_ = false;
1348 TracingController::GetInstance()->DisableRecording( 1345 TracingController::GetInstance()->DisableRecording(
1349 TracingController::CreateFileSink( 1346 TracingController::CreateFileSink(
1350 startup_trace_file_, 1347 startup_trace_file_,
1351 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); 1348 base::Bind(OnStoppedStartupTracing, startup_trace_file_)));
1352 } 1349 }
1353 1350
1354 } // namespace content 1351 } // namespace content
OLDNEW
« no previous file with comments | « base/memory/memory_pressure_monitor_win_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698