| 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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 // static | 741 // static |
| 742 void RenderProcessHostImpl::ShutDownInProcessRenderer() { | 742 void RenderProcessHostImpl::ShutDownInProcessRenderer() { |
| 743 DCHECK(g_run_renderer_in_process_); | 743 DCHECK(g_run_renderer_in_process_); |
| 744 | 744 |
| 745 switch (g_all_hosts.Pointer()->size()) { | 745 switch (g_all_hosts.Pointer()->size()) { |
| 746 case 0: | 746 case 0: |
| 747 return; | 747 return; |
| 748 case 1: { | 748 case 1: { |
| 749 RenderProcessHostImpl* host = static_cast<RenderProcessHostImpl*>( | 749 RenderProcessHostImpl* host = static_cast<RenderProcessHostImpl*>( |
| 750 AllHostsIterator().GetCurrentValue()); | 750 AllHostsIterator().GetCurrentValue()); |
| 751 FOR_EACH_OBSERVER(RenderProcessHostObserver, host->observers_, | 751 for (auto& observer : host->observers_) |
| 752 RenderProcessHostDestroyed(host)); | 752 observer.RenderProcessHostDestroyed(host); |
| 753 #ifndef NDEBUG | 753 #ifndef NDEBUG |
| 754 host->is_self_deleted_ = true; | 754 host->is_self_deleted_ = true; |
| 755 #endif | 755 #endif |
| 756 delete host; | 756 delete host; |
| 757 return; | 757 return; |
| 758 } | 758 } |
| 759 default: | 759 default: |
| 760 NOTREACHED() << "There should be only one RenderProcessHost when running " | 760 NOTREACHED() << "There should be only one RenderProcessHost when running " |
| 761 << "in-process."; | 761 << "in-process."; |
| 762 } | 762 } |
| (...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2008 } | 2008 } |
| 2009 return listener->OnMessageReceived(msg); | 2009 return listener->OnMessageReceived(msg); |
| 2010 } | 2010 } |
| 2011 | 2011 |
| 2012 void RenderProcessHostImpl::OnChannelConnected(int32_t peer_pid) { | 2012 void RenderProcessHostImpl::OnChannelConnected(int32_t peer_pid) { |
| 2013 channel_connected_ = true; | 2013 channel_connected_ = true; |
| 2014 if (IsReady()) { | 2014 if (IsReady()) { |
| 2015 DCHECK(!sent_render_process_ready_); | 2015 DCHECK(!sent_render_process_ready_); |
| 2016 sent_render_process_ready_ = true; | 2016 sent_render_process_ready_ = true; |
| 2017 // Send RenderProcessReady only if we already received the process handle. | 2017 // Send RenderProcessReady only if we already received the process handle. |
| 2018 FOR_EACH_OBSERVER(RenderProcessHostObserver, | 2018 for (auto& observer : observers_) |
| 2019 observers_, | 2019 observer.RenderProcessReady(this); |
| 2020 RenderProcessReady(this)); | |
| 2021 } | 2020 } |
| 2022 | 2021 |
| 2023 #if defined(IPC_MESSAGE_LOG_ENABLED) | 2022 #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 2024 Send(new ChildProcessMsg_SetIPCLoggingEnabled( | 2023 Send(new ChildProcessMsg_SetIPCLoggingEnabled( |
| 2025 IPC::Logging::GetInstance()->Enabled())); | 2024 IPC::Logging::GetInstance()->Enabled())); |
| 2026 #endif | 2025 #endif |
| 2027 | 2026 |
| 2028 tracked_objects::ThreadData::Status status = | 2027 tracked_objects::ThreadData::Status status = |
| 2029 tracked_objects::ThreadData::status(); | 2028 tracked_objects::ThreadData::status(); |
| 2030 Send(new ChildProcessMsg_SetProfilerStatus(status)); | 2029 Send(new ChildProcessMsg_SetProfilerStatus(status)); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2129 // control flow. | 2128 // control flow. |
| 2130 DCHECK(!deleting_soon_); | 2129 DCHECK(!deleting_soon_); |
| 2131 | 2130 |
| 2132 DCHECK_EQ(0, pending_views_); | 2131 DCHECK_EQ(0, pending_views_); |
| 2133 | 2132 |
| 2134 // If the process associated with this RenderProcessHost is still alive, | 2133 // If the process associated with this RenderProcessHost is still alive, |
| 2135 // notify all observers that the process has exited cleanly, even though it | 2134 // notify all observers that the process has exited cleanly, even though it |
| 2136 // will be destroyed a bit later. Observers shouldn't rely on this process | 2135 // will be destroyed a bit later. Observers shouldn't rely on this process |
| 2137 // anymore. | 2136 // anymore. |
| 2138 if (HasConnection()) { | 2137 if (HasConnection()) { |
| 2139 FOR_EACH_OBSERVER( | 2138 for (auto& observer : observers_) { |
| 2140 RenderProcessHostObserver, observers_, | 2139 observer.RenderProcessExited( |
| 2141 RenderProcessExited(this, base::TERMINATION_STATUS_NORMAL_TERMINATION, | 2140 this, base::TERMINATION_STATUS_NORMAL_TERMINATION, 0); |
| 2142 0)); | 2141 } |
| 2143 } | 2142 } |
| 2144 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, | 2143 for (auto& observer : observers_) |
| 2145 RenderProcessHostDestroyed(this)); | 2144 observer.RenderProcessHostDestroyed(this); |
| 2146 NotificationService::current()->Notify( | 2145 NotificationService::current()->Notify( |
| 2147 NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 2146 NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 2148 Source<RenderProcessHost>(this), NotificationService::NoDetails()); | 2147 Source<RenderProcessHost>(this), NotificationService::NoDetails()); |
| 2149 | 2148 |
| 2150 if (connection_filter_id_ != | 2149 if (connection_filter_id_ != |
| 2151 ServiceManagerConnection::kInvalidConnectionFilterId) { | 2150 ServiceManagerConnection::kInvalidConnectionFilterId) { |
| 2152 ServiceManagerConnection* service_manager_connection = | 2151 ServiceManagerConnection* service_manager_connection = |
| 2153 BrowserContext::GetServiceManagerConnectionFor(browser_context_); | 2152 BrowserContext::GetServiceManagerConnectionFor(browser_context_); |
| 2154 connection_filter_controller_->DisableFilter(); | 2153 connection_filter_controller_->DisableFilter(); |
| 2155 service_manager_connection->RemoveConnectionFilter(connection_filter_id_); | 2154 service_manager_connection->RemoveConnectionFilter(connection_filter_id_); |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2672 remote_route_provider_.reset(); | 2671 remote_route_provider_.reset(); |
| 2673 renderer_interface_.reset(); | 2672 renderer_interface_.reset(); |
| 2674 | 2673 |
| 2675 UpdateProcessPriority(); | 2674 UpdateProcessPriority(); |
| 2676 DCHECK(!is_process_backgrounded_); | 2675 DCHECK(!is_process_backgrounded_); |
| 2677 | 2676 |
| 2678 within_process_died_observer_ = true; | 2677 within_process_died_observer_ = true; |
| 2679 NotificationService::current()->Notify( | 2678 NotificationService::current()->Notify( |
| 2680 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), | 2679 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), |
| 2681 Details<RendererClosedDetails>(&details)); | 2680 Details<RendererClosedDetails>(&details)); |
| 2682 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, | 2681 for (auto& observer : observers_) |
| 2683 RenderProcessExited(this, status, exit_code)); | 2682 observer.RenderProcessExited(this, status, exit_code); |
| 2684 within_process_died_observer_ = false; | 2683 within_process_died_observer_ = false; |
| 2685 | 2684 |
| 2686 message_port_message_filter_ = NULL; | 2685 message_port_message_filter_ = NULL; |
| 2687 | 2686 |
| 2688 RemoveUserData(kSessionStorageHolderKey); | 2687 RemoveUserData(kSessionStorageHolderKey); |
| 2689 | 2688 |
| 2690 IDMap<IPC::Listener>::iterator iter(&listeners_); | 2689 IDMap<IPC::Listener>::iterator iter(&listeners_); |
| 2691 while (!iter.IsAtEnd()) { | 2690 while (!iter.IsAtEnd()) { |
| 2692 iter.GetCurrentValue()->OnMessageReceived(FrameHostMsg_RenderProcessGone( | 2691 iter.GetCurrentValue()->OnMessageReceived(FrameHostMsg_RenderProcessGone( |
| 2693 iter.GetCurrentKey(), static_cast<int>(status), exit_code)); | 2692 iter.GetCurrentKey(), static_cast<int>(status), exit_code)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2738 | 2737 |
| 2739 void RenderProcessHostImpl::OnShutdownRequest() { | 2738 void RenderProcessHostImpl::OnShutdownRequest() { |
| 2740 // Don't shut down if there are active RenderViews, or if there are pending | 2739 // Don't shut down if there are active RenderViews, or if there are pending |
| 2741 // RenderViews being swapped back in. | 2740 // RenderViews being swapped back in. |
| 2742 // In single process mode, we never shutdown the renderer. | 2741 // In single process mode, we never shutdown the renderer. |
| 2743 if (pending_views_ || run_renderer_in_process() || GetActiveViewCount() > 0) | 2742 if (pending_views_ || run_renderer_in_process() || GetActiveViewCount() > 0) |
| 2744 return; | 2743 return; |
| 2745 | 2744 |
| 2746 // Notify any contents that might have swapped out renderers from this | 2745 // Notify any contents that might have swapped out renderers from this |
| 2747 // process. They should not attempt to swap them back in. | 2746 // process. They should not attempt to swap them back in. |
| 2748 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, | 2747 for (auto& observer : observers_) |
| 2749 RenderProcessWillExit(this)); | 2748 observer.RenderProcessWillExit(this); |
| 2750 | 2749 |
| 2751 Send(new ChildProcessMsg_Shutdown()); | 2750 Send(new ChildProcessMsg_Shutdown()); |
| 2752 } | 2751 } |
| 2753 | 2752 |
| 2754 void RenderProcessHostImpl::SuddenTerminationChanged(bool enabled) { | 2753 void RenderProcessHostImpl::SuddenTerminationChanged(bool enabled) { |
| 2755 SetSuddenTerminationAllowed(enabled); | 2754 SetSuddenTerminationAllowed(enabled); |
| 2756 } | 2755 } |
| 2757 | 2756 |
| 2758 void RenderProcessHostImpl::UpdateProcessPriority() { | 2757 void RenderProcessHostImpl::UpdateProcessPriority() { |
| 2759 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) { | 2758 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2854 Source<RenderProcessHost>(this), | 2853 Source<RenderProcessHost>(this), |
| 2855 NotificationService::NoDetails()); | 2854 NotificationService::NoDetails()); |
| 2856 | 2855 |
| 2857 if (child_process_launcher_) | 2856 if (child_process_launcher_) |
| 2858 channel_->Flush(); | 2857 channel_->Flush(); |
| 2859 | 2858 |
| 2860 if (IsReady()) { | 2859 if (IsReady()) { |
| 2861 DCHECK(!sent_render_process_ready_); | 2860 DCHECK(!sent_render_process_ready_); |
| 2862 sent_render_process_ready_ = true; | 2861 sent_render_process_ready_ = true; |
| 2863 // Send RenderProcessReady only if the channel is already connected. | 2862 // Send RenderProcessReady only if the channel is already connected. |
| 2864 FOR_EACH_OBSERVER(RenderProcessHostObserver, | 2863 for (auto& observer : observers_) |
| 2865 observers_, | 2864 observer.RenderProcessReady(this); |
| 2866 RenderProcessReady(this)); | |
| 2867 } | 2865 } |
| 2868 | 2866 |
| 2869 #if defined(ENABLE_WEBRTC) | 2867 #if defined(ENABLE_WEBRTC) |
| 2870 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { | 2868 if (WebRTCInternals::GetInstance()->IsAudioDebugRecordingsEnabled()) { |
| 2871 EnableAudioDebugRecordings( | 2869 EnableAudioDebugRecordings( |
| 2872 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()); | 2870 WebRTCInternals::GetInstance()->GetAudioDebugRecordingsFilePath()); |
| 2873 } | 2871 } |
| 2874 #endif | 2872 #endif |
| 2875 } | 2873 } |
| 2876 | 2874 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3002 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3000 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 3003 | 3001 |
| 3004 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 3002 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
| 3005 // enough information here so that we can determine what the bad message was. | 3003 // enough information here so that we can determine what the bad message was. |
| 3006 base::debug::Alias(&error); | 3004 base::debug::Alias(&error); |
| 3007 bad_message::ReceivedBadMessage(render_process_id, | 3005 bad_message::ReceivedBadMessage(render_process_id, |
| 3008 bad_message::RPH_MOJO_PROCESS_ERROR); | 3006 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 3009 } | 3007 } |
| 3010 | 3008 |
| 3011 } // namespace content | 3009 } // namespace content |
| OLD | NEW |