| 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 "app/app_paths.h" | 7 #include "app/app_paths.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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #include "base/win/registry.h" | 56 #include "base/win/registry.h" |
| 57 #include "sandbox/src/sandbox.h" | 57 #include "sandbox/src/sandbox.h" |
| 58 #include "tools/memory_watcher/memory_watcher.h" | 58 #include "tools/memory_watcher/memory_watcher.h" |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 #if defined(OS_MACOSX) | 61 #if defined(OS_MACOSX) |
| 62 #include "base/mac/mac_util.h" | 62 #include "base/mac/mac_util.h" |
| 63 #include "base/mac/os_crash_dumps.h" | 63 #include "base/mac/os_crash_dumps.h" |
| 64 #include "base/mach_ipc_mac.h" | 64 #include "base/mach_ipc_mac.h" |
| 65 #include "chrome/app/breakpad_mac.h" | 65 #include "chrome/app/breakpad_mac.h" |
| 66 #include "chrome/browser/mac/relauncher.h" |
| 66 #include "chrome/browser/mach_broker_mac.h" | 67 #include "chrome/browser/mach_broker_mac.h" |
| 67 #include "chrome/common/chrome_paths_internal.h" | 68 #include "chrome/common/chrome_paths_internal.h" |
| 68 #include "grit/chromium_strings.h" | 69 #include "grit/chromium_strings.h" |
| 69 #include "third_party/WebKit/Source/WebKit/mac/WebCoreSupport/WebSystemInterface
.h" | 70 #include "third_party/WebKit/Source/WebKit/mac/WebCoreSupport/WebSystemInterface
.h" |
| 70 #include "ui/base/l10n/l10n_util_mac.h" | 71 #include "ui/base/l10n/l10n_util_mac.h" |
| 71 #endif | 72 #endif |
| 72 | 73 |
| 73 #if defined(OS_POSIX) | 74 #if defined(OS_POSIX) |
| 74 #include <locale.h> | 75 #include <locale.h> |
| 75 #include <signal.h> | 76 #include <signal.h> |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // The zygote process opens the resources for the renderers. | 291 // The zygote process opens the resources for the renderers. |
| 291 process_type == switches::kZygoteProcess || | 292 process_type == switches::kZygoteProcess || |
| 292 #endif | 293 #endif |
| 293 process_type == switches::kRendererProcess || | 294 process_type == switches::kRendererProcess || |
| 294 process_type == switches::kExtensionProcess || | 295 process_type == switches::kExtensionProcess || |
| 295 process_type == switches::kUtilityProcess; | 296 process_type == switches::kUtilityProcess; |
| 296 } | 297 } |
| 297 | 298 |
| 298 // Returns true if this process is a child of the browser process. | 299 // Returns true if this process is a child of the browser process. |
| 299 bool SubprocessIsBrowserChild(const std::string& process_type) { | 300 bool SubprocessIsBrowserChild(const std::string& process_type) { |
| 300 if (process_type.empty() || process_type == switches::kServiceProcess) { | 301 if (process_type.empty() || |
| 302 #if defined(OS_MACOSX) |
| 303 process_type == switches::kRelauncherProcess || |
| 304 #endif |
| 305 process_type == switches::kServiceProcess) { |
| 301 return false; | 306 return false; |
| 302 } | 307 } |
| 303 return true; | 308 return true; |
| 304 } | 309 } |
| 305 | 310 |
| 306 #if defined(OS_MACOSX) | 311 #if defined(OS_MACOSX) |
| 307 // Update the name shown in Activity Monitor so users are less likely to ask | 312 // Update the name shown in Activity Monitor so users are less likely to ask |
| 308 // why Chrome has so many processes. | 313 // why Chrome has so many processes. |
| 309 void SetMacProcessName(const std::string& process_type) { | 314 void SetMacProcessName(const std::string& process_type) { |
| 310 // Don't worry about the browser process, its gets the stock name. | 315 // Don't worry about the browser process, its gets the stock name. |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 { switches::kWorkerProcess, WorkerMain }, | 498 { switches::kWorkerProcess, WorkerMain }, |
| 494 { switches::kPpapiPluginProcess, PpapiPluginMain }, | 499 { switches::kPpapiPluginProcess, PpapiPluginMain }, |
| 495 { switches::kPpapiBrokerProcess, PpapiBrokerMain }, | 500 { switches::kPpapiBrokerProcess, PpapiBrokerMain }, |
| 496 { switches::kUtilityProcess, UtilityMain }, | 501 { switches::kUtilityProcess, UtilityMain }, |
| 497 { switches::kGpuProcess, GpuMain }, | 502 { switches::kGpuProcess, GpuMain }, |
| 498 { switches::kServiceProcess, ServiceProcessMain }, | 503 { switches::kServiceProcess, ServiceProcessMain }, |
| 499 | 504 |
| 500 #if defined(OS_MACOSX) | 505 #if defined(OS_MACOSX) |
| 501 // TODO(port): Use OOP profile import - http://crbug.com/22142 . | 506 // TODO(port): Use OOP profile import - http://crbug.com/22142 . |
| 502 { switches::kProfileImportProcess, ProfileImportMain }, | 507 { switches::kProfileImportProcess, ProfileImportMain }, |
| 508 { switches::kRelauncherProcess, mac_relauncher::RelauncherMain }, |
| 503 #endif | 509 #endif |
| 504 #if !defined(DISABLE_NACL) | 510 #if !defined(DISABLE_NACL) |
| 505 { switches::kNaClLoaderProcess, NaClMain }, | 511 { switches::kNaClLoaderProcess, NaClMain }, |
| 506 #ifdef _WIN64 // The broker process is used only on Win64. | 512 #ifdef _WIN64 // The broker process is used only on Win64. |
| 507 { switches::kNaClBrokerProcess, NaClBrokerMain }, | 513 { switches::kNaClBrokerProcess, NaClBrokerMain }, |
| 508 #endif | 514 #endif |
| 509 #endif // DISABLE_NACL | 515 #endif // DISABLE_NACL |
| 510 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 516 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 511 // Zygote startup is special -- see RunZygote comments above | 517 // Zygote startup is special -- see RunZygote comments above |
| 512 // for why we don't use ZygoteMain directly. | 518 // for why we don't use ZygoteMain directly. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 browser_pid = static_cast<base::ProcessId>(browser_pid_int); | 604 browser_pid = static_cast<base::ProcessId>(browser_pid_int); |
| 599 DCHECK_NE(browser_pid_int, 0); | 605 DCHECK_NE(browser_pid_int, 0); |
| 600 #elif defined(OS_POSIX) | 606 #elif defined(OS_POSIX) |
| 601 // On linux, we're in the zygote here; so we need the parent process' id. | 607 // On linux, we're in the zygote here; so we need the parent process' id. |
| 602 browser_pid = base::GetParentProcessId(base::GetCurrentProcId()); | 608 browser_pid = base::GetParentProcessId(base::GetCurrentProcId()); |
| 603 #endif | 609 #endif |
| 604 | 610 |
| 605 #if defined(OS_MACOSX) | 611 #if defined(OS_MACOSX) |
| 606 SendTaskPortToParentProcess(); | 612 SendTaskPortToParentProcess(); |
| 607 #endif | 613 #endif |
| 614 } |
| 608 | 615 |
| 609 #if defined(OS_POSIX) | 616 #if defined(OS_POSIX) |
| 617 if (!process_type.empty()) { |
| 610 // When you hit Ctrl-C in a terminal running the browser | 618 // When you hit Ctrl-C in a terminal running the browser |
| 611 // process, a SIGINT is delivered to the entire process group. | 619 // process, a SIGINT is delivered to the entire process group. |
| 612 // When debugging the browser process via gdb, gdb catches the | 620 // When debugging the browser process via gdb, gdb catches the |
| 613 // SIGINT for the browser process (and dumps you back to the gdb | 621 // SIGINT for the browser process (and dumps you back to the gdb |
| 614 // console) but doesn't for the child processes, killing them. | 622 // console) but doesn't for the child processes, killing them. |
| 615 // The fix is to have child processes ignore SIGINT; they'll die | 623 // The fix is to have child processes ignore SIGINT; they'll die |
| 616 // on their own when the browser process goes away. | 624 // on their own when the browser process goes away. |
| 617 // | 625 // |
| 618 // Note that we *can't* rely on BeingDebugged to catch this case because we | 626 // Note that we *can't* rely on BeingDebugged to catch this case because we |
| 619 // are the child process, which is not being debugged. | 627 // are the child process, which is not being debugged. |
| 620 // TODO(evanm): move this to some shared subprocess-init function. | 628 // TODO(evanm): move this to some shared subprocess-init function. |
| 621 if (!base::debug::BeingDebugged()) | 629 if (!base::debug::BeingDebugged()) |
| 622 signal(SIGINT, SIG_IGN); | 630 signal(SIGINT, SIG_IGN); |
| 631 } |
| 623 #endif | 632 #endif |
| 624 } | 633 |
| 625 SetupCRT(command_line); | 634 SetupCRT(command_line); |
| 626 | 635 |
| 627 #if defined(USE_NSS) | 636 #if defined(USE_NSS) |
| 628 crypto::EarlySetupForNSSInit(); | 637 crypto::EarlySetupForNSSInit(); |
| 629 #endif | 638 #endif |
| 630 | 639 |
| 631 // Initialize the Chrome path provider. | 640 // Initialize the Chrome path provider. |
| 632 app::RegisterPathProvider(); | 641 app::RegisterPathProvider(); |
| 633 ui::RegisterPathProvider(); | 642 ui::RegisterPathProvider(); |
| 634 chrome::RegisterPathProvider(); | 643 chrome::RegisterPathProvider(); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 | 848 |
| 840 if (SubprocessNeedsResourceBundle(process_type)) | 849 if (SubprocessNeedsResourceBundle(process_type)) |
| 841 ResourceBundle::CleanupSharedInstance(); | 850 ResourceBundle::CleanupSharedInstance(); |
| 842 | 851 |
| 843 logging::CleanupChromeLogging(); | 852 logging::CleanupChromeLogging(); |
| 844 | 853 |
| 845 chrome_main::LowLevelShutdown(); | 854 chrome_main::LowLevelShutdown(); |
| 846 | 855 |
| 847 return exit_code; | 856 return exit_code; |
| 848 } | 857 } |
| OLD | NEW |