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 |
11 #include "base/allocator/allocator_extension.h" | |
12 #include "base/base_switches.h" | 11 #include "base/base_switches.h" |
13 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
14 #include "base/command_line.h" | 13 #include "base/command_line.h" |
15 #include "base/debug/leak_annotations.h" | 14 #include "base/debug/leak_annotations.h" |
16 #include "base/debug/profiler.h" | 15 #include "base/debug/profiler.h" |
17 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
18 #include "base/location.h" | 17 #include "base/location.h" |
19 #include "base/logging.h" | 18 #include "base/logging.h" |
20 #include "base/message_loop/timer_slack.h" | 19 #include "base/message_loop/timer_slack.h" |
21 #include "base/metrics/field_trial.h" | 20 #include "base/metrics/field_trial.h" |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 IPC_MESSAGE_HANDLER(ChildProcessMsg_ProfilingPhaseCompleted, | 655 IPC_MESSAGE_HANDLER(ChildProcessMsg_ProfilingPhaseCompleted, |
657 OnProfilingPhaseCompleted) | 656 OnProfilingPhaseCompleted) |
658 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded, | 657 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded, |
659 OnProcessBackgrounded) | 658 OnProcessBackgrounded) |
660 IPC_MESSAGE_HANDLER(MojoMsg_BindExternalMojoShellHandle, | 659 IPC_MESSAGE_HANDLER(MojoMsg_BindExternalMojoShellHandle, |
661 OnBindExternalMojoShellHandle) | 660 OnBindExternalMojoShellHandle) |
662 #if defined(OS_WIN) | 661 #if defined(OS_WIN) |
663 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetMojoParentPipeHandle, | 662 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetMojoParentPipeHandle, |
664 OnSetMojoParentPipeHandle) | 663 OnSetMojoParentPipeHandle) |
665 #endif | 664 #endif |
666 #if defined(USE_TCMALLOC) | |
667 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTcmallocStats, OnGetTcmallocStats) | |
668 #endif | |
669 IPC_MESSAGE_UNHANDLED(handled = false) | 665 IPC_MESSAGE_UNHANDLED(handled = false) |
670 IPC_END_MESSAGE_MAP() | 666 IPC_END_MESSAGE_MAP() |
671 | 667 |
672 if (handled) | 668 if (handled) |
673 return true; | 669 return true; |
674 | 670 |
675 if (msg.routing_id() == MSG_ROUTING_CONTROL) | 671 if (msg.routing_id() == MSG_ROUTING_CONTROL) |
676 return OnControlMessageReceived(msg); | 672 return OnControlMessageReceived(msg); |
677 | 673 |
678 return router_.OnMessageReceived(msg); | 674 return router_.OnMessageReceived(msg); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 #endif // defined(MOJO_SHELL_CLIENT) | 731 #endif // defined(MOJO_SHELL_CLIENT) |
736 } | 732 } |
737 | 733 |
738 #if defined(OS_WIN) | 734 #if defined(OS_WIN) |
739 void ChildThreadImpl::OnSetMojoParentPipeHandle( | 735 void ChildThreadImpl::OnSetMojoParentPipeHandle( |
740 const IPC::PlatformFileForTransit& file) { | 736 const IPC::PlatformFileForTransit& file) { |
741 mojo::embedder::SetParentPipeHandle(file); | 737 mojo::embedder::SetParentPipeHandle(file); |
742 } | 738 } |
743 #endif | 739 #endif |
744 | 740 |
745 #if defined(USE_TCMALLOC) | |
746 void ChildThreadImpl::OnGetTcmallocStats() { | |
747 std::string result; | |
748 char buffer[1024 * 32]; | |
749 base::allocator::GetStats(buffer, sizeof(buffer)); | |
750 result.append(buffer); | |
751 Send(new ChildProcessHostMsg_TcmallocStats(result)); | |
752 } | |
753 #endif | |
754 | |
755 ChildThreadImpl* ChildThreadImpl::current() { | 741 ChildThreadImpl* ChildThreadImpl::current() { |
756 return g_lazy_tls.Pointer()->Get(); | 742 return g_lazy_tls.Pointer()->Get(); |
757 } | 743 } |
758 | 744 |
759 #if defined(OS_ANDROID) | 745 #if defined(OS_ANDROID) |
760 // The method must NOT be called on the child thread itself. | 746 // The method must NOT be called on the child thread itself. |
761 // It may block the child thread if so. | 747 // It may block the child thread if so. |
762 void ChildThreadImpl::ShutdownThread() { | 748 void ChildThreadImpl::ShutdownThread() { |
763 DCHECK(!ChildThreadImpl::current()) << | 749 DCHECK(!ChildThreadImpl::current()) << |
764 "this method should NOT be called from child thread itself"; | 750 "this method should NOT be called from child thread itself"; |
(...skipping 19 matching lines...) Expand all Loading... |
784 void ChildThreadImpl::EnsureConnected() { | 770 void ChildThreadImpl::EnsureConnected() { |
785 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; | 771 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; |
786 base::Process::Current().Terminate(0, false); | 772 base::Process::Current().Terminate(0, false); |
787 } | 773 } |
788 | 774 |
789 bool ChildThreadImpl::IsInBrowserProcess() const { | 775 bool ChildThreadImpl::IsInBrowserProcess() const { |
790 return browser_process_io_runner_; | 776 return browser_process_io_runner_; |
791 } | 777 } |
792 | 778 |
793 } // namespace content | 779 } // namespace content |
OLD | NEW |