| 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/child/child_thread_impl.h" | 5 #include "content/child/child_thread_impl.h" |
| 6 | 6 |
| 7 #include <signal.h> | 7 #include <signal.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "content/child/power_monitor_broadcast_source.h" | 45 #include "content/child/power_monitor_broadcast_source.h" |
| 46 #include "content/child/push_messaging/push_dispatcher.h" | 46 #include "content/child/push_messaging/push_dispatcher.h" |
| 47 #include "content/child/quota_dispatcher.h" | 47 #include "content/child/quota_dispatcher.h" |
| 48 #include "content/child/quota_message_filter.h" | 48 #include "content/child/quota_message_filter.h" |
| 49 #include "content/child/resource_dispatcher.h" | 49 #include "content/child/resource_dispatcher.h" |
| 50 #include "content/child/service_worker/service_worker_message_filter.h" | 50 #include "content/child/service_worker/service_worker_message_filter.h" |
| 51 #include "content/child/thread_safe_sender.h" | 51 #include "content/child/thread_safe_sender.h" |
| 52 #include "content/child/websocket_dispatcher.h" | 52 #include "content/child/websocket_dispatcher.h" |
| 53 #include "content/common/child_process_messages.h" | 53 #include "content/common/child_process_messages.h" |
| 54 #include "content/common/in_process_child_thread_params.h" | 54 #include "content/common/in_process_child_thread_params.h" |
| 55 #include "content/common/mojo/mojo_messages.h" |
| 55 #include "content/public/common/content_switches.h" | 56 #include "content/public/common/content_switches.h" |
| 56 #include "ipc/attachment_broker.h" | 57 #include "ipc/attachment_broker.h" |
| 57 #include "ipc/attachment_broker_unprivileged.h" | 58 #include "ipc/attachment_broker_unprivileged.h" |
| 58 #include "ipc/ipc_logging.h" | 59 #include "ipc/ipc_logging.h" |
| 59 #include "ipc/ipc_switches.h" | 60 #include "ipc/ipc_switches.h" |
| 60 #include "ipc/ipc_sync_channel.h" | 61 #include "ipc/ipc_sync_channel.h" |
| 61 #include "ipc/ipc_sync_message_filter.h" | 62 #include "ipc/ipc_sync_message_filter.h" |
| 62 #include "ipc/mojo/ipc_channel_mojo.h" | 63 #include "ipc/mojo/ipc_channel_mojo.h" |
| 63 | 64 |
| 64 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) | 65 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) |
| 65 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" | 66 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" |
| 66 #endif | 67 #endif |
| 67 | 68 |
| 68 #if defined(OS_MACOSX) | 69 #if defined(OS_MACOSX) |
| 69 #include "content/child/child_io_surface_manager_mac.h" | 70 #include "content/child/child_io_surface_manager_mac.h" |
| 70 #endif | 71 #endif |
| 71 | 72 |
| 72 #if defined(USE_OZONE) | 73 #if defined(USE_OZONE) |
| 73 #include "ui/ozone/public/client_native_pixmap_factory.h" | 74 #include "ui/ozone/public/client_native_pixmap_factory.h" |
| 74 #endif | 75 #endif |
| 75 | 76 |
| 77 #if defined(MOJO_SHELL_CLIENT) |
| 78 #include "content/common/mojo/mojo_shell_connection_impl.h" |
| 79 #endif |
| 80 |
| 76 using tracked_objects::ThreadData; | 81 using tracked_objects::ThreadData; |
| 77 | 82 |
| 78 namespace content { | 83 namespace content { |
| 79 namespace { | 84 namespace { |
| 80 | 85 |
| 81 // How long to wait for a connection to the browser process before giving up. | 86 // How long to wait for a connection to the browser process before giving up. |
| 82 const int kConnectionTimeoutS = 15; | 87 const int kConnectionTimeoutS = 15; |
| 83 | 88 |
| 84 base::LazyInstance<base::ThreadLocalPointer<ChildThreadImpl> > g_lazy_tls = | 89 base::LazyInstance<base::ThreadLocalPointer<ChildThreadImpl> > g_lazy_tls = |
| 85 LAZY_INSTANCE_INITIALIZER; | 90 LAZY_INSTANCE_INITIALIZER; |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 OnSetIPCLoggingEnabled) | 649 OnSetIPCLoggingEnabled) |
| 645 #endif | 650 #endif |
| 646 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProfilerStatus, | 651 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProfilerStatus, |
| 647 OnSetProfilerStatus) | 652 OnSetProfilerStatus) |
| 648 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData, | 653 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData, |
| 649 OnGetChildProfilerData) | 654 OnGetChildProfilerData) |
| 650 IPC_MESSAGE_HANDLER(ChildProcessMsg_ProfilingPhaseCompleted, | 655 IPC_MESSAGE_HANDLER(ChildProcessMsg_ProfilingPhaseCompleted, |
| 651 OnProfilingPhaseCompleted) | 656 OnProfilingPhaseCompleted) |
| 652 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded, | 657 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded, |
| 653 OnProcessBackgrounded) | 658 OnProcessBackgrounded) |
| 659 IPC_MESSAGE_HANDLER(MojoMsg_BindExternalMojoShellHandle, |
| 660 OnBindExternalMojoShellHandle) |
| 654 #if defined(USE_TCMALLOC) | 661 #if defined(USE_TCMALLOC) |
| 655 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTcmallocStats, OnGetTcmallocStats) | 662 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTcmallocStats, OnGetTcmallocStats) |
| 656 #endif | 663 #endif |
| 657 IPC_MESSAGE_UNHANDLED(handled = false) | 664 IPC_MESSAGE_UNHANDLED(handled = false) |
| 658 IPC_END_MESSAGE_MAP() | 665 IPC_END_MESSAGE_MAP() |
| 659 | 666 |
| 660 if (handled) | 667 if (handled) |
| 661 return true; | 668 return true; |
| 662 | 669 |
| 663 if (msg.routing_id() == MSG_ROUTING_CONTROL) | 670 if (msg.routing_id() == MSG_ROUTING_CONTROL) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 ThreadData::Snapshot(current_profiling_phase, &process_data); | 708 ThreadData::Snapshot(current_profiling_phase, &process_data); |
| 702 | 709 |
| 703 Send( | 710 Send( |
| 704 new ChildProcessHostMsg_ChildProfilerData(sequence_number, process_data)); | 711 new ChildProcessHostMsg_ChildProfilerData(sequence_number, process_data)); |
| 705 } | 712 } |
| 706 | 713 |
| 707 void ChildThreadImpl::OnProfilingPhaseCompleted(int profiling_phase) { | 714 void ChildThreadImpl::OnProfilingPhaseCompleted(int profiling_phase) { |
| 708 ThreadData::OnProfilingPhaseCompleted(profiling_phase); | 715 ThreadData::OnProfilingPhaseCompleted(profiling_phase); |
| 709 } | 716 } |
| 710 | 717 |
| 718 void ChildThreadImpl::OnBindExternalMojoShellHandle( |
| 719 const IPC::PlatformFileForTransit& file) { |
| 720 #if defined(MOJO_SHELL_CLIENT) |
| 721 #if defined(OS_POSIX) |
| 722 base::PlatformFile handle = file.fd; |
| 723 #elif defined(OS_WIN) |
| 724 base::PlatformFile handle = file; |
| 725 #endif |
| 726 mojo::ScopedMessagePipeHandle message_pipe = |
| 727 mojo_shell_channel_init_.Init(handle, GetIOTaskRunner()); |
| 728 DCHECK(message_pipe.is_valid()); |
| 729 MojoShellConnectionImpl::CreateWithMessagePipe(message_pipe.Pass()); |
| 730 #endif // defined(MOJO_SHELL_CLIENT) |
| 731 } |
| 732 |
| 711 #if defined(USE_TCMALLOC) | 733 #if defined(USE_TCMALLOC) |
| 712 void ChildThreadImpl::OnGetTcmallocStats() { | 734 void ChildThreadImpl::OnGetTcmallocStats() { |
| 713 std::string result; | 735 std::string result; |
| 714 char buffer[1024 * 32]; | 736 char buffer[1024 * 32]; |
| 715 base::allocator::GetStats(buffer, sizeof(buffer)); | 737 base::allocator::GetStats(buffer, sizeof(buffer)); |
| 716 result.append(buffer); | 738 result.append(buffer); |
| 717 Send(new ChildProcessHostMsg_TcmallocStats(result)); | 739 Send(new ChildProcessHostMsg_TcmallocStats(result)); |
| 718 } | 740 } |
| 719 #endif | 741 #endif |
| 720 | 742 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 750 void ChildThreadImpl::EnsureConnected() { | 772 void ChildThreadImpl::EnsureConnected() { |
| 751 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; | 773 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; |
| 752 base::Process::Current().Terminate(0, false); | 774 base::Process::Current().Terminate(0, false); |
| 753 } | 775 } |
| 754 | 776 |
| 755 bool ChildThreadImpl::IsInBrowserProcess() const { | 777 bool ChildThreadImpl::IsInBrowserProcess() const { |
| 756 return browser_process_io_runner_; | 778 return browser_process_io_runner_; |
| 757 } | 779 } |
| 758 | 780 |
| 759 } // namespace content | 781 } // namespace content |
| OLD | NEW |