OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/app_paths.h" | 5 #include "app/app_paths.h" |
6 #include "app/app_switches.h" | 6 #include "app/app_switches.h" |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include <atlbase.h> | 41 #include <atlbase.h> |
42 #include <atlapp.h> | 42 #include <atlapp.h> |
43 #include <malloc.h> | 43 #include <malloc.h> |
44 #include <new.h> | 44 #include <new.h> |
45 #include "sandbox/src/sandbox.h" | 45 #include "sandbox/src/sandbox.h" |
46 #include "tools/memory_watcher/memory_watcher.h" | 46 #include "tools/memory_watcher/memory_watcher.h" |
47 #endif | 47 #endif |
48 | 48 |
49 #if defined(OS_MACOSX) | 49 #if defined(OS_MACOSX) |
50 #include "app/l10n_util_mac.h" | 50 #include "app/l10n_util_mac.h" |
| 51 #include "base/mac/mac_util.h" |
51 #include "base/mac/os_crash_dumps.h" | 52 #include "base/mac/os_crash_dumps.h" |
52 #include "base/mac_util.h" | |
53 #include "base/mach_ipc_mac.h" | 53 #include "base/mach_ipc_mac.h" |
54 #include "chrome/app/breakpad_mac.h" | 54 #include "chrome/app/breakpad_mac.h" |
55 #include "chrome/browser/mach_broker_mac.h" | 55 #include "chrome/browser/mach_broker_mac.h" |
56 #include "chrome/common/chrome_paths_internal.h" | 56 #include "chrome/common/chrome_paths_internal.h" |
57 #include "grit/chromium_strings.h" | 57 #include "grit/chromium_strings.h" |
58 #include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h" | 58 #include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h" |
59 #endif | 59 #endif |
60 | 60 |
61 #if defined(OS_POSIX) | 61 #if defined(OS_POSIX) |
62 #include <locale.h> | 62 #include <locale.h> |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 name_id = IDS_RENDERER_APP_NAME; | 404 name_id = IDS_RENDERER_APP_NAME; |
405 } else if (process_type == switches::kPluginProcess) { | 405 } else if (process_type == switches::kPluginProcess) { |
406 name_id = IDS_PLUGIN_APP_NAME; | 406 name_id = IDS_PLUGIN_APP_NAME; |
407 } else if (process_type == switches::kExtensionProcess) { | 407 } else if (process_type == switches::kExtensionProcess) { |
408 name_id = IDS_WORKER_APP_NAME; | 408 name_id = IDS_WORKER_APP_NAME; |
409 } else if (process_type == switches::kUtilityProcess) { | 409 } else if (process_type == switches::kUtilityProcess) { |
410 name_id = IDS_UTILITY_APP_NAME; | 410 name_id = IDS_UTILITY_APP_NAME; |
411 } | 411 } |
412 if (name_id) { | 412 if (name_id) { |
413 NSString* app_name = l10n_util::GetNSString(name_id); | 413 NSString* app_name = l10n_util::GetNSString(name_id); |
414 mac_util::SetProcessName(reinterpret_cast<CFStringRef>(app_name)); | 414 base::mac::SetProcessName(reinterpret_cast<CFStringRef>(app_name)); |
415 } | 415 } |
416 } | 416 } |
417 | 417 |
418 // Completes the Mach IPC handshake by sending this process' task port to the | 418 // Completes the Mach IPC handshake by sending this process' task port to the |
419 // parent process. The parent is listening on the Mach port given by | 419 // parent process. The parent is listening on the Mach port given by |
420 // |GetMachPortName()|. The task port is used by the parent to get CPU/memory | 420 // |GetMachPortName()|. The task port is used by the parent to get CPU/memory |
421 // stats to display in the task manager. | 421 // stats to display in the task manager. |
422 void SendTaskPortToParentProcess() { | 422 void SendTaskPortToParentProcess() { |
423 const mach_msg_timeout_t kTimeoutMs = 100; | 423 const mach_msg_timeout_t kTimeoutMs = 100; |
424 const int32_t kMessageId = 0; | 424 const int32_t kMessageId = 0; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | 634 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
635 // This will directly exit if the user asked for help. | 635 // This will directly exit if the user asked for help. |
636 HandleHelpSwitches(command_line); | 636 HandleHelpSwitches(command_line); |
637 #endif | 637 #endif |
638 #endif // OS_POSIX | 638 #endif // OS_POSIX |
639 | 639 |
640 std::string process_type = | 640 std::string process_type = |
641 command_line.GetSwitchValueASCII(switches::kProcessType); | 641 command_line.GetSwitchValueASCII(switches::kProcessType); |
642 | 642 |
643 #if defined(OS_MACOSX) | 643 #if defined(OS_MACOSX) |
644 mac_util::SetOverrideAppBundlePath(chrome::GetFrameworkBundlePath()); | 644 base::mac::SetOverrideAppBundlePath(chrome::GetFrameworkBundlePath()); |
645 #endif // OS_MACOSX | 645 #endif // OS_MACOSX |
646 | 646 |
647 // If we are in diagnostics mode this is the end of the line. After the | 647 // If we are in diagnostics mode this is the end of the line. After the |
648 // diagnostics are run the process will invariably exit. | 648 // diagnostics are run the process will invariably exit. |
649 if (command_line.HasSwitch(switches::kDiagnostics)) { | 649 if (command_line.HasSwitch(switches::kDiagnostics)) { |
650 return DiagnosticsMain(command_line); | 650 return DiagnosticsMain(command_line); |
651 } | 651 } |
652 | 652 |
653 #if defined(OS_WIN) | 653 #if defined(OS_WIN) |
654 // Must do this before any other usage of command line! | 654 // Must do this before any other usage of command line! |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 // | 740 // |
741 // What we do: | 741 // What we do: |
742 // * We only pass crashes for foreground processes to Apple's Crash reporter. | 742 // * We only pass crashes for foreground processes to Apple's Crash reporter. |
743 // At the time of this writing, that means just the Browser process. | 743 // At the time of this writing, that means just the Browser process. |
744 // * If Breakpad is enabled, it will pass browser crashes to Crash Reporter | 744 // * If Breakpad is enabled, it will pass browser crashes to Crash Reporter |
745 // itself. | 745 // itself. |
746 // * If Breakpad is disabled, we only turn on Crash Reporter for the | 746 // * If Breakpad is disabled, we only turn on Crash Reporter for the |
747 // Browser process in release mode. | 747 // Browser process in release mode. |
748 if (!command_line.HasSwitch(switches::kDisableBreakpad)) { | 748 if (!command_line.HasSwitch(switches::kDisableBreakpad)) { |
749 bool disable_apple_crash_reporter = is_debug_build | 749 bool disable_apple_crash_reporter = is_debug_build |
750 || mac_util::IsBackgroundOnlyProcess(); | 750 || base::mac::IsBackgroundOnlyProcess(); |
751 if (!IsCrashReporterEnabled() && disable_apple_crash_reporter) { | 751 if (!IsCrashReporterEnabled() && disable_apple_crash_reporter) { |
752 base::mac::DisableOSCrashDumps(); | 752 base::mac::DisableOSCrashDumps(); |
753 } | 753 } |
754 } | 754 } |
755 | 755 |
756 #if defined(OS_MACOSX) | 756 #if defined(OS_MACOSX) |
757 // Mac Chrome is packaged with a main app bundle and a helper app bundle. | 757 // Mac Chrome is packaged with a main app bundle and a helper app bundle. |
758 // The main app bundle should only be used for the browser process, so it | 758 // The main app bundle should only be used for the browser process, so it |
759 // should never see a --type switch (switches::kProcessType). Likewise, | 759 // should never see a --type switch (switches::kProcessType). Likewise, |
760 // the helper should always have a --type switch. | 760 // the helper should always have a --type switch. |
761 // | 761 // |
762 // This check is done this late so there is already a call to | 762 // This check is done this late so there is already a call to |
763 // mac_util::IsBackgroundOnlyProcess(), so there is no change in | 763 // base::mac::IsBackgroundOnlyProcess(), so there is no change in |
764 // startup/initialization order. | 764 // startup/initialization order. |
765 | 765 |
766 // The helper's Info.plist marks it as a background only app. | 766 // The helper's Info.plist marks it as a background only app. |
767 if (mac_util::IsBackgroundOnlyProcess()) { | 767 if (base::mac::IsBackgroundOnlyProcess()) { |
768 CHECK(command_line.HasSwitch(switches::kProcessType)) | 768 CHECK(command_line.HasSwitch(switches::kProcessType)) |
769 << "Helper application requires --type."; | 769 << "Helper application requires --type."; |
770 } else { | 770 } else { |
771 CHECK(!command_line.HasSwitch(switches::kProcessType)) | 771 CHECK(!command_line.HasSwitch(switches::kProcessType)) |
772 << "Main application forbids --type, saw \"" << process_type << "\"."; | 772 << "Main application forbids --type, saw \"" << process_type << "\"."; |
773 } | 773 } |
774 #endif // defined(OS_MACOSX) | 774 #endif // defined(OS_MACOSX) |
775 | 775 |
776 if (IsCrashReporterEnabled()) | 776 if (IsCrashReporterEnabled()) |
777 InitCrashProcessInfo(); | 777 InitCrashProcessInfo(); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 | 912 |
913 int exit_code = RunNamedProcessTypeMain(process_type, main_params); | 913 int exit_code = RunNamedProcessTypeMain(process_type, main_params); |
914 | 914 |
915 if (SubprocessNeedsResourceBundle(process_type)) | 915 if (SubprocessNeedsResourceBundle(process_type)) |
916 ResourceBundle::CleanupSharedInstance(); | 916 ResourceBundle::CleanupSharedInstance(); |
917 | 917 |
918 LowLevelShutdown(); | 918 LowLevelShutdown(); |
919 | 919 |
920 return exit_code; | 920 return exit_code; |
921 } | 921 } |
OLD | NEW |