OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
7 | 7 |
8 #include "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 channel_ = CreateChannelProxy(channel_id); | 729 channel_ = CreateChannelProxy(channel_id); |
730 | 730 |
731 // Call the embedder first so that their IPC filters have priority. | 731 // Call the embedder first so that their IPC filters have priority. |
732 GetContentClient()->browser()->RenderProcessWillLaunch(this); | 732 GetContentClient()->browser()->RenderProcessWillLaunch(this); |
733 | 733 |
734 #if !defined(OS_MACOSX) | 734 #if !defined(OS_MACOSX) |
735 // Intentionally delay the hang monitor creation after the first renderer | 735 // Intentionally delay the hang monitor creation after the first renderer |
736 // is created. On Mac audio thread is the UI thread, a hang monitor is not | 736 // is created. On Mac audio thread is the UI thread, a hang monitor is not |
737 // necessary or recommended. | 737 // necessary or recommended. |
738 media::AudioManager::StartHangMonitorIfNeeded( | 738 media::AudioManager::StartHangMonitorIfNeeded( |
739 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 739 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); |
740 #endif // !defined(OS_MACOSX) | 740 #endif // !defined(OS_MACOSX) |
741 | 741 |
742 #if defined(OS_ANDROID) | 742 #if defined(OS_ANDROID) |
743 // Initialize the java audio manager so that media session tests will pass. | 743 // Initialize the java audio manager so that media session tests will pass. |
744 // See internal b/29872494. | 744 // See internal b/29872494. |
745 static_cast<media::AudioManagerAndroid*>(media::AudioManager::Get())-> | 745 static_cast<media::AudioManagerAndroid*>(media::AudioManager::Get())-> |
746 InitializeIfNeeded(); | 746 InitializeIfNeeded(); |
747 #endif // defined(OS_ANDROID) | 747 #endif // defined(OS_ANDROID) |
748 | 748 |
749 CreateMessageFilters(); | 749 CreateMessageFilters(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 power_monitor_broadcaster_.Init(); | 815 power_monitor_broadcaster_.Init(); |
816 | 816 |
817 is_initialized_ = true; | 817 is_initialized_ = true; |
818 init_time_ = base::TimeTicks::Now(); | 818 init_time_ = base::TimeTicks::Now(); |
819 return true; | 819 return true; |
820 } | 820 } |
821 | 821 |
822 std::unique_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( | 822 std::unique_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( |
823 const std::string& channel_id) { | 823 const std::string& channel_id) { |
824 scoped_refptr<base::SingleThreadTaskRunner> runner = | 824 scoped_refptr<base::SingleThreadTaskRunner> runner = |
825 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 825 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); |
826 mojo_channel_token_ = mojo::edk::GenerateRandomToken(); | 826 mojo_channel_token_ = mojo::edk::GenerateRandomToken(); |
827 mojo::ScopedMessagePipeHandle handle = | 827 mojo::ScopedMessagePipeHandle handle = |
828 mojo::edk::CreateParentMessagePipe(mojo_channel_token_, child_token_); | 828 mojo::edk::CreateParentMessagePipe(mojo_channel_token_, child_token_); |
829 | 829 |
830 // Do NOT expand ifdef or run time condition checks here! Synchronous | 830 // Do NOT expand ifdef or run time condition checks here! Synchronous |
831 // IPCs from browser process are banned. It is only narrowly allowed | 831 // IPCs from browser process are banned. It is only narrowly allowed |
832 // for Android WebView to maintain backward compatibility. | 832 // for Android WebView to maintain backward compatibility. |
833 // See crbug.com/526842 for details. | 833 // See crbug.com/526842 for details. |
834 #if defined(OS_ANDROID) | 834 #if defined(OS_ANDROID) |
835 if (GetContentClient()->UsingSynchronousCompositing()) { | 835 if (GetContentClient()->UsingSynchronousCompositing()) { |
836 return IPC::SyncChannel::Create( | 836 return IPC::SyncChannel::Create( |
837 IPC::ChannelMojo::CreateServerFactory(std::move(handle)), this, | 837 IPC::ChannelMojo::CreateServerFactory(std::move(handle)), this, |
838 runner.get(), true, &never_signaled_); | 838 runner.get(), true, &never_signaled_); |
839 } | 839 } |
840 #endif // OS_ANDROID | 840 #endif // OS_ANDROID |
841 | 841 |
842 std::unique_ptr<IPC::ChannelProxy> channel( | 842 std::unique_ptr<IPC::ChannelProxy> channel( |
843 new IPC::ChannelProxy(this, runner.get())); | 843 new IPC::ChannelProxy(this, runner.get())); |
844 #if USE_ATTACHMENT_BROKER | 844 #if USE_ATTACHMENT_BROKER |
845 IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel( | 845 IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel( |
846 channel.get(), content::BrowserThread::GetMessageLoopProxyForThread( | 846 channel.get(), content::BrowserThread::GetTaskRunnerForThread( |
847 content::BrowserThread::IO)); | 847 content::BrowserThread::IO)); |
848 #endif | 848 #endif |
849 channel->Init(IPC::ChannelMojo::CreateServerFactory(std::move(handle)), true); | 849 channel->Init(IPC::ChannelMojo::CreateServerFactory(std::move(handle)), true); |
850 return channel; | 850 return channel; |
851 } | 851 } |
852 | 852 |
853 void RenderProcessHostImpl::CreateMessageFilters() { | 853 void RenderProcessHostImpl::CreateMessageFilters() { |
854 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 854 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
855 AddFilter(new ResourceSchedulerFilter(GetID())); | 855 AddFilter(new ResourceSchedulerFilter(GetID())); |
856 MediaInternals* media_internals = MediaInternals::GetInstance(); | 856 MediaInternals* media_internals = MediaInternals::GetInstance(); |
857 media::AudioManager* audio_manager = | 857 media::AudioManager* audio_manager = |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 base::Bind(&RenderProcessHostImpl::CreateStoragePartitionService, | 1069 base::Bind(&RenderProcessHostImpl::CreateStoragePartitionService, |
1070 base::Unretained(this))); | 1070 base::Unretained(this))); |
1071 | 1071 |
1072 GetInterfaceRegistry()->AddInterface( | 1072 GetInterfaceRegistry()->AddInterface( |
1073 base::Bind(&webmessaging::BroadcastChannelProvider::Connect, | 1073 base::Bind(&webmessaging::BroadcastChannelProvider::Connect, |
1074 base::Unretained( | 1074 base::Unretained( |
1075 storage_partition_impl_->GetBroadcastChannelProvider()))); | 1075 storage_partition_impl_->GetBroadcastChannelProvider()))); |
1076 | 1076 |
1077 GetInterfaceRegistry()->AddInterface( | 1077 GetInterfaceRegistry()->AddInterface( |
1078 base::Bind(&MimeRegistryImpl::Create), | 1078 base::Bind(&MimeRegistryImpl::Create), |
1079 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 1079 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); |
1080 | 1080 |
1081 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = | 1081 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = |
1082 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 1082 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); |
1083 GetInterfaceRegistry()->AddInterface(base::Bind(&DeviceLightHost::Create), | 1083 GetInterfaceRegistry()->AddInterface(base::Bind(&DeviceLightHost::Create), |
1084 io_task_runner); | 1084 io_task_runner); |
1085 GetInterfaceRegistry()->AddInterface(base::Bind(&DeviceMotionHost::Create), | 1085 GetInterfaceRegistry()->AddInterface(base::Bind(&DeviceMotionHost::Create), |
1086 io_task_runner); | 1086 io_task_runner); |
1087 GetInterfaceRegistry()->AddInterface( | 1087 GetInterfaceRegistry()->AddInterface( |
1088 base::Bind(&DeviceOrientationHost::Create), io_task_runner); | 1088 base::Bind(&DeviceOrientationHost::Create), io_task_runner); |
1089 GetInterfaceRegistry()->AddInterface( | 1089 GetInterfaceRegistry()->AddInterface( |
1090 base::Bind(&DeviceOrientationAbsoluteHost::Create), io_task_runner); | 1090 base::Bind(&DeviceOrientationAbsoluteHost::Create), io_task_runner); |
1091 | 1091 |
1092 #if defined(OS_ANDROID) | 1092 #if defined(OS_ANDROID) |
(...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2767 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 2767 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
2768 | 2768 |
2769 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 2769 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
2770 // enough information here so that we can determine what the bad message was. | 2770 // enough information here so that we can determine what the bad message was. |
2771 base::debug::Alias(&error); | 2771 base::debug::Alias(&error); |
2772 bad_message::ReceivedBadMessage(process.get(), | 2772 bad_message::ReceivedBadMessage(process.get(), |
2773 bad_message::RPH_MOJO_PROCESS_ERROR); | 2773 bad_message::RPH_MOJO_PROCESS_ERROR); |
2774 } | 2774 } |
2775 | 2775 |
2776 } // namespace content | 2776 } // namespace content |
OLD | NEW |