| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 #include "content/browser/renderer_host/media/video_capture_host.h" | 102 #include "content/browser/renderer_host/media/video_capture_host.h" |
| 103 #include "content/browser/renderer_host/offscreen_canvas_surface_impl.h" | 103 #include "content/browser/renderer_host/offscreen_canvas_surface_impl.h" |
| 104 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" | 104 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" |
| 105 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h" | 105 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h" |
| 106 #include "content/browser/renderer_host/render_message_filter.h" | 106 #include "content/browser/renderer_host/render_message_filter.h" |
| 107 #include "content/browser/renderer_host/render_view_host_delegate.h" | 107 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 108 #include "content/browser/renderer_host/render_view_host_impl.h" | 108 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 109 #include "content/browser/renderer_host/render_widget_helper.h" | 109 #include "content/browser/renderer_host/render_widget_helper.h" |
| 110 #include "content/browser/renderer_host/render_widget_host_impl.h" | 110 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 111 #include "content/browser/renderer_host/text_input_client_message_filter.h" | 111 #include "content/browser/renderer_host/text_input_client_message_filter.h" |
| 112 #include "content/browser/renderer_host/websocket_dispatcher_host.h" | |
| 113 #include "content/browser/resolve_proxy_msg_helper.h" | 112 #include "content/browser/resolve_proxy_msg_helper.h" |
| 114 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 113 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 115 #include "content/browser/service_worker/service_worker_dispatcher_host.h" | 114 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
| 116 #include "content/browser/shared_worker/shared_worker_message_filter.h" | 115 #include "content/browser/shared_worker/shared_worker_message_filter.h" |
| 117 #include "content/browser/shared_worker/worker_storage_partition.h" | 116 #include "content/browser/shared_worker/worker_storage_partition.h" |
| 118 #include "content/browser/speech/speech_recognition_dispatcher_host.h" | 117 #include "content/browser/speech/speech_recognition_dispatcher_host.h" |
| 119 #include "content/browser/storage_partition_impl.h" | 118 #include "content/browser/storage_partition_impl.h" |
| 120 #include "content/browser/streams/stream_context.h" | 119 #include "content/browser/streams/stream_context.h" |
| 121 #include "content/browser/tracing/trace_message_filter.h" | 120 #include "content/browser/tracing/trace_message_filter.h" |
| 121 #include "content/browser/websockets/websocket_manager.h" |
| 122 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 122 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
| 123 #include "content/common/child_process_host_impl.h" | 123 #include "content/common/child_process_host_impl.h" |
| 124 #include "content/common/child_process_messages.h" | 124 #include "content/common/child_process_messages.h" |
| 125 #include "content/common/content_switches_internal.h" | 125 #include "content/common/content_switches_internal.h" |
| 126 #include "content/common/frame_messages.h" | 126 #include "content/common/frame_messages.h" |
| 127 #include "content/common/gpu_host_messages.h" | 127 #include "content/common/gpu_host_messages.h" |
| 128 #include "content/common/in_process_child_thread_params.h" | 128 #include "content/common/in_process_child_thread_params.h" |
| 129 #include "content/common/mojo/mojo_shell_connection_impl.h" | 129 #include "content/common/mojo/mojo_shell_connection_impl.h" |
| 130 #include "content/common/render_process_messages.h" | 130 #include "content/common/render_process_messages.h" |
| 131 #include "content/common/resource_messages.h" | 131 #include "content/common/resource_messages.h" |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 queued_messages_.pop(); | 678 queued_messages_.pop(); |
| 679 } | 679 } |
| 680 | 680 |
| 681 UnregisterHost(GetID()); | 681 UnregisterHost(GetID()); |
| 682 | 682 |
| 683 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 683 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 684 switches::kDisableGpuShaderDiskCache)) { | 684 switches::kDisableGpuShaderDiskCache)) { |
| 685 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 685 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 686 base::Bind(&RemoveShaderInfo, GetID())); | 686 base::Bind(&RemoveShaderInfo, GetID())); |
| 687 } | 687 } |
| 688 |
| 689 if (websocket_manager_) |
| 690 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, websocket_manager_); |
| 688 } | 691 } |
| 689 | 692 |
| 690 void RenderProcessHostImpl::EnableSendQueue() { | 693 void RenderProcessHostImpl::EnableSendQueue() { |
| 691 is_initialized_ = false; | 694 is_initialized_ = false; |
| 692 } | 695 } |
| 693 | 696 |
| 694 bool RenderProcessHostImpl::Init() { | 697 bool RenderProcessHostImpl::Init() { |
| 695 // calling Init() more than once does nothing, this makes it more convenient | 698 // calling Init() more than once does nothing, this makes it more convenient |
| 696 // for the view host which may not be sure in some cases | 699 // for the view host which may not be sure in some cases |
| 697 if (channel_) | 700 if (channel_) |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 // should eventually be if (!ShouldUseDirectWrite()) guarded. | 950 // should eventually be if (!ShouldUseDirectWrite()) guarded. |
| 948 channel_->AddFilter(new FontCacheDispatcher()); | 951 channel_->AddFilter(new FontCacheDispatcher()); |
| 949 #elif defined(OS_ANDROID) | 952 #elif defined(OS_ANDROID) |
| 950 browser_demuxer_android_ = new BrowserDemuxerAndroid(); | 953 browser_demuxer_android_ = new BrowserDemuxerAndroid(); |
| 951 AddFilter(browser_demuxer_android_.get()); | 954 AddFilter(browser_demuxer_android_.get()); |
| 952 #endif | 955 #endif |
| 953 #if defined(ENABLE_BROWSER_CDMS) | 956 #if defined(ENABLE_BROWSER_CDMS) |
| 954 AddFilter(new BrowserCdmManager(GetID(), NULL)); | 957 AddFilter(new BrowserCdmManager(GetID(), NULL)); |
| 955 #endif | 958 #endif |
| 956 | 959 |
| 957 WebSocketDispatcherHost::GetRequestContextCallback | |
| 958 websocket_request_context_callback( | |
| 959 base::Bind(&GetRequestContext, request_context, media_request_context, | |
| 960 RESOURCE_TYPE_SUB_RESOURCE)); | |
| 961 | |
| 962 AddFilter(new WebSocketDispatcherHost( | |
| 963 GetID(), websocket_request_context_callback, blob_storage_context.get(), | |
| 964 storage_partition_impl_)); | |
| 965 | |
| 966 message_port_message_filter_ = new MessagePortMessageFilter( | 960 message_port_message_filter_ = new MessagePortMessageFilter( |
| 967 base::Bind(&RenderWidgetHelper::GetNextRoutingID, | 961 base::Bind(&RenderWidgetHelper::GetNextRoutingID, |
| 968 base::Unretained(widget_helper_.get()))); | 962 base::Unretained(widget_helper_.get()))); |
| 969 AddFilter(message_port_message_filter_.get()); | 963 AddFilter(message_port_message_filter_.get()); |
| 970 | 964 |
| 971 scoped_refptr<CacheStorageDispatcherHost> cache_storage_filter = | 965 scoped_refptr<CacheStorageDispatcherHost> cache_storage_filter = |
| 972 new CacheStorageDispatcherHost(); | 966 new CacheStorageDispatcherHost(); |
| 973 cache_storage_filter->Init(storage_partition_impl_->GetCacheStorageContext()); | 967 cache_storage_filter->Init(storage_partition_impl_->GetCacheStorageContext()); |
| 974 AddFilter(cache_storage_filter.get()); | 968 AddFilter(cache_storage_filter.get()); |
| 975 | 969 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 1058 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 1065 GetInterfaceRegistry()->AddInterface(base::Bind(&DeviceLightHost::Create), | 1059 GetInterfaceRegistry()->AddInterface(base::Bind(&DeviceLightHost::Create), |
| 1066 io_task_runner); | 1060 io_task_runner); |
| 1067 GetInterfaceRegistry()->AddInterface(base::Bind(&DeviceMotionHost::Create), | 1061 GetInterfaceRegistry()->AddInterface(base::Bind(&DeviceMotionHost::Create), |
| 1068 io_task_runner); | 1062 io_task_runner); |
| 1069 GetInterfaceRegistry()->AddInterface( | 1063 GetInterfaceRegistry()->AddInterface( |
| 1070 base::Bind(&DeviceOrientationHost::Create), io_task_runner); | 1064 base::Bind(&DeviceOrientationHost::Create), io_task_runner); |
| 1071 GetInterfaceRegistry()->AddInterface( | 1065 GetInterfaceRegistry()->AddInterface( |
| 1072 base::Bind(&DeviceOrientationAbsoluteHost::Create), io_task_runner); | 1066 base::Bind(&DeviceOrientationAbsoluteHost::Create), io_task_runner); |
| 1073 | 1067 |
| 1068 // This is the fallback registration used when the renderer needs a WebSocket |
| 1069 // that we cannot associate with a RenderFrame (e.g., Shared Workers). |
| 1070 GetInterfaceRegistry()->AddInterface( |
| 1071 base::Bind( |
| 1072 &WebSocketManager::CreateWebSocket, |
| 1073 base::Unretained(GetWebSocketManager()), |
| 1074 MSG_ROUTING_NONE), |
| 1075 io_task_runner); |
| 1076 |
| 1074 #if defined(OS_ANDROID) | 1077 #if defined(OS_ANDROID) |
| 1075 ServiceRegistrarAndroid::RegisterProcessHostServices( | 1078 ServiceRegistrarAndroid::RegisterProcessHostServices( |
| 1076 mojo_child_connection_->service_registry_android()); | 1079 mojo_child_connection_->service_registry_android()); |
| 1077 #endif | 1080 #endif |
| 1078 | 1081 |
| 1079 GetContentClient()->browser()->ExposeInterfacesToRenderer( | 1082 GetContentClient()->browser()->ExposeInterfacesToRenderer( |
| 1080 GetInterfaceRegistry(), this); | 1083 GetInterfaceRegistry(), this); |
| 1081 } | 1084 } |
| 1082 | 1085 |
| 1083 void RenderProcessHostImpl::CreateStoragePartitionService( | 1086 void RenderProcessHostImpl::CreateStoragePartitionService( |
| (...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2629 // sent a RenderProcessHostDestroyed notification, and we must observe our | 2632 // sent a RenderProcessHostDestroyed notification, and we must observe our |
| 2630 // contract that says that will be the last call. | 2633 // contract that says that will be the last call. |
| 2631 if (deleting_soon_) | 2634 if (deleting_soon_) |
| 2632 return; | 2635 return; |
| 2633 | 2636 |
| 2634 RendererClosedDetails details{base::TERMINATION_STATUS_LAUNCH_FAILED, | 2637 RendererClosedDetails details{base::TERMINATION_STATUS_LAUNCH_FAILED, |
| 2635 error_code}; | 2638 error_code}; |
| 2636 ProcessDied(true, &details); | 2639 ProcessDied(true, &details); |
| 2637 } | 2640 } |
| 2638 | 2641 |
| 2642 WebSocketManager* RenderProcessHostImpl::GetWebSocketManager() { |
| 2643 if (!websocket_manager_) |
| 2644 websocket_manager_ = new WebSocketManager(GetID(), storage_partition_impl_); |
| 2645 return websocket_manager_; |
| 2646 } |
| 2647 |
| 2639 scoped_refptr<AudioRendererHost> RenderProcessHostImpl::audio_renderer_host() | 2648 scoped_refptr<AudioRendererHost> RenderProcessHostImpl::audio_renderer_host() |
| 2640 const { | 2649 const { |
| 2641 return audio_renderer_host_; | 2650 return audio_renderer_host_; |
| 2642 } | 2651 } |
| 2643 | 2652 |
| 2644 void RenderProcessHostImpl::OnUserMetricsRecordAction( | 2653 void RenderProcessHostImpl::OnUserMetricsRecordAction( |
| 2645 const std::string& action) { | 2654 const std::string& action) { |
| 2646 RecordComputedAction(action); | 2655 RecordComputedAction(action); |
| 2647 } | 2656 } |
| 2648 | 2657 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2830 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 2839 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 2831 | 2840 |
| 2832 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 2841 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
| 2833 // enough information here so that we can determine what the bad message was. | 2842 // enough information here so that we can determine what the bad message was. |
| 2834 base::debug::Alias(&error); | 2843 base::debug::Alias(&error); |
| 2835 bad_message::ReceivedBadMessage(process.get(), | 2844 bad_message::ReceivedBadMessage(process.get(), |
| 2836 bad_message::RPH_MOJO_PROCESS_ERROR); | 2845 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 2837 } | 2846 } |
| 2838 | 2847 |
| 2839 } // namespace content | 2848 } // namespace content |
| OLD | NEW |