OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/app/chrome_main.h" | 5 #include "chrome/app/chrome_main.h" |
6 | 6 |
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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 // The main app bundle should only be used for the browser process, so it | 757 // The main app bundle should only be used for the browser process, so it |
758 // should never see a --type switch (switches::kProcessType). Likewise, | 758 // should never see a --type switch (switches::kProcessType). Likewise, |
759 // the helper should always have a --type switch. | 759 // the helper should always have a --type switch. |
760 // | 760 // |
761 // This check is done this late so there is already a call to | 761 // This check is done this late so there is already a call to |
762 // base::mac::IsBackgroundOnlyProcess(), so there is no change in | 762 // base::mac::IsBackgroundOnlyProcess(), so there is no change in |
763 // startup/initialization order. | 763 // startup/initialization order. |
764 | 764 |
765 // The helper's Info.plist marks it as a background only app. | 765 // The helper's Info.plist marks it as a background only app. |
766 if (base::mac::IsBackgroundOnlyProcess()) { | 766 if (base::mac::IsBackgroundOnlyProcess()) { |
767 CHECK(command_line.HasSwitch(switches::kProcessType)) | 767 CHECK(command_line.HasSwitch(switches::kProcessType) && |
| 768 !process_type.empty()) |
768 << "Helper application requires --type."; | 769 << "Helper application requires --type."; |
| 770 |
| 771 // In addition, some helper flavors only work with certain process types. |
| 772 FilePath executable; |
| 773 if (PathService::Get(base::FILE_EXE, &executable) && |
| 774 executable.value().size() >= 3) { |
| 775 std::string last_three = |
| 776 executable.value().substr(executable.value().size() - 3); |
| 777 |
| 778 if (last_three == " EH") { |
| 779 CHECK_EQ(switches::kPluginProcess, process_type) |
| 780 << "Executable-heap process requires --type=" |
| 781 << switches::kPluginProcess << ", saw " << process_type; |
| 782 } else if (last_three == " NP") { |
| 783 CHECK_EQ(switches::kNaClLoaderProcess, process_type) |
| 784 << "Non-PIE process requires --type=" |
| 785 << switches::kNaClLoaderProcess << ", saw " << process_type; |
| 786 } else { |
| 787 CHECK(process_type != switches::kPluginProcess && |
| 788 process_type != switches::kNaClLoaderProcess) |
| 789 << "Non-executable-heap PIE process is intolerant of --type=" |
| 790 << switches::kPluginProcess << " and " |
| 791 << switches::kNaClLoaderProcess << ", saw " << process_type; |
| 792 } |
| 793 } |
769 } else { | 794 } else { |
770 CHECK(!command_line.HasSwitch(switches::kProcessType)) | 795 CHECK(!command_line.HasSwitch(switches::kProcessType) && |
771 << "Main application forbids --type, saw \"" << process_type << "\"."; | 796 process_type.empty()) |
| 797 << "Main application forbids --type, saw " << process_type; |
772 } | 798 } |
773 | 799 |
774 if (IsCrashReporterEnabled()) | 800 if (IsCrashReporterEnabled()) |
775 InitCrashProcessInfo(); | 801 InitCrashProcessInfo(); |
776 #endif // defined(OS_MACOSX) | 802 #endif // defined(OS_MACOSX) |
777 | 803 |
778 InitializeStatsTable(browser_pid, command_line); | 804 InitializeStatsTable(browser_pid, command_line); |
779 | 805 |
780 base::StatsScope<base::StatsCounterTimer> | 806 base::StatsScope<base::StatsCounterTimer> |
781 startup_timer(content::Counters::chrome_main()); | 807 startup_timer(content::Counters::chrome_main()); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 | 935 |
910 if (SubprocessNeedsResourceBundle(process_type)) | 936 if (SubprocessNeedsResourceBundle(process_type)) |
911 ResourceBundle::CleanupSharedInstance(); | 937 ResourceBundle::CleanupSharedInstance(); |
912 | 938 |
913 logging::CleanupChromeLogging(); | 939 logging::CleanupChromeLogging(); |
914 | 940 |
915 chrome_main::LowLevelShutdown(); | 941 chrome_main::LowLevelShutdown(); |
916 | 942 |
917 return exit_code; | 943 return exit_code; |
918 } | 944 } |
OLD | NEW |