| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h" | 89 #include "content/browser/renderer_host/pepper/pepper_renderer_connection.h" |
| 90 #include "content/browser/renderer_host/render_message_filter.h" | 90 #include "content/browser/renderer_host/render_message_filter.h" |
| 91 #include "content/browser/renderer_host/render_view_host_delegate.h" | 91 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 92 #include "content/browser/renderer_host/render_view_host_impl.h" | 92 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 93 #include "content/browser/renderer_host/render_widget_helper.h" | 93 #include "content/browser/renderer_host/render_widget_helper.h" |
| 94 #include "content/browser/renderer_host/render_widget_host_impl.h" | 94 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 95 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" | 95 #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" |
| 96 #include "content/browser/renderer_host/text_input_client_message_filter.h" | 96 #include "content/browser/renderer_host/text_input_client_message_filter.h" |
| 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/screen_orientation/screen_orientation_dispatcher_host.
h" |
| 99 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 100 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 100 #include "content/browser/service_worker/service_worker_dispatcher_host.h" | 101 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
| 101 #include "content/browser/shared_worker/shared_worker_message_filter.h" | 102 #include "content/browser/shared_worker/shared_worker_message_filter.h" |
| 102 #include "content/browser/speech/speech_recognition_dispatcher_host.h" | 103 #include "content/browser/speech/speech_recognition_dispatcher_host.h" |
| 103 #include "content/browser/storage_partition_impl.h" | 104 #include "content/browser/storage_partition_impl.h" |
| 104 #include "content/browser/streams/stream_context.h" | 105 #include "content/browser/streams/stream_context.h" |
| 105 #include "content/browser/tracing/trace_message_filter.h" | 106 #include "content/browser/tracing/trace_message_filter.h" |
| 106 #include "content/browser/vibration/vibration_message_filter.h" | 107 #include "content/browser/vibration/vibration_message_filter.h" |
| 107 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 108 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
| 108 #include "content/browser/worker_host/worker_message_filter.h" | 109 #include "content/browser/worker_host/worker_message_filter.h" |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 453 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
| 453 browser_context_(browser_context), | 454 browser_context_(browser_context), |
| 454 storage_partition_impl_(storage_partition_impl), | 455 storage_partition_impl_(storage_partition_impl), |
| 455 sudden_termination_allowed_(true), | 456 sudden_termination_allowed_(true), |
| 456 ignore_input_events_(false), | 457 ignore_input_events_(false), |
| 457 is_isolated_guest_(is_isolated_guest), | 458 is_isolated_guest_(is_isolated_guest), |
| 458 gpu_observer_registered_(false), | 459 gpu_observer_registered_(false), |
| 459 delayed_cleanup_needed_(false), | 460 delayed_cleanup_needed_(false), |
| 460 within_process_died_observer_(false), | 461 within_process_died_observer_(false), |
| 461 power_monitor_broadcaster_(this), | 462 power_monitor_broadcaster_(this), |
| 463 screen_orientation_dispatcher_host_(NULL), |
| 462 worker_ref_count_(0), | 464 worker_ref_count_(0), |
| 463 weak_factory_(this) { | 465 weak_factory_(this) { |
| 464 widget_helper_ = new RenderWidgetHelper(); | 466 widget_helper_ = new RenderWidgetHelper(); |
| 465 | 467 |
| 466 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); | 468 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); |
| 467 | 469 |
| 468 CHECK(!g_exited_main_message_loop); | 470 CHECK(!g_exited_main_message_loop); |
| 469 RegisterHost(GetID(), this); | 471 RegisterHost(GetID(), this); |
| 470 g_all_hosts.Get().set_check_on_null_data(true); | 472 g_all_hosts.Get().set_check_on_null_data(true); |
| 471 // Initialize |child_process_activity_time_| to a reasonable value. | 473 // Initialize |child_process_activity_time_| to a reasonable value. |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 AddFilter(new DeviceMotionMessageFilter()); | 877 AddFilter(new DeviceMotionMessageFilter()); |
| 876 AddFilter(new DeviceOrientationMessageFilter()); | 878 AddFilter(new DeviceOrientationMessageFilter()); |
| 877 AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); | 879 AddFilter(new ProfilerMessageFilter(PROCESS_TYPE_RENDERER)); |
| 878 AddFilter(new HistogramMessageFilter()); | 880 AddFilter(new HistogramMessageFilter()); |
| 879 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) | 881 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) |
| 880 if (CommandLine::ForCurrentProcess()->HasSwitch( | 882 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 881 switches::kEnableMemoryBenchmarking)) | 883 switches::kEnableMemoryBenchmarking)) |
| 882 AddFilter(new MemoryBenchmarkMessageFilter()); | 884 AddFilter(new MemoryBenchmarkMessageFilter()); |
| 883 #endif | 885 #endif |
| 884 AddFilter(new VibrationMessageFilter()); | 886 AddFilter(new VibrationMessageFilter()); |
| 887 screen_orientation_dispatcher_host_ = new ScreenOrientationDispatcherHost(); |
| 888 AddFilter(screen_orientation_dispatcher_host_); |
| 885 AddFilter(new PushMessagingMessageFilter(GetID())); | 889 AddFilter(new PushMessagingMessageFilter(GetID())); |
| 886 AddFilter(new BatteryStatusMessageFilter()); | 890 AddFilter(new BatteryStatusMessageFilter()); |
| 887 } | 891 } |
| 888 | 892 |
| 889 int RenderProcessHostImpl::GetNextRoutingID() { | 893 int RenderProcessHostImpl::GetNextRoutingID() { |
| 890 return widget_helper_->GetNextRoutingID(); | 894 return widget_helper_->GetNextRoutingID(); |
| 891 } | 895 } |
| 892 | 896 |
| 893 | 897 |
| 894 void RenderProcessHostImpl::ResumeDeferredNavigation( | 898 void RenderProcessHostImpl::ResumeDeferredNavigation( |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1493 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1497 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 1494 deleting_soon_ = true; | 1498 deleting_soon_ = true; |
| 1495 // It's important not to wait for the DeleteTask to delete the channel | 1499 // It's important not to wait for the DeleteTask to delete the channel |
| 1496 // proxy. Kill it off now. That way, in case the profile is going away, the | 1500 // proxy. Kill it off now. That way, in case the profile is going away, the |
| 1497 // rest of the objects attached to this RenderProcessHost start going | 1501 // rest of the objects attached to this RenderProcessHost start going |
| 1498 // away first, since deleting the channel proxy will post a | 1502 // away first, since deleting the channel proxy will post a |
| 1499 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. | 1503 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. |
| 1500 channel_.reset(); | 1504 channel_.reset(); |
| 1501 gpu_message_filter_ = NULL; | 1505 gpu_message_filter_ = NULL; |
| 1502 message_port_message_filter_ = NULL; | 1506 message_port_message_filter_ = NULL; |
| 1507 screen_orientation_dispatcher_host_ = NULL; |
| 1503 RemoveUserData(kSessionStorageHolderKey); | 1508 RemoveUserData(kSessionStorageHolderKey); |
| 1504 | 1509 |
| 1505 // Remove ourself from the list of renderer processes so that we can't be | 1510 // Remove ourself from the list of renderer processes so that we can't be |
| 1506 // reused in between now and when the Delete task runs. | 1511 // reused in between now and when the Delete task runs. |
| 1507 UnregisterHost(GetID()); | 1512 UnregisterHost(GetID()); |
| 1508 } | 1513 } |
| 1509 } | 1514 } |
| 1510 | 1515 |
| 1511 void RenderProcessHostImpl::AddPendingView() { | 1516 void RenderProcessHostImpl::AddPendingView() { |
| 1512 pending_views_++; | 1517 pending_views_++; |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 Details<RendererClosedDetails>(&details)); | 1911 Details<RendererClosedDetails>(&details)); |
| 1907 FOR_EACH_OBSERVER(RenderProcessHostObserver, | 1912 FOR_EACH_OBSERVER(RenderProcessHostObserver, |
| 1908 observers_, | 1913 observers_, |
| 1909 RenderProcessExited(this, GetHandle(), status, exit_code)); | 1914 RenderProcessExited(this, GetHandle(), status, exit_code)); |
| 1910 within_process_died_observer_ = false; | 1915 within_process_died_observer_ = false; |
| 1911 | 1916 |
| 1912 child_process_launcher_.reset(); | 1917 child_process_launcher_.reset(); |
| 1913 channel_.reset(); | 1918 channel_.reset(); |
| 1914 gpu_message_filter_ = NULL; | 1919 gpu_message_filter_ = NULL; |
| 1915 message_port_message_filter_ = NULL; | 1920 message_port_message_filter_ = NULL; |
| 1921 screen_orientation_dispatcher_host_ = NULL; |
| 1916 RemoveUserData(kSessionStorageHolderKey); | 1922 RemoveUserData(kSessionStorageHolderKey); |
| 1917 | 1923 |
| 1918 IDMap<IPC::Listener>::iterator iter(&listeners_); | 1924 IDMap<IPC::Listener>::iterator iter(&listeners_); |
| 1919 while (!iter.IsAtEnd()) { | 1925 while (!iter.IsAtEnd()) { |
| 1920 iter.GetCurrentValue()->OnMessageReceived( | 1926 iter.GetCurrentValue()->OnMessageReceived( |
| 1921 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), | 1927 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), |
| 1922 static_cast<int>(status), | 1928 static_cast<int>(status), |
| 1923 exit_code)); | 1929 exit_code)); |
| 1924 iter.Advance(); | 1930 iter.Advance(); |
| 1925 } | 1931 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1970 } | 1976 } |
| 1971 | 1977 |
| 1972 #if defined(ENABLE_WEBRTC) | 1978 #if defined(ENABLE_WEBRTC) |
| 1973 void RenderProcessHostImpl::WebRtcLogMessage(const std::string& message) { | 1979 void RenderProcessHostImpl::WebRtcLogMessage(const std::string& message) { |
| 1974 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1980 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1975 if (!webrtc_log_message_callback_.is_null()) | 1981 if (!webrtc_log_message_callback_.is_null()) |
| 1976 webrtc_log_message_callback_.Run(message); | 1982 webrtc_log_message_callback_.Run(message); |
| 1977 } | 1983 } |
| 1978 #endif | 1984 #endif |
| 1979 | 1985 |
| 1986 scoped_refptr<ScreenOrientationDispatcherHost> |
| 1987 RenderProcessHostImpl::screen_orientation_dispatcher_host() const { |
| 1988 return make_scoped_refptr(screen_orientation_dispatcher_host_); |
| 1989 } |
| 1990 |
| 1980 void RenderProcessHostImpl::ReleaseOnCloseACK( | 1991 void RenderProcessHostImpl::ReleaseOnCloseACK( |
| 1981 RenderProcessHost* host, | 1992 RenderProcessHost* host, |
| 1982 const SessionStorageNamespaceMap& sessions, | 1993 const SessionStorageNamespaceMap& sessions, |
| 1983 int view_route_id) { | 1994 int view_route_id) { |
| 1984 DCHECK(host); | 1995 DCHECK(host); |
| 1985 if (sessions.empty()) | 1996 if (sessions.empty()) |
| 1986 return; | 1997 return; |
| 1987 SessionStorageHolder* holder = static_cast<SessionStorageHolder*> | 1998 SessionStorageHolder* holder = static_cast<SessionStorageHolder*> |
| 1988 (host->GetUserData(kSessionStorageHolderKey)); | 1999 (host->GetUserData(kSessionStorageHolderKey)); |
| 1989 if (!holder) { | 2000 if (!holder) { |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2289 void RenderProcessHostImpl::GpuMemoryBufferAllocated( | 2300 void RenderProcessHostImpl::GpuMemoryBufferAllocated( |
| 2290 IPC::Message* reply, | 2301 IPC::Message* reply, |
| 2291 const gfx::GpuMemoryBufferHandle& handle) { | 2302 const gfx::GpuMemoryBufferHandle& handle) { |
| 2292 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2303 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2293 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, | 2304 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, |
| 2294 handle); | 2305 handle); |
| 2295 Send(reply); | 2306 Send(reply); |
| 2296 } | 2307 } |
| 2297 | 2308 |
| 2298 } // namespace content | 2309 } // namespace content |
| OLD | NEW |