| 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 <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "base/allocator/allocator_extension.h" | 9 #include "base/allocator/allocator_extension.h" |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 base::LazyInstance<ContentRendererClient> | 173 base::LazyInstance<ContentRendererClient> |
| 174 g_empty_content_renderer_client = LAZY_INSTANCE_INITIALIZER; | 174 g_empty_content_renderer_client = LAZY_INSTANCE_INITIALIZER; |
| 175 base::LazyInstance<ContentUtilityClient> | 175 base::LazyInstance<ContentUtilityClient> |
| 176 g_empty_content_utility_client = LAZY_INSTANCE_INITIALIZER; | 176 g_empty_content_utility_client = LAZY_INSTANCE_INITIALIZER; |
| 177 #endif // !OS_IOS | 177 #endif // !OS_IOS |
| 178 | 178 |
| 179 #if defined(OS_WIN) | 179 #if defined(OS_WIN) |
| 180 | 180 |
| 181 static CAppModule _Module; | 181 static CAppModule _Module; |
| 182 | 182 |
| 183 #elif defined(OS_MACOSX) && !defined(OS_IOS) | |
| 184 | |
| 185 // Completes the Mach IPC handshake by sending this process' task port to the | |
| 186 // parent process. The parent is listening on the Mach port given by | |
| 187 // |GetMachPortName()|. The task port is used by the parent to get CPU/memory | |
| 188 // stats to display in the task manager. | |
| 189 void SendTaskPortToParentProcess() { | |
| 190 const mach_msg_timeout_t kTimeoutMs = 100; | |
| 191 const int32_t kMessageId = 0; | |
| 192 std::string mach_port_name = MachBroker::GetMachPortName(); | |
| 193 | |
| 194 base::MachSendMessage child_message(kMessageId); | |
| 195 if (!child_message.AddDescriptor(mach_task_self())) { | |
| 196 LOG(ERROR) << "child AddDescriptor(mach_task_self()) failed."; | |
| 197 return; | |
| 198 } | |
| 199 | |
| 200 base::MachPortSender child_sender(mach_port_name.c_str()); | |
| 201 kern_return_t err = child_sender.SendMessage(child_message, kTimeoutMs); | |
| 202 if (err != KERN_SUCCESS) { | |
| 203 LOG(ERROR) << | |
| 204 base::StringPrintf("child SendMessage() failed: 0x%x %s", err, | |
| 205 mach_error_string(err)); | |
| 206 } | |
| 207 } | |
| 208 | |
| 209 #endif // defined(OS_WIN) | 183 #endif // defined(OS_WIN) |
| 210 | 184 |
| 211 #if defined(OS_POSIX) && !defined(OS_IOS) | 185 #if defined(OS_POSIX) && !defined(OS_IOS) |
| 212 | 186 |
| 213 // Setup signal-handling state: resanitize most signals, ignore SIGPIPE. | 187 // Setup signal-handling state: resanitize most signals, ignore SIGPIPE. |
| 214 void SetupSignalHandlers() { | 188 void SetupSignalHandlers() { |
| 215 // Sanitise our signal handling state. Signals that were ignored by our | 189 // Sanitise our signal handling state. Signals that were ignored by our |
| 216 // parent will also be ignored by us. We also inherit our parent's sigmask. | 190 // parent will also be ignored by us. We also inherit our parent's sigmask. |
| 217 sigset_t empty_signal_set; | 191 sigset_t empty_signal_set; |
| 218 CHECK(0 == sigemptyset(&empty_signal_set)); | 192 CHECK(0 == sigemptyset(&empty_signal_set)); |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 process_type == switches::kRendererProcess || | 633 process_type == switches::kRendererProcess || |
| 660 process_type == switches::kUtilityProcess || | 634 process_type == switches::kUtilityProcess || |
| 661 process_type == switches::kWorkerProcess || | 635 process_type == switches::kWorkerProcess || |
| 662 (delegate && | 636 (delegate && |
| 663 delegate->ProcessRegistersWithSystemProcess(process_type))) { | 637 delegate->ProcessRegistersWithSystemProcess(process_type))) { |
| 664 base::PowerMonitor::AllocateSystemIOPorts(); | 638 base::PowerMonitor::AllocateSystemIOPorts(); |
| 665 } | 639 } |
| 666 | 640 |
| 667 if (!process_type.empty() && | 641 if (!process_type.empty() && |
| 668 (!delegate || delegate->ShouldSendMachPort(process_type))) { | 642 (!delegate || delegate->ShouldSendMachPort(process_type))) { |
| 669 SendTaskPortToParentProcess(); | 643 MachBroker::ChildSendTaskPortToParent(); |
| 670 } | 644 } |
| 671 #elif defined(OS_WIN) | 645 #elif defined(OS_WIN) |
| 672 // This must be done early enough since some helper functions like | 646 // This must be done early enough since some helper functions like |
| 673 // IsTouchEnabled, needed to load resources, may call into the theme dll. | 647 // IsTouchEnabled, needed to load resources, may call into the theme dll. |
| 674 EnableThemeSupportOnAllWindowStations(); | 648 EnableThemeSupportOnAllWindowStations(); |
| 675 #if defined(ENABLE_HIDPI) | 649 #if defined(ENABLE_HIDPI) |
| 676 ui::EnableHighDPISupport(); | 650 ui::EnableHighDPISupport(); |
| 677 #endif | 651 #endif |
| 678 SetupCRT(command_line); | 652 SetupCRT(command_line); |
| 679 #endif | 653 #endif |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 | 796 |
| 823 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 797 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
| 824 }; | 798 }; |
| 825 | 799 |
| 826 // static | 800 // static |
| 827 ContentMainRunner* ContentMainRunner::Create() { | 801 ContentMainRunner* ContentMainRunner::Create() { |
| 828 return new ContentMainRunnerImpl(); | 802 return new ContentMainRunnerImpl(); |
| 829 } | 803 } |
| 830 | 804 |
| 831 } // namespace content | 805 } // namespace content |
| OLD | NEW |