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 // 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 #include "content/browser/renderer_host/websocket_dispatcher_host.h" | 98 #include "content/browser/renderer_host/websocket_dispatcher_host.h" |
99 #include "content/browser/resolve_proxy_msg_helper.h" | 99 #include "content/browser/resolve_proxy_msg_helper.h" |
100 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 100 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
101 #include "content/browser/service_worker/service_worker_dispatcher_host.h" | 101 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
102 #include "content/browser/shared_worker/shared_worker_message_filter.h" | 102 #include "content/browser/shared_worker/shared_worker_message_filter.h" |
103 #include "content/browser/shared_worker/worker_storage_partition.h" | 103 #include "content/browser/shared_worker/worker_storage_partition.h" |
104 #include "content/browser/speech/speech_recognition_dispatcher_host.h" | 104 #include "content/browser/speech/speech_recognition_dispatcher_host.h" |
105 #include "content/browser/storage_partition_impl.h" | 105 #include "content/browser/storage_partition_impl.h" |
106 #include "content/browser/streams/stream_context.h" | 106 #include "content/browser/streams/stream_context.h" |
107 #include "content/browser/tracing/trace_message_filter.h" | 107 #include "content/browser/tracing/trace_message_filter.h" |
108 #include "content/browser/vibration/vibration_message_filter.h" | |
109 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 108 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
110 #include "content/common/child_process_host_impl.h" | 109 #include "content/common/child_process_host_impl.h" |
111 #include "content/common/child_process_messages.h" | 110 #include "content/common/child_process_messages.h" |
112 #include "content/common/content_switches_internal.h" | 111 #include "content/common/content_switches_internal.h" |
113 #include "content/common/gpu/gpu_messages.h" | 112 #include "content/common/gpu/gpu_messages.h" |
114 #include "content/common/mojo/mojo_messages.h" | 113 #include "content/common/mojo/mojo_messages.h" |
115 #include "content/common/resource_messages.h" | 114 #include "content/common/resource_messages.h" |
116 #include "content/common/view_messages.h" | 115 #include "content/common/view_messages.h" |
117 #include "content/public/browser/browser_context.h" | 116 #include "content/public/browser/browser_context.h" |
118 #include "content/public/browser/content_browser_client.h" | 117 #include "content/public/browser/content_browser_client.h" |
119 #include "content/public/browser/notification_service.h" | 118 #include "content/public/browser/notification_service.h" |
120 #include "content/public/browser/notification_types.h" | 119 #include "content/public/browser/notification_types.h" |
121 #include "content/public/browser/render_process_host_factory.h" | 120 #include "content/public/browser/render_process_host_factory.h" |
122 #include "content/public/browser/render_process_host_observer.h" | 121 #include "content/public/browser/render_process_host_observer.h" |
123 #include "content/public/browser/render_widget_host.h" | 122 #include "content/public/browser/render_widget_host.h" |
124 #include "content/public/browser/render_widget_host_iterator.h" | 123 #include "content/public/browser/render_widget_host_iterator.h" |
125 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 124 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
126 #include "content/public/browser/resource_context.h" | 125 #include "content/public/browser/resource_context.h" |
127 #include "content/public/browser/user_metrics.h" | 126 #include "content/public/browser/user_metrics.h" |
128 #include "content/public/browser/worker_service.h" | 127 #include "content/public/browser/worker_service.h" |
129 #include "content/public/common/content_constants.h" | 128 #include "content/public/common/content_constants.h" |
130 #include "content/public/common/content_switches.h" | 129 #include "content/public/common/content_switches.h" |
131 #include "content/public/common/process_type.h" | 130 #include "content/public/common/process_type.h" |
132 #include "content/public/common/resource_type.h" | 131 #include "content/public/common/resource_type.h" |
133 #include "content/public/common/result_codes.h" | 132 #include "content/public/common/result_codes.h" |
134 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 133 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
135 #include "content/public/common/url_constants.h" | 134 #include "content/public/common/url_constants.h" |
| 135 #include "device/vibration/vibration_manager_impl.h" |
136 #include "gpu/command_buffer/client/gpu_switches.h" | 136 #include "gpu/command_buffer/client/gpu_switches.h" |
137 #include "gpu/command_buffer/service/gpu_switches.h" | 137 #include "gpu/command_buffer/service/gpu_switches.h" |
138 #include "ipc/ipc_channel.h" | 138 #include "ipc/ipc_channel.h" |
139 #include "ipc/ipc_logging.h" | 139 #include "ipc/ipc_logging.h" |
140 #include "ipc/ipc_switches.h" | 140 #include "ipc/ipc_switches.h" |
141 #include "ipc/mojo/ipc_channel_mojo.h" | 141 #include "ipc/mojo/ipc_channel_mojo.h" |
142 #include "ipc/mojo/ipc_channel_mojo_host.h" | 142 #include "ipc/mojo/ipc_channel_mojo_host.h" |
143 #include "media/base/media_switches.h" | 143 #include "media/base/media_switches.h" |
144 #include "net/url_request/url_request_context_getter.h" | 144 #include "net/url_request/url_request_context_getter.h" |
145 #include "ppapi/shared_impl/ppapi_switches.h" | 145 #include "ppapi/shared_impl/ppapi_switches.h" |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 IPC::Channel::GenerateVerifiedChannelID(std::string()); | 582 IPC::Channel::GenerateVerifiedChannelID(std::string()); |
583 channel_ = CreateChannelProxy(channel_id); | 583 channel_ = CreateChannelProxy(channel_id); |
584 | 584 |
585 // Setup the Mojo channel. | 585 // Setup the Mojo channel. |
586 mojo_application_host_->Init(); | 586 mojo_application_host_->Init(); |
587 | 587 |
588 // Call the embedder first so that their IPC filters have priority. | 588 // Call the embedder first so that their IPC filters have priority. |
589 GetContentClient()->browser()->RenderProcessWillLaunch(this); | 589 GetContentClient()->browser()->RenderProcessWillLaunch(this); |
590 | 590 |
591 CreateMessageFilters(); | 591 CreateMessageFilters(); |
| 592 RegisterMojoServices(); |
592 | 593 |
593 if (run_renderer_in_process()) { | 594 if (run_renderer_in_process()) { |
594 DCHECK(g_renderer_main_thread_factory); | 595 DCHECK(g_renderer_main_thread_factory); |
595 // Crank up a thread and run the initialization there. With the way that | 596 // Crank up a thread and run the initialization there. With the way that |
596 // messages flow between the browser and renderer, this thread is required | 597 // messages flow between the browser and renderer, this thread is required |
597 // to prevent a deadlock in single-process mode. Since the primordial | 598 // to prevent a deadlock in single-process mode. Since the primordial |
598 // thread in the renderer process runs the WebKit code and can sometimes | 599 // thread in the renderer process runs the WebKit code and can sometimes |
599 // make blocking calls to the UI thread (i.e. this thread), they need to run | 600 // make blocking calls to the UI thread (i.e. this thread), they need to run |
600 // on separate threads. | 601 // on separate threads. |
601 in_process_renderer_.reset(g_renderer_main_thread_factory(channel_id)); | 602 in_process_renderer_.reset(g_renderer_main_thread_factory(channel_id)); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 AddFilter(new DeviceLightMessageFilter()); | 880 AddFilter(new DeviceLightMessageFilter()); |
880 AddFilter(new DeviceMotionMessageFilter()); | 881 AddFilter(new DeviceMotionMessageFilter()); |
881 AddFilter(new DeviceOrientationMessageFilter()); | 882 AddFilter(new DeviceOrientationMessageFilter()); |
882 AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); | 883 AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); |
883 AddFilter(new HistogramMessageFilter()); | 884 AddFilter(new HistogramMessageFilter()); |
884 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) | 885 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) |
885 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 886 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
886 switches::kEnableMemoryBenchmarking)) | 887 switches::kEnableMemoryBenchmarking)) |
887 AddFilter(new MemoryBenchmarkMessageFilter()); | 888 AddFilter(new MemoryBenchmarkMessageFilter()); |
888 #endif | 889 #endif |
889 AddFilter(new VibrationMessageFilter()); | |
890 AddFilter(new PushMessagingMessageFilter( | 890 AddFilter(new PushMessagingMessageFilter( |
891 GetID(), storage_partition_impl_->GetServiceWorkerContext())); | 891 GetID(), storage_partition_impl_->GetServiceWorkerContext())); |
892 AddFilter(new BatteryStatusMessageFilter()); | 892 AddFilter(new BatteryStatusMessageFilter()); |
893 #if defined(OS_ANDROID) | 893 #if defined(OS_ANDROID) |
894 AddFilter(new ScreenOrientationMessageFilterAndroid()); | 894 AddFilter(new ScreenOrientationMessageFilterAndroid()); |
895 #endif | 895 #endif |
896 AddFilter(new GeofencingDispatcherHost()); | 896 AddFilter(new GeofencingDispatcherHost()); |
897 } | 897 } |
898 | 898 |
899 int RenderProcessHostImpl::GetNextRoutingID() { | 899 int RenderProcessHostImpl::GetNextRoutingID() { |
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2100 // was after, we can end up executing JavaScript before the initialization | 2100 // was after, we can end up executing JavaScript before the initialization |
2101 // happens. | 2101 // happens. |
2102 NotificationService::current()->Notify( | 2102 NotificationService::current()->Notify( |
2103 NOTIFICATION_RENDERER_PROCESS_CREATED, | 2103 NOTIFICATION_RENDERER_PROCESS_CREATED, |
2104 Source<RenderProcessHost>(this), | 2104 Source<RenderProcessHost>(this), |
2105 NotificationService::NoDetails()); | 2105 NotificationService::NoDetails()); |
2106 | 2106 |
2107 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. | 2107 // Allow Mojo to be setup before the renderer sees any Chrome IPC messages. |
2108 // This way, Mojo can be safely used from the renderer in response to any | 2108 // This way, Mojo can be safely used from the renderer in response to any |
2109 // Chrome IPC message. | 2109 // Chrome IPC message. |
2110 MaybeActivateMojo(); | 2110 // NOTE: Apparently this leads to flaky crashes see crbug.com/415059. |
| 2111 mojo_application_host_->Activate(this, GetHandle()); |
2111 | 2112 |
2112 if (channel_mojo_host_) | 2113 if (channel_mojo_host_) |
2113 channel_mojo_host_->OnClientLaunched(GetHandle()); | 2114 channel_mojo_host_->OnClientLaunched(GetHandle()); |
2114 | 2115 |
2115 while (!queued_messages_.empty()) { | 2116 while (!queued_messages_.empty()) { |
2116 Send(queued_messages_.front()); | 2117 Send(queued_messages_.front()); |
2117 queued_messages_.pop(); | 2118 queued_messages_.pop(); |
2118 } | 2119 } |
2119 | 2120 |
2120 #if defined(ENABLE_WEBRTC) | 2121 #if defined(ENABLE_WEBRTC) |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2249 --worker_ref_count_; | 2250 --worker_ref_count_; |
2250 if (worker_ref_count_ == 0) | 2251 if (worker_ref_count_ == 0) |
2251 Cleanup(); | 2252 Cleanup(); |
2252 } | 2253 } |
2253 | 2254 |
2254 void RenderProcessHostImpl::EnsureMojoActivated() { | 2255 void RenderProcessHostImpl::EnsureMojoActivated() { |
2255 mojo_activation_required_ = true; | 2256 mojo_activation_required_ = true; |
2256 MaybeActivateMojo(); | 2257 MaybeActivateMojo(); |
2257 } | 2258 } |
2258 | 2259 |
| 2260 void RenderProcessHostImpl::RegisterMojoServices() { |
| 2261 mojo_application_host_->service_registry() |
| 2262 ->AddService(base::Bind(&device::VibrationManagerImpl::Create)); |
| 2263 } |
| 2264 |
2259 } // namespace content | 2265 } // namespace content |
OLD | NEW |