OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/public/app/content_main_runner.h" | 5 #include "content/public/app/content_main_runner.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "base/process/process.h" | 37 #include "base/process/process.h" |
38 #include "base/process/process_handle.h" | 38 #include "base/process/process_handle.h" |
39 #include "base/profiler/scoped_tracker.h" | 39 #include "base/profiler/scoped_tracker.h" |
40 #include "base/strings/string_number_conversions.h" | 40 #include "base/strings/string_number_conversions.h" |
41 #include "base/strings/string_util.h" | 41 #include "base/strings/string_util.h" |
42 #include "base/strings/stringprintf.h" | 42 #include "base/strings/stringprintf.h" |
43 #include "base/trace_event/trace_event.h" | 43 #include "base/trace_event/trace_event.h" |
44 #include "build/build_config.h" | 44 #include "build/build_config.h" |
45 #include "components/tracing/common/trace_startup.h" | 45 #include "components/tracing/common/trace_startup.h" |
46 #include "content/app/mojo/mojo_init.h" | 46 #include "content/app/mojo/mojo_init.h" |
47 #include "content/common/set_process_title.h" | |
48 #include "content/common/url_schemes.h" | 47 #include "content/common/url_schemes.h" |
49 #include "content/public/app/content_main.h" | 48 #include "content/public/app/content_main.h" |
50 #include "content/public/app/content_main_delegate.h" | 49 #include "content/public/app/content_main_delegate.h" |
51 #include "content/public/common/content_client.h" | 50 #include "content/public/common/content_client.h" |
52 #include "content/public/common/content_constants.h" | 51 #include "content/public/common/content_constants.h" |
53 #include "content/public/common/content_descriptor_keys.h" | 52 #include "content/public/common/content_descriptor_keys.h" |
54 #include "content/public/common/content_paths.h" | 53 #include "content/public/common/content_paths.h" |
55 #include "content/public/common/content_switches.h" | 54 #include "content/public/common/content_switches.h" |
56 #include "content/public/common/main_function_params.h" | 55 #include "content/public/common/main_function_params.h" |
57 #include "content/public/common/sandbox_init.h" | 56 #include "content/public/common/sandbox_init.h" |
58 #include "ipc/ipc_descriptors.h" | 57 #include "ipc/ipc_descriptors.h" |
59 #include "media/base/media.h" | 58 #include "media/base/media.h" |
60 #include "ppapi/features/features.h" | 59 #include "ppapi/features/features.h" |
61 #include "services/service_manager/public/cpp/shared_file_util.h" | |
62 #include "ui/base/ui_base_paths.h" | 60 #include "ui/base/ui_base_paths.h" |
63 #include "ui/base/ui_base_switches.h" | 61 #include "ui/base/ui_base_switches.h" |
64 | 62 |
65 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) && \ | 63 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) && \ |
66 !defined(CHROME_MULTIPLE_DLL_BROWSER) | 64 !defined(CHROME_MULTIPLE_DLL_BROWSER) |
67 #include "gin/v8_initializer.h" | 65 #include "gin/v8_initializer.h" |
68 #endif | 66 #endif |
69 | 67 |
70 #if defined(OS_WIN) | 68 #if defined(OS_WIN) |
71 #include <malloc.h> | 69 #include <malloc.h> |
72 #include <cstring> | 70 #include <cstring> |
73 | 71 |
74 #include "base/trace_event/trace_event_etw_export_win.h" | 72 #include "base/trace_event/trace_event_etw_export_win.h" |
75 #include "base/win/process_startup_helper.h" | |
76 #include "sandbox/win/src/sandbox_types.h" | 73 #include "sandbox/win/src/sandbox_types.h" |
77 #include "ui/base/win/atl_module.h" | |
78 #include "ui/display/win/dpi.h" | 74 #include "ui/display/win/dpi.h" |
79 #elif defined(OS_MACOSX) | 75 #elif defined(OS_MACOSX) |
80 #include "base/allocator/allocator_shim.h" | |
81 #include "base/mac/scoped_nsautorelease_pool.h" | 76 #include "base/mac/scoped_nsautorelease_pool.h" |
82 #include "base/power_monitor/power_monitor_device_source.h" | 77 #include "base/power_monitor/power_monitor_device_source.h" |
83 #include "content/app/mac/mac_init.h" | |
84 #include "content/browser/mach_broker_mac.h" | 78 #include "content/browser/mach_broker_mac.h" |
85 #include "content/common/sandbox_init_mac.h" | 79 #include "content/common/sandbox_init_mac.h" |
86 #endif // OS_WIN | 80 #endif // OS_WIN |
87 | 81 |
88 #if defined(OS_POSIX) | 82 #if defined(OS_POSIX) |
89 #include <signal.h> | 83 #include <signal.h> |
90 | 84 |
91 #include "base/file_descriptor_store.h" | 85 #include "base/file_descriptor_store.h" |
92 #include "base/posix/global_descriptors.h" | 86 #include "base/posix/global_descriptors.h" |
93 #include "content/public/common/content_descriptors.h" | 87 #include "content/public/common/content_descriptors.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 226 |
233 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) | 227 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) |
234 base::LazyInstance<ContentGpuClient>::DestructorAtExit | 228 base::LazyInstance<ContentGpuClient>::DestructorAtExit |
235 g_empty_content_gpu_client = LAZY_INSTANCE_INITIALIZER; | 229 g_empty_content_gpu_client = LAZY_INSTANCE_INITIALIZER; |
236 base::LazyInstance<ContentRendererClient>::DestructorAtExit | 230 base::LazyInstance<ContentRendererClient>::DestructorAtExit |
237 g_empty_content_renderer_client = LAZY_INSTANCE_INITIALIZER; | 231 g_empty_content_renderer_client = LAZY_INSTANCE_INITIALIZER; |
238 base::LazyInstance<ContentUtilityClient>::DestructorAtExit | 232 base::LazyInstance<ContentUtilityClient>::DestructorAtExit |
239 g_empty_content_utility_client = LAZY_INSTANCE_INITIALIZER; | 233 g_empty_content_utility_client = LAZY_INSTANCE_INITIALIZER; |
240 #endif // !CHROME_MULTIPLE_DLL_BROWSER | 234 #endif // !CHROME_MULTIPLE_DLL_BROWSER |
241 | 235 |
242 #if defined(OS_POSIX) | |
243 | |
244 // Setup signal-handling state: resanitize most signals, ignore SIGPIPE. | |
245 void SetupSignalHandlers() { | |
246 // Sanitise our signal handling state. Signals that were ignored by our | |
247 // parent will also be ignored by us. We also inherit our parent's sigmask. | |
248 sigset_t empty_signal_set; | |
249 CHECK_EQ(0, sigemptyset(&empty_signal_set)); | |
250 CHECK_EQ(0, sigprocmask(SIG_SETMASK, &empty_signal_set, NULL)); | |
251 | |
252 struct sigaction sigact; | |
253 memset(&sigact, 0, sizeof(sigact)); | |
254 sigact.sa_handler = SIG_DFL; | |
255 static const int signals_to_reset[] = | |
256 {SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, | |
257 SIGALRM, SIGTERM, SIGCHLD, SIGBUS, SIGTRAP}; // SIGPIPE is set below. | |
258 for (unsigned i = 0; i < arraysize(signals_to_reset); i++) { | |
259 CHECK_EQ(0, sigaction(signals_to_reset[i], &sigact, NULL)); | |
260 } | |
261 | |
262 // Always ignore SIGPIPE. We check the return value of write(). | |
263 CHECK_NE(SIG_ERR, signal(SIGPIPE, SIG_IGN)); | |
264 } | |
265 | |
266 void PopulateFDsFromCommandLine() { | |
267 const std::string& shared_file_param = | |
268 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
269 switches::kSharedFiles); | |
270 if (shared_file_param.empty()) | |
271 return; | |
272 | |
273 base::Optional<std::map<int, std::string>> shared_file_descriptors = | |
274 service_manager::ParseSharedFileSwitchValue(shared_file_param); | |
275 if (!shared_file_descriptors) | |
276 return; | |
277 | |
278 for (const auto& descriptor : *shared_file_descriptors) { | |
279 base::MemoryMappedFile::Region region; | |
280 const std::string& key = descriptor.second; | |
281 base::ScopedFD fd = base::GlobalDescriptors::GetInstance()->TakeFD( | |
282 descriptor.first, ®ion); | |
283 base::FileDescriptorStore::GetInstance().Set(key, std::move(fd), region); | |
284 } | |
285 } | |
286 | |
287 #endif // OS_POSIX | |
288 | |
289 void CommonSubprocessInit() { | 236 void CommonSubprocessInit() { |
290 #if defined(OS_WIN) | 237 #if defined(OS_WIN) |
291 // HACK: Let Windows know that we have started. This is needed to suppress | 238 // HACK: Let Windows know that we have started. This is needed to suppress |
292 // the IDC_APPSTARTING cursor from being displayed for a prolonged period | 239 // the IDC_APPSTARTING cursor from being displayed for a prolonged period |
293 // while a subprocess is starting. | 240 // while a subprocess is starting. |
294 PostThreadMessage(GetCurrentThreadId(), WM_NULL, 0, 0); | 241 PostThreadMessage(GetCurrentThreadId(), WM_NULL, 0, 0); |
295 MSG msg; | 242 MSG msg; |
296 PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); | 243 PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); |
297 #endif | 244 #endif |
298 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 245 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 Shutdown(); | 472 Shutdown(); |
526 } | 473 } |
527 | 474 |
528 int Initialize(const ContentMainParams& params) override { | 475 int Initialize(const ContentMainParams& params) override { |
529 ui_task_ = params.ui_task; | 476 ui_task_ = params.ui_task; |
530 | 477 |
531 #if defined(USE_AURA) | 478 #if defined(USE_AURA) |
532 env_mode_ = params.env_mode; | 479 env_mode_ = params.env_mode; |
533 #endif | 480 #endif |
534 | 481 |
535 #if defined(OS_MACOSX) && BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM) | |
536 base::allocator::InitializeAllocatorShim(); | |
537 #endif | |
538 base::EnableTerminationOnOutOfMemory(); | |
539 #if defined(OS_WIN) | 482 #if defined(OS_WIN) |
540 base::win::RegisterInvalidParamHandler(); | |
541 ui::win::CreateATLModuleIfNeeded(); | |
542 | |
543 sandbox_info_ = *params.sandbox_info; | 483 sandbox_info_ = *params.sandbox_info; |
544 #else // !OS_WIN | 484 #else // !OS_WIN |
545 | 485 |
| 486 #if defined(OS_MACOSX) |
| 487 autorelease_pool_ = params.autorelease_pool; |
| 488 #endif // defined(OS_MACOSX) |
| 489 |
546 #if defined(OS_ANDROID) | 490 #if defined(OS_ANDROID) |
547 // See note at the initialization of ExitManager, below; basically, | 491 // See note at the initialization of ExitManager, below; basically, |
548 // only Android builds have the ctor/dtor handlers set up to use | 492 // only Android builds have the ctor/dtor handlers set up to use |
549 // TRACE_EVENT right away. | 493 // TRACE_EVENT right away. |
550 TRACE_EVENT0("startup,benchmark,rail", "ContentMainRunnerImpl::Initialize"); | 494 TRACE_EVENT0("startup,benchmark,rail", "ContentMainRunnerImpl::Initialize"); |
551 #endif // OS_ANDROID | 495 #endif // OS_ANDROID |
552 | 496 |
553 base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance(); | 497 base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance(); |
554 ALLOW_UNUSED_LOCAL(g_fds); | 498 ALLOW_UNUSED_LOCAL(g_fds); |
555 | 499 |
556 // On Android, | 500 // On Android, the ipc_fd is passed through the Java service. |
557 // - setlocale() is not supported. | |
558 // - We do not override the signal handlers so that we can get | |
559 // stack trace when crashing. | |
560 // - The ipc_fd is passed through the Java service. | |
561 // Thus, these are all disabled. | |
562 #if !defined(OS_ANDROID) | 501 #if !defined(OS_ANDROID) |
563 // Set C library locale to make sure CommandLine can parse argument values | |
564 // in correct encoding. | |
565 setlocale(LC_ALL, ""); | |
566 | |
567 SetupSignalHandlers(); | |
568 g_fds->Set(kMojoIPCChannel, | 502 g_fds->Set(kMojoIPCChannel, |
569 kMojoIPCChannel + base::GlobalDescriptors::kBaseDescriptor); | 503 kMojoIPCChannel + base::GlobalDescriptors::kBaseDescriptor); |
570 | 504 |
571 g_fds->Set( | 505 g_fds->Set( |
572 kFieldTrialDescriptor, | 506 kFieldTrialDescriptor, |
573 kFieldTrialDescriptor + base::GlobalDescriptors::kBaseDescriptor); | 507 kFieldTrialDescriptor + base::GlobalDescriptors::kBaseDescriptor); |
574 #endif // !OS_ANDROID | 508 #endif // !OS_ANDROID |
575 | 509 |
576 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 510 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
577 g_fds->Set(kCrashDumpSignal, | 511 g_fds->Set(kCrashDumpSignal, |
578 kCrashDumpSignal + base::GlobalDescriptors::kBaseDescriptor); | 512 kCrashDumpSignal + base::GlobalDescriptors::kBaseDescriptor); |
579 #endif // OS_LINUX || OS_OPENBSD | 513 #endif // OS_LINUX || OS_OPENBSD |
580 | 514 |
581 | |
582 #endif // !OS_WIN | 515 #endif // !OS_WIN |
583 | 516 |
584 is_initialized_ = true; | 517 is_initialized_ = true; |
585 delegate_ = params.delegate; | 518 delegate_ = params.delegate; |
586 | 519 |
587 // The exit manager is in charge of calling the dtors of singleton objects. | 520 // The exit manager is in charge of calling the dtors of singleton objects. |
588 // On Android, AtExitManager is set up when library is loaded. | 521 // On Android, AtExitManager is set up when library is loaded. |
589 // A consequence of this is that you can't use the ctor/dtor-based | 522 // A consequence of this is that you can't use the ctor/dtor-based |
590 // TRACE_EVENT methods on Linux or iOS builds till after we set this up. | 523 // TRACE_EVENT methods on Linux or iOS builds till after we set this up. |
591 #if !defined(OS_ANDROID) | 524 #if !defined(OS_ANDROID) |
592 if (!ui_task_) { | 525 if (!ui_task_) { |
593 // When running browser tests, don't create a second AtExitManager as that | 526 // When running browser tests, don't create a second AtExitManager as that |
594 // interfers with shutdown when objects created before ContentMain is | 527 // interfers with shutdown when objects created before ContentMain is |
595 // called are destructed when it returns. | 528 // called are destructed when it returns. |
596 exit_manager_.reset(new base::AtExitManager); | 529 exit_manager_.reset(new base::AtExitManager); |
597 } | 530 } |
598 #endif // !OS_ANDROID | 531 #endif // !OS_ANDROID |
599 | 532 |
600 #if defined(OS_MACOSX) | |
601 // We need this pool for all the objects created before we get to the | |
602 // event loop, but we don't want to leave them hanging around until the | |
603 // app quits. Each "main" needs to flush this pool right before it goes into | |
604 // its main event loop to get rid of the cruft. | |
605 autorelease_pool_.reset(new base::mac::ScopedNSAutoreleasePool()); | |
606 InitializeMac(); | |
607 #endif | |
608 | |
609 // On Android, the command line is initialized and the FDs set when the | |
610 // library is loaded and we have already started our TRACE_EVENT0. | |
611 #if !defined(OS_ANDROID) | 533 #if !defined(OS_ANDROID) |
612 // argc/argv are ignored on Windows and Android; see command_line.h for | |
613 // details. | |
614 int argc = 0; | |
615 const char** argv = NULL; | |
616 | |
617 #if !defined(OS_WIN) | |
618 argc = params.argc; | |
619 argv = params.argv; | |
620 #endif | |
621 | |
622 base::CommandLine::Init(argc, argv); | |
623 | |
624 #if defined(OS_POSIX) | |
625 PopulateFDsFromCommandLine(); | |
626 #endif | |
627 | |
628 base::EnableTerminationOnHeapCorruption(); | |
629 | |
630 // TODO(yiyaoliu, vadimt): Remove this once crbug.com/453640 is fixed. | |
631 // Enable profiler recording right after command line is initialized so that | |
632 // browser startup can be instrumented. | |
633 if (delegate_ && delegate_->ShouldEnableProfilerRecording()) | 534 if (delegate_ && delegate_->ShouldEnableProfilerRecording()) |
634 tracked_objects::ScopedTracker::Enable(); | 535 tracked_objects::ScopedTracker::Enable(); |
635 | |
636 SetProcessTitleFromCommandLine(argv); | |
637 #endif // !OS_ANDROID | 536 #endif // !OS_ANDROID |
638 | 537 |
639 int exit_code = 0; | 538 int exit_code = 0; |
640 if (delegate_ && delegate_->BasicStartupComplete(&exit_code)) | 539 if (delegate_ && delegate_->BasicStartupComplete(&exit_code)) |
641 return exit_code; | 540 return exit_code; |
642 | 541 |
643 completed_basic_startup_ = true; | 542 completed_basic_startup_ = true; |
644 | 543 |
645 const base::CommandLine& command_line = | 544 const base::CommandLine& command_line = |
646 *base::CommandLine::ForCurrentProcess(); | 545 *base::CommandLine::ForCurrentProcess(); |
647 std::string process_type = | 546 std::string process_type = |
648 command_line.GetSwitchValueASCII(switches::kProcessType); | 547 command_line.GetSwitchValueASCII(switches::kProcessType); |
649 | 548 |
650 // Initialize mojo here so that services can be registered. | |
651 InitializeMojo(); | |
652 | |
653 #if defined(OS_WIN) | 549 #if defined(OS_WIN) |
654 if (command_line.HasSwitch(switches::kDeviceScaleFactor)) { | 550 if (command_line.HasSwitch(switches::kDeviceScaleFactor)) { |
655 std::string scale_factor_string = command_line.GetSwitchValueASCII( | 551 std::string scale_factor_string = command_line.GetSwitchValueASCII( |
656 switches::kDeviceScaleFactor); | 552 switches::kDeviceScaleFactor); |
657 double scale_factor = 0; | 553 double scale_factor = 0; |
658 if (base::StringToDouble(scale_factor_string, &scale_factor)) | 554 if (base::StringToDouble(scale_factor_string, &scale_factor)) |
659 display::win::SetDefaultDeviceScaleFactor(scale_factor); | 555 display::win::SetDefaultDeviceScaleFactor(scale_factor); |
660 } | 556 } |
661 #endif | 557 #endif |
662 | 558 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 if (process_type.empty() || | 599 if (process_type.empty() || |
704 (delegate_ && | 600 (delegate_ && |
705 delegate_->ProcessRegistersWithSystemProcess(process_type))) { | 601 delegate_->ProcessRegistersWithSystemProcess(process_type))) { |
706 base::PowerMonitorDeviceSource::AllocateSystemIOPorts(); | 602 base::PowerMonitorDeviceSource::AllocateSystemIOPorts(); |
707 } | 603 } |
708 | 604 |
709 if (!process_type.empty() && | 605 if (!process_type.empty() && |
710 (!delegate_ || delegate_->ShouldSendMachPort(process_type))) { | 606 (!delegate_ || delegate_->ShouldSendMachPort(process_type))) { |
711 MachBroker::ChildSendTaskPortToParent(); | 607 MachBroker::ChildSendTaskPortToParent(); |
712 } | 608 } |
713 #elif defined(OS_WIN) | |
714 base::win::SetupCRT(command_line); | |
715 #endif | 609 #endif |
716 | 610 |
717 // If we are on a platform where the default allocator is overridden (shim | 611 // If we are on a platform where the default allocator is overridden (shim |
718 // layer on windows, tcmalloc on Linux Desktop) smoke-tests that the | 612 // layer on windows, tcmalloc on Linux Desktop) smoke-tests that the |
719 // overriding logic is working correctly. If not causes a hard crash, as its | 613 // overriding logic is working correctly. If not causes a hard crash, as its |
720 // unexpected absence has security implications. | 614 // unexpected absence has security implications. |
721 CHECK(base::allocator::IsAllocatorInitialized()); | 615 CHECK(base::allocator::IsAllocatorInitialized()); |
722 | 616 |
723 #if defined(OS_POSIX) | 617 #if defined(OS_POSIX) |
724 if (!process_type.empty()) { | 618 if (!process_type.empty()) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 if (!process_type.empty() && process_type != switches::kZygoteProcess) | 714 if (!process_type.empty() && process_type != switches::kZygoteProcess) |
821 InitializeFieldTrialAndFeatureList(&field_trial_list); | 715 InitializeFieldTrialAndFeatureList(&field_trial_list); |
822 | 716 |
823 base::HistogramBase::EnableActivityReportHistogram(process_type); | 717 base::HistogramBase::EnableActivityReportHistogram(process_type); |
824 | 718 |
825 MainFunctionParams main_params(command_line); | 719 MainFunctionParams main_params(command_line); |
826 main_params.ui_task = ui_task_; | 720 main_params.ui_task = ui_task_; |
827 #if defined(OS_WIN) | 721 #if defined(OS_WIN) |
828 main_params.sandbox_info = &sandbox_info_; | 722 main_params.sandbox_info = &sandbox_info_; |
829 #elif defined(OS_MACOSX) | 723 #elif defined(OS_MACOSX) |
830 main_params.autorelease_pool = autorelease_pool_.get(); | 724 main_params.autorelease_pool = autorelease_pool_; |
831 #endif | 725 #endif |
832 #if defined(USE_AURA) | 726 #if defined(USE_AURA) |
833 main_params.env_mode = env_mode_; | 727 main_params.env_mode = env_mode_; |
834 #endif | 728 #endif |
835 | 729 |
836 return RunNamedProcessTypeMain(process_type, main_params, delegate_); | 730 return RunNamedProcessTypeMain(process_type, main_params, delegate_); |
837 } | 731 } |
838 | 732 |
839 void Shutdown() override { | 733 void Shutdown() override { |
840 DCHECK(is_initialized_); | 734 DCHECK(is_initialized_); |
841 DCHECK(!is_shutdown_); | 735 DCHECK(!is_shutdown_); |
842 | 736 |
843 if (completed_basic_startup_ && delegate_) { | 737 if (completed_basic_startup_ && delegate_) { |
844 const base::CommandLine& command_line = | 738 const base::CommandLine& command_line = |
845 *base::CommandLine::ForCurrentProcess(); | 739 *base::CommandLine::ForCurrentProcess(); |
846 std::string process_type = | 740 std::string process_type = |
847 command_line.GetSwitchValueASCII(switches::kProcessType); | 741 command_line.GetSwitchValueASCII(switches::kProcessType); |
848 | 742 |
849 delegate_->ProcessExiting(process_type); | 743 delegate_->ProcessExiting(process_type); |
850 } | 744 } |
851 | 745 |
852 #if defined(OS_WIN) | 746 #if defined(OS_WIN) |
853 #ifdef _CRTDBG_MAP_ALLOC | 747 #ifdef _CRTDBG_MAP_ALLOC |
854 _CrtDumpMemoryLeaks(); | 748 _CrtDumpMemoryLeaks(); |
855 #endif // _CRTDBG_MAP_ALLOC | 749 #endif // _CRTDBG_MAP_ALLOC |
856 #endif // OS_WIN | 750 #endif // OS_WIN |
857 | 751 |
858 #if defined(OS_MACOSX) | |
859 autorelease_pool_.reset(NULL); | |
860 #endif | |
861 | |
862 exit_manager_.reset(NULL); | 752 exit_manager_.reset(NULL); |
863 | 753 |
864 delegate_ = NULL; | 754 delegate_ = NULL; |
865 is_shutdown_ = true; | 755 is_shutdown_ = true; |
866 } | 756 } |
867 | 757 |
868 private: | 758 private: |
869 // True if the runner has been initialized. | 759 // True if the runner has been initialized. |
870 bool is_initialized_; | 760 bool is_initialized_; |
871 | 761 |
872 // True if the runner has been shut down. | 762 // True if the runner has been shut down. |
873 bool is_shutdown_; | 763 bool is_shutdown_; |
874 | 764 |
875 // True if basic startup was completed. | 765 // True if basic startup was completed. |
876 bool completed_basic_startup_; | 766 bool completed_basic_startup_; |
877 | 767 |
878 // Used if the embedder doesn't set one. | 768 // Used if the embedder doesn't set one. |
879 ContentClient empty_content_client_; | 769 ContentClient empty_content_client_; |
880 | 770 |
881 // The delegate will outlive this object. | 771 // The delegate will outlive this object. |
882 ContentMainDelegate* delegate_; | 772 ContentMainDelegate* delegate_; |
883 | 773 |
884 std::unique_ptr<base::AtExitManager> exit_manager_; | 774 std::unique_ptr<base::AtExitManager> exit_manager_; |
885 #if defined(OS_WIN) | 775 #if defined(OS_WIN) |
886 sandbox::SandboxInterfaceInfo sandbox_info_; | 776 sandbox::SandboxInterfaceInfo sandbox_info_; |
887 #elif defined(OS_MACOSX) | 777 #elif defined(OS_MACOSX) |
888 std::unique_ptr<base::mac::ScopedNSAutoreleasePool> autorelease_pool_; | 778 base::mac::ScopedNSAutoreleasePool* autorelease_pool_ = nullptr; |
889 #endif | 779 #endif |
890 | 780 |
891 base::Closure* ui_task_; | 781 base::Closure* ui_task_; |
892 | 782 |
893 #if defined(USE_AURA) | 783 #if defined(USE_AURA) |
894 aura::Env::Mode env_mode_ = aura::Env::Mode::LOCAL; | 784 aura::Env::Mode env_mode_ = aura::Env::Mode::LOCAL; |
895 #endif | 785 #endif |
896 | 786 |
897 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 787 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
898 }; | 788 }; |
899 | 789 |
900 // static | 790 // static |
901 ContentMainRunner* ContentMainRunner::Create() { | 791 ContentMainRunner* ContentMainRunner::Create() { |
902 return new ContentMainRunnerImpl(); | 792 return new ContentMainRunnerImpl(); |
903 } | 793 } |
904 | 794 |
905 } // namespace content | 795 } // namespace content |
OLD | NEW |