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

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

Issue 7215040: Fix relaunches on the Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months 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) 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
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/common/chrome_paths_internal.h" 67 #include "chrome/common/chrome_paths_internal.h"
67 #include "content/browser/mach_broker_mac.h" 68 #include "content/browser/mach_broker_mac.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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // The zygote process opens the resources for the renderers. 299 // The zygote process opens the resources for the renderers.
299 process_type == switches::kZygoteProcess || 300 process_type == switches::kZygoteProcess ||
300 #endif 301 #endif
301 process_type == switches::kRendererProcess || 302 process_type == switches::kRendererProcess ||
302 process_type == switches::kExtensionProcess || 303 process_type == switches::kExtensionProcess ||
303 process_type == switches::kUtilityProcess; 304 process_type == switches::kUtilityProcess;
304 } 305 }
305 306
306 // Returns true if this process is a child of the browser process. 307 // Returns true if this process is a child of the browser process.
307 bool SubprocessIsBrowserChild(const std::string& process_type) { 308 bool SubprocessIsBrowserChild(const std::string& process_type) {
308 if (process_type.empty() || process_type == switches::kServiceProcess) { 309 if (process_type.empty() ||
310 #if defined(OS_MACOSX)
311 process_type == switches::kRelauncherProcess ||
312 #endif
313 process_type == switches::kServiceProcess) {
309 return false; 314 return false;
310 } 315 }
311 return true; 316 return true;
312 } 317 }
313 318
314 #if defined(OS_MACOSX) 319 #if defined(OS_MACOSX)
315 // Update the name shown in Activity Monitor so users are less likely to ask 320 // Update the name shown in Activity Monitor so users are less likely to ask
316 // why Chrome has so many processes. 321 // why Chrome has so many processes.
317 void SetMacProcessName(const std::string& process_type) { 322 void SetMacProcessName(const std::string& process_type) {
318 // Don't worry about the browser process, its gets the stock name. 323 // Don't worry about the browser process, its gets the stock name.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 { switches::kWorkerProcess, WorkerMain }, 506 { switches::kWorkerProcess, WorkerMain },
502 { switches::kPpapiPluginProcess, PpapiPluginMain }, 507 { switches::kPpapiPluginProcess, PpapiPluginMain },
503 { switches::kPpapiBrokerProcess, PpapiBrokerMain }, 508 { switches::kPpapiBrokerProcess, PpapiBrokerMain },
504 { switches::kUtilityProcess, UtilityMain }, 509 { switches::kUtilityProcess, UtilityMain },
505 { switches::kGpuProcess, GpuMain }, 510 { switches::kGpuProcess, GpuMain },
506 { switches::kServiceProcess, ServiceProcessMain }, 511 { switches::kServiceProcess, ServiceProcessMain },
507 512
508 #if defined(OS_MACOSX) 513 #if defined(OS_MACOSX)
509 // TODO(port): Use OOP profile import - http://crbug.com/22142 . 514 // TODO(port): Use OOP profile import - http://crbug.com/22142 .
510 { switches::kProfileImportProcess, ProfileImportMain }, 515 { switches::kProfileImportProcess, ProfileImportMain },
516 { switches::kRelauncherProcess, mac_relauncher::internal::RelauncherMain },
511 #endif 517 #endif
512 #if !defined(DISABLE_NACL) 518 #if !defined(DISABLE_NACL)
513 { switches::kNaClLoaderProcess, NaClMain }, 519 { switches::kNaClLoaderProcess, NaClMain },
514 #ifdef _WIN64 // The broker process is used only on Win64. 520 #ifdef _WIN64 // The broker process is used only on Win64.
515 { switches::kNaClBrokerProcess, NaClBrokerMain }, 521 { switches::kNaClBrokerProcess, NaClBrokerMain },
516 #endif 522 #endif
517 #endif // DISABLE_NACL 523 #endif // DISABLE_NACL
518 #if defined(OS_POSIX) && !defined(OS_MACOSX) 524 #if defined(OS_POSIX) && !defined(OS_MACOSX)
519 // Zygote startup is special -- see RunZygote comments above 525 // Zygote startup is special -- see RunZygote comments above
520 // for why we don't use ZygoteMain directly. 526 // for why we don't use ZygoteMain directly.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 browser_pid = static_cast<base::ProcessId>(browser_pid_int); 612 browser_pid = static_cast<base::ProcessId>(browser_pid_int);
607 DCHECK_NE(browser_pid_int, 0); 613 DCHECK_NE(browser_pid_int, 0);
608 #elif defined(OS_POSIX) 614 #elif defined(OS_POSIX)
609 // On linux, we're in the zygote here; so we need the parent process' id. 615 // On linux, we're in the zygote here; so we need the parent process' id.
610 browser_pid = base::GetParentProcessId(base::GetCurrentProcId()); 616 browser_pid = base::GetParentProcessId(base::GetCurrentProcId());
611 #endif 617 #endif
612 618
613 #if defined(OS_MACOSX) 619 #if defined(OS_MACOSX)
614 SendTaskPortToParentProcess(); 620 SendTaskPortToParentProcess();
615 #endif 621 #endif
622 }
616 623
617 #if defined(OS_POSIX) 624 #if defined(OS_POSIX)
625 if (!process_type.empty()) {
618 // When you hit Ctrl-C in a terminal running the browser 626 // When you hit Ctrl-C in a terminal running the browser
619 // process, a SIGINT is delivered to the entire process group. 627 // process, a SIGINT is delivered to the entire process group.
620 // When debugging the browser process via gdb, gdb catches the 628 // When debugging the browser process via gdb, gdb catches the
621 // SIGINT for the browser process (and dumps you back to the gdb 629 // SIGINT for the browser process (and dumps you back to the gdb
622 // console) but doesn't for the child processes, killing them. 630 // console) but doesn't for the child processes, killing them.
623 // The fix is to have child processes ignore SIGINT; they'll die 631 // The fix is to have child processes ignore SIGINT; they'll die
624 // on their own when the browser process goes away. 632 // on their own when the browser process goes away.
625 // 633 //
626 // Note that we *can't* rely on BeingDebugged to catch this case because we 634 // Note that we *can't* rely on BeingDebugged to catch this case because we
627 // are the child process, which is not being debugged. 635 // are the child process, which is not being debugged.
628 // TODO(evanm): move this to some shared subprocess-init function. 636 // TODO(evanm): move this to some shared subprocess-init function.
629 if (!base::debug::BeingDebugged()) 637 if (!base::debug::BeingDebugged())
630 signal(SIGINT, SIG_IGN); 638 signal(SIGINT, SIG_IGN);
639 }
631 #endif 640 #endif
632 } 641
633 SetupCRT(command_line); 642 SetupCRT(command_line);
634 643
635 #if defined(USE_NSS) 644 #if defined(USE_NSS)
636 crypto::EarlySetupForNSSInit(); 645 crypto::EarlySetupForNSSInit();
637 #endif 646 #endif
638 647
639 // Initialize the Chrome path provider. 648 // Initialize the Chrome path provider.
640 app::RegisterPathProvider(); 649 app::RegisterPathProvider();
641 ui::RegisterPathProvider(); 650 ui::RegisterPathProvider();
642 chrome::RegisterPathProvider(); 651 chrome::RegisterPathProvider();
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 856
848 if (SubprocessNeedsResourceBundle(process_type)) 857 if (SubprocessNeedsResourceBundle(process_type))
849 ResourceBundle::CleanupSharedInstance(); 858 ResourceBundle::CleanupSharedInstance();
850 859
851 logging::CleanupChromeLogging(); 860 logging::CleanupChromeLogging();
852 861
853 chrome_main::LowLevelShutdown(); 862 chrome_main::LowLevelShutdown();
854 863
855 return exit_code; 864 return exit_code;
856 } 865 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698