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