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

Side by Side Diff: chrome/app/chrome_dll_main.cc

Issue 467058: Linux: Adjust /proc/pid/oom_adj to sacrifice plugin and renderer processes to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 // TODO(port): the ifdefs in here are a first step towards trying to determine 5 // TODO(port): the ifdefs in here are a first step towards trying to determine
6 // the correct abstraction for all the OS functionality required at this 6 // the correct abstraction for all the OS functionality required at this
7 // stage of process initialization. It should not be taken as a final 7 // stage of process initialization. It should not be taken as a final
8 // abstraction. 8 // abstraction.
9 9
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 g_log_set_handler(kLogDomains[i], 238 g_log_set_handler(kLogDomains[i],
239 static_cast<GLogLevelFlags>(G_LOG_FLAG_RECURSION | 239 static_cast<GLogLevelFlags>(G_LOG_FLAG_RECURSION |
240 G_LOG_FLAG_FATAL | 240 G_LOG_FLAG_FATAL |
241 G_LOG_LEVEL_ERROR | 241 G_LOG_LEVEL_ERROR |
242 G_LOG_LEVEL_CRITICAL | 242 G_LOG_LEVEL_CRITICAL |
243 G_LOG_LEVEL_WARNING), 243 G_LOG_LEVEL_WARNING),
244 GLibLogHandler, 244 GLibLogHandler,
245 NULL); 245 NULL);
246 } 246 }
247 } 247 }
248
249 static void AdjustLinuxOOMScore(const std::string& process_type) {
250 const int kMiscScore = 7;
251 const int kPluginScore = 10;
252 int score = -1;
253
254 if (process_type == switches::kPluginProcess) {
255 score = kPluginScore;
256 } else if (process_type == switches::kUtilityProcess ||
257 process_type == switches::kWorkerProcess) {
258 score = kMiscScore;
259 } else if (process_type == switches::kProfileImportProcess) {
260 NOTIMPLEMENTED();
261 #ifndef DISABLE_NACL
262 } else if (process_type == switches::kNaClProcess) {
263 score = kPluginScore;
264 #endif
265 } else if (process_type == switches::kZygoteProcess ||
266 process_type.empty()) {
267 // Pass - browser / zygote process stays at 0.
268 } else if (process_type == switches::kExtensionProcess ||
269 process_type == switches::kRendererProcess) {
270 // Set in chrome/browser/zygote_host_linux.cc.
271 NOTREACHED() << "process type " << process_type
272 << "should go through the zygote.";
273 } else {
274 NOTREACHED() << "Unknown process type";
275 }
276 if (score > -1)
277 base::AdjustOOMScore(base::GetCurrentProcId(), score);
278 }
248 #endif // defined(OS_LINUX) 279 #endif // defined(OS_LINUX)
249 280
250 // Register the invalid param handler and pure call handler to be able to 281 // Register the invalid param handler and pure call handler to be able to
251 // notify breakpad when it happens. 282 // notify breakpad when it happens.
252 void RegisterInvalidParamHandler() { 283 void RegisterInvalidParamHandler() {
253 #if defined(OS_WIN) 284 #if defined(OS_WIN)
254 _set_invalid_parameter_handler(InvalidParameter); 285 _set_invalid_parameter_handler(InvalidParameter);
255 _set_purecall_handler(PureCall); 286 _set_purecall_handler(PureCall);
256 // Gather allocation failure. 287 // Gather allocation failure.
257 std::set_new_handler(&OnNoMemory); 288 std::set_new_handler(&OnNoMemory);
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 CHECK(sandbox_initialized_ok) << "Error initializing sandbox for " 625 CHECK(sandbox_initialized_ok) << "Error initializing sandbox for "
595 << process_type; 626 << process_type;
596 } 627 }
597 #endif // OS_MACOSX 628 #endif // OS_MACOSX
598 629
599 startup_timer.Stop(); // End of Startup Time Measurement. 630 startup_timer.Stop(); // End of Startup Time Measurement.
600 631
601 MainFunctionParams main_params(parsed_command_line, sandbox_wrapper, 632 MainFunctionParams main_params(parsed_command_line, sandbox_wrapper,
602 &autorelease_pool); 633 &autorelease_pool);
603 634
635 // Note: If you are adding a new process type below, be sure to adjust the
636 // AdjustLinuxOOMScore function too.
637 #if defined(OS_LINUX)
638 AdjustLinuxOOMScore(process_type);
639 #endif
640
604 // TODO(port): turn on these main() functions as they've been de-winified. 641 // TODO(port): turn on these main() functions as they've been de-winified.
605 int rv = -1; 642 int rv = -1;
606 if (process_type == switches::kRendererProcess) { 643 if (process_type == switches::kRendererProcess) {
607 rv = RendererMain(main_params); 644 rv = RendererMain(main_params);
608 } else if (process_type == switches::kExtensionProcess) { 645 } else if (process_type == switches::kExtensionProcess) {
609 // An extension process is just a renderer process. We use a different 646 // An extension process is just a renderer process. We use a different
610 // command line argument to differentiate crash reports. 647 // command line argument to differentiate crash reports.
611 rv = RendererMain(main_params); 648 rv = RendererMain(main_params);
612 } else if (process_type == switches::kPluginProcess) { 649 } else if (process_type == switches::kPluginProcess) {
613 rv = PluginMain(main_params); 650 rv = PluginMain(main_params);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 741
705 logging::CleanupChromeLogging(); 742 logging::CleanupChromeLogging();
706 743
707 #if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD) 744 #if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD)
708 // TODO(mark): See the TODO(mark) above at InitCrashReporter. 745 // TODO(mark): See the TODO(mark) above at InitCrashReporter.
709 DestructCrashReporter(); 746 DestructCrashReporter();
710 #endif // OS_MACOSX && GOOGLE_CHROME_BUILD 747 #endif // OS_MACOSX && GOOGLE_CHROME_BUILD
711 748
712 return rv; 749 return rv;
713 } 750 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698