| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 #endif | 66 #endif |
| 67 | 67 |
| 68 #if defined(OS_MACOSX) | 68 #if defined(OS_MACOSX) |
| 69 #include "content/child/child_io_surface_manager_mac.h" | 69 #include "content/child/child_io_surface_manager_mac.h" |
| 70 #endif | 70 #endif |
| 71 | 71 |
| 72 #if defined(USE_OZONE) | 72 #if defined(USE_OZONE) |
| 73 #include "ui/ozone/public/client_native_pixmap_factory.h" | 73 #include "ui/ozone/public/client_native_pixmap_factory.h" |
| 74 #endif | 74 #endif |
| 75 | 75 |
| 76 #if defined(MOJO_SHELL_CLIENT) | |
| 77 #include "content/common/mojo/mojo_messages.h" | |
| 78 #include "content/common/mojo/mojo_shell_connection_impl.h" | |
| 79 #endif | |
| 80 | |
| 81 using tracked_objects::ThreadData; | 76 using tracked_objects::ThreadData; |
| 82 | 77 |
| 83 namespace content { | 78 namespace content { |
| 84 namespace { | 79 namespace { |
| 85 | 80 |
| 86 // How long to wait for a connection to the browser process before giving up. | 81 // How long to wait for a connection to the browser process before giving up. |
| 87 const int kConnectionTimeoutS = 15; | 82 const int kConnectionTimeoutS = 15; |
| 88 | 83 |
| 89 base::LazyInstance<base::ThreadLocalPointer<ChildThreadImpl> > g_lazy_tls = | 84 base::LazyInstance<base::ThreadLocalPointer<ChildThreadImpl> > g_lazy_tls = |
| 90 LAZY_INSTANCE_INITIALIZER; | 85 LAZY_INSTANCE_INITIALIZER; |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 OnSetProfilerStatus) | 647 OnSetProfilerStatus) |
| 653 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData, | 648 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData, |
| 654 OnGetChildProfilerData) | 649 OnGetChildProfilerData) |
| 655 IPC_MESSAGE_HANDLER(ChildProcessMsg_ProfilingPhaseCompleted, | 650 IPC_MESSAGE_HANDLER(ChildProcessMsg_ProfilingPhaseCompleted, |
| 656 OnProfilingPhaseCompleted) | 651 OnProfilingPhaseCompleted) |
| 657 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded, | 652 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded, |
| 658 OnProcessBackgrounded) | 653 OnProcessBackgrounded) |
| 659 #if defined(USE_TCMALLOC) | 654 #if defined(USE_TCMALLOC) |
| 660 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTcmallocStats, OnGetTcmallocStats) | 655 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTcmallocStats, OnGetTcmallocStats) |
| 661 #endif | 656 #endif |
| 662 #if defined(MOJO_SHELL_CLIENT) | |
| 663 IPC_MESSAGE_HANDLER(MojoMsg_BindControllerHandle, OnBindControllerHandle) | |
| 664 #endif | |
| 665 IPC_MESSAGE_UNHANDLED(handled = false) | 657 IPC_MESSAGE_UNHANDLED(handled = false) |
| 666 IPC_END_MESSAGE_MAP() | 658 IPC_END_MESSAGE_MAP() |
| 667 | 659 |
| 668 if (handled) | 660 if (handled) |
| 669 return true; | 661 return true; |
| 670 | 662 |
| 671 if (msg.routing_id() == MSG_ROUTING_CONTROL) | 663 if (msg.routing_id() == MSG_ROUTING_CONTROL) |
| 672 return OnControlMessageReceived(msg); | 664 return OnControlMessageReceived(msg); |
| 673 | 665 |
| 674 return router_.OnMessageReceived(msg); | 666 return router_.OnMessageReceived(msg); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 #if defined(USE_TCMALLOC) | 711 #if defined(USE_TCMALLOC) |
| 720 void ChildThreadImpl::OnGetTcmallocStats() { | 712 void ChildThreadImpl::OnGetTcmallocStats() { |
| 721 std::string result; | 713 std::string result; |
| 722 char buffer[1024 * 32]; | 714 char buffer[1024 * 32]; |
| 723 base::allocator::GetStats(buffer, sizeof(buffer)); | 715 base::allocator::GetStats(buffer, sizeof(buffer)); |
| 724 result.append(buffer); | 716 result.append(buffer); |
| 725 Send(new ChildProcessHostMsg_TcmallocStats(result)); | 717 Send(new ChildProcessHostMsg_TcmallocStats(result)); |
| 726 } | 718 } |
| 727 #endif | 719 #endif |
| 728 | 720 |
| 729 #if defined(MOJO_SHELL_CLIENT) | |
| 730 void ChildThreadImpl::OnBindControllerHandle( | |
| 731 const IPC::PlatformFileForTransit& file) { | |
| 732 #if defined(OS_POSIX) | |
| 733 base::PlatformFile handle = file.fd; | |
| 734 #elif defined(OS_WIN) | |
| 735 base::PlatformFile handle = file; | |
| 736 #endif | |
| 737 mojo::ScopedMessagePipeHandle message_pipe = | |
| 738 mojo_shell_channel_init_.Init(handle, GetIOTaskRunner()); | |
| 739 DCHECK(message_pipe.is_valid()); | |
| 740 MojoShellConnectionImpl::CreateWithMessagePipe(message_pipe.Pass()); | |
| 741 } | |
| 742 #endif | |
| 743 | |
| 744 ChildThreadImpl* ChildThreadImpl::current() { | 721 ChildThreadImpl* ChildThreadImpl::current() { |
| 745 return g_lazy_tls.Pointer()->Get(); | 722 return g_lazy_tls.Pointer()->Get(); |
| 746 } | 723 } |
| 747 | 724 |
| 748 #if defined(OS_ANDROID) | 725 #if defined(OS_ANDROID) |
| 749 // The method must NOT be called on the child thread itself. | 726 // The method must NOT be called on the child thread itself. |
| 750 // It may block the child thread if so. | 727 // It may block the child thread if so. |
| 751 void ChildThreadImpl::ShutdownThread() { | 728 void ChildThreadImpl::ShutdownThread() { |
| 752 DCHECK(!ChildThreadImpl::current()) << | 729 DCHECK(!ChildThreadImpl::current()) << |
| 753 "this method should NOT be called from child thread itself"; | 730 "this method should NOT be called from child thread itself"; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 773 void ChildThreadImpl::EnsureConnected() { | 750 void ChildThreadImpl::EnsureConnected() { |
| 774 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; | 751 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; |
| 775 base::Process::Current().Terminate(0, false); | 752 base::Process::Current().Terminate(0, false); |
| 776 } | 753 } |
| 777 | 754 |
| 778 bool ChildThreadImpl::IsInBrowserProcess() const { | 755 bool ChildThreadImpl::IsInBrowserProcess() const { |
| 779 return browser_process_io_runner_; | 756 return browser_process_io_runner_; |
| 780 } | 757 } |
| 781 | 758 |
| 782 } // namespace content | 759 } // namespace content |
| OLD | NEW |