Chromium Code Reviews| 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 "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/debugger.h" | 9 #include "base/debug/debugger.h" |
| 10 #include "base/i18n/icu_util.h" | 10 #include "base/i18n/icu_util.h" |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 675 // Disable sync and extensions if we're in "browse without sign-in" mode. | 675 // Disable sync and extensions if we're in "browse without sign-in" mode. |
| 676 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); | 676 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); |
| 677 singleton_command_line->AppendSwitch(switches::kDisableSync); | 677 singleton_command_line->AppendSwitch(switches::kDisableSync); |
| 678 singleton_command_line->AppendSwitch(switches::kDisableExtensions); | 678 singleton_command_line->AppendSwitch(switches::kDisableExtensions); |
| 679 browser_defaults::bookmarks_enabled = false; | 679 browser_defaults::bookmarks_enabled = false; |
| 680 } | 680 } |
| 681 #endif | 681 #endif |
| 682 | 682 |
| 683 base::ProcessId browser_pid = base::GetCurrentProcId(); | 683 base::ProcessId browser_pid = base::GetCurrentProcId(); |
| 684 if (SubprocessIsBrowserChild(process_type)) { | 684 if (SubprocessIsBrowserChild(process_type)) { |
| 685 #if defined(OS_WIN) | 685 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 686 std::string channel_name = | 686 std::string channel_name = |
| 687 command_line.GetSwitchValueASCII(switches::kProcessChannelID); | 687 command_line.GetSwitchValueASCII(switches::kProcessChannelID); |
| 688 | 688 |
| 689 int browser_pid_int; | 689 int browser_pid_int; |
| 690 base::StringToInt(channel_name, &browser_pid_int); | 690 base::StringToInt(channel_name, &browser_pid_int); |
| 691 browser_pid = static_cast<base::ProcessId>(browser_pid_int); | 691 browser_pid = static_cast<base::ProcessId>(browser_pid_int); |
| 692 DCHECK_NE(browser_pid, 0u); | 692 DCHECK_NE(browser_pid, 0); |
| 693 #elif defined(OS_MACOSX) | |
| 694 browser_pid = base::GetCurrentProcId(); | |
| 695 SendTaskPortToParentProcess(); | |
| 696 #elif defined(OS_POSIX) | 693 #elif defined(OS_POSIX) |
| 697 // On linux, we're in the zygote here; so we need the parent process' id. | 694 // On linux, we're in the zygote here; so we need the parent process' id. |
| 698 browser_pid = base::GetParentProcessId(base::GetCurrentProcId()); | 695 browser_pid = base::GetParentProcessId(base::GetCurrentProcId()); |
| 699 #endif | 696 #endif |
| 700 | 697 |
| 698 #if defined(OS_MACOSX) | |
| 699 SendTaskPortToParentProcess(); | |
| 700 #endif | |
| 701 | |
| 701 #if defined(OS_POSIX) | 702 #if defined(OS_POSIX) |
| 702 // When you hit Ctrl-C in a terminal running the browser | 703 // When you hit Ctrl-C in a terminal running the browser |
| 703 // process, a SIGINT is delivered to the entire process group. | 704 // process, a SIGINT is delivered to the entire process group. |
| 704 // When debugging the browser process via gdb, gdb catches the | 705 // When debugging the browser process via gdb, gdb catches the |
| 705 // SIGINT for the browser process (and dumps you back to the gdb | 706 // SIGINT for the browser process (and dumps you back to the gdb |
| 706 // console) but doesn't for the child processes, killing them. | 707 // console) but doesn't for the child processes, killing them. |
| 707 // The fix is to have child processes ignore SIGINT; they'll die | 708 // The fix is to have child processes ignore SIGINT; they'll die |
| 708 // on their own when the browser process goes away. | 709 // on their own when the browser process goes away. |
| 709 // | 710 // |
| 710 // Note that we *can't* rely on BeingDebugged to catch this case because we | 711 // Note that we *can't* rely on BeingDebugged to catch this case because we |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 758 // * If Breakpad is disabled, we only turn on Crash Reporter for the | 759 // * If Breakpad is disabled, we only turn on Crash Reporter for the |
| 759 // Browser process in release mode. | 760 // Browser process in release mode. |
| 760 if (!command_line.HasSwitch(switches::kDisableBreakpad)) { | 761 if (!command_line.HasSwitch(switches::kDisableBreakpad)) { |
| 761 bool disable_apple_crash_reporter = is_debug_build | 762 bool disable_apple_crash_reporter = is_debug_build |
| 762 || base::mac::IsBackgroundOnlyProcess(); | 763 || base::mac::IsBackgroundOnlyProcess(); |
| 763 if (!IsCrashReporterEnabled() && disable_apple_crash_reporter) { | 764 if (!IsCrashReporterEnabled() && disable_apple_crash_reporter) { |
| 764 base::mac::DisableOSCrashDumps(); | 765 base::mac::DisableOSCrashDumps(); |
| 765 } | 766 } |
| 766 } | 767 } |
| 767 | 768 |
| 768 #if defined(OS_MACOSX) | |
|
tonyg
2011/01/24 23:56:55
FYI, this is no functional change. I just noticed
| |
| 769 // Mac Chrome is packaged with a main app bundle and a helper app bundle. | 769 // Mac Chrome is packaged with a main app bundle and a helper app bundle. |
| 770 // The main app bundle should only be used for the browser process, so it | 770 // The main app bundle should only be used for the browser process, so it |
| 771 // should never see a --type switch (switches::kProcessType). Likewise, | 771 // should never see a --type switch (switches::kProcessType). Likewise, |
| 772 // the helper should always have a --type switch. | 772 // the helper should always have a --type switch. |
| 773 // | 773 // |
| 774 // This check is done this late so there is already a call to | 774 // This check is done this late so there is already a call to |
| 775 // base::mac::IsBackgroundOnlyProcess(), so there is no change in | 775 // base::mac::IsBackgroundOnlyProcess(), so there is no change in |
| 776 // startup/initialization order. | 776 // startup/initialization order. |
| 777 | 777 |
| 778 // The helper's Info.plist marks it as a background only app. | 778 // The helper's Info.plist marks it as a background only app. |
| 779 if (base::mac::IsBackgroundOnlyProcess()) { | 779 if (base::mac::IsBackgroundOnlyProcess()) { |
| 780 CHECK(command_line.HasSwitch(switches::kProcessType)) | 780 CHECK(command_line.HasSwitch(switches::kProcessType)) |
| 781 << "Helper application requires --type."; | 781 << "Helper application requires --type."; |
| 782 } else { | 782 } else { |
| 783 CHECK(!command_line.HasSwitch(switches::kProcessType)) | 783 CHECK(!command_line.HasSwitch(switches::kProcessType)) |
| 784 << "Main application forbids --type, saw \"" << process_type << "\"."; | 784 << "Main application forbids --type, saw \"" << process_type << "\"."; |
| 785 } | 785 } |
| 786 #endif // defined(OS_MACOSX) | |
| 787 | 786 |
| 788 if (IsCrashReporterEnabled()) | 787 if (IsCrashReporterEnabled()) |
| 789 InitCrashProcessInfo(); | 788 InitCrashProcessInfo(); |
| 790 #endif // OS_MACOSX | 789 #endif // defined(OS_MACOSX) |
| 791 | 790 |
| 792 InitializeStatsTable(browser_pid, command_line); | 791 InitializeStatsTable(browser_pid, command_line); |
| 793 | 792 |
| 794 base::StatsScope<base::StatsCounterTimer> | 793 base::StatsScope<base::StatsCounterTimer> |
| 795 startup_timer(chrome::Counters::chrome_main()); | 794 startup_timer(chrome::Counters::chrome_main()); |
| 796 | 795 |
| 797 // Enable the heap profiler as early as possible! | 796 // Enable the heap profiler as early as possible! |
| 798 EnableHeapProfiler(command_line); | 797 EnableHeapProfiler(command_line); |
| 799 | 798 |
| 800 // Enable Message Loop related state asap. | 799 // Enable Message Loop related state asap. |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 924 | 923 |
| 925 int exit_code = RunNamedProcessTypeMain(process_type, main_params); | 924 int exit_code = RunNamedProcessTypeMain(process_type, main_params); |
| 926 | 925 |
| 927 if (SubprocessNeedsResourceBundle(process_type)) | 926 if (SubprocessNeedsResourceBundle(process_type)) |
| 928 ResourceBundle::CleanupSharedInstance(); | 927 ResourceBundle::CleanupSharedInstance(); |
| 929 | 928 |
| 930 LowLevelShutdown(); | 929 LowLevelShutdown(); |
| 931 | 930 |
| 932 return exit_code; | 931 return exit_code; |
| 933 } | 932 } |
| OLD | NEW |