Chromium Code Reviews| Index: content/browser/renderer_host/render_view_host_impl.cc |
| diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc |
| index 6b78d742666d65b1250cd7dc0bf49d84688efca6..ed5cc127b505814522cb614fb8d6a5090aa35340 100644 |
| --- a/content/browser/renderer_host/render_view_host_impl.cc |
| +++ b/content/browser/renderer_host/render_view_host_impl.cc |
| @@ -34,7 +34,6 @@ |
| #include "content/browser/host_zoom_map_impl.h" |
| #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| #include "content/browser/renderer_host/dip_util.h" |
| -#include "content/browser/renderer_host/input/timeout_monitor.h" |
| #include "content/browser/renderer_host/media/audio_renderer_host.h" |
| #include "content/browser/renderer_host/render_process_host_impl.h" |
| #include "content/browser/renderer_host/render_view_host_delegate.h" |
| @@ -136,14 +135,6 @@ const int RenderViewHostImpl::kUnloadTimeoutMS = 1000; |
| // RenderViewHost, public: |
| // static |
| -bool RenderViewHostImpl::IsRVHStateActive(RenderViewHostImplState rvh_state) { |
| - if (rvh_state == STATE_DEFAULT || |
| - rvh_state == STATE_WAITING_FOR_CLOSE) |
| - return true; |
| - return false; |
| -} |
| - |
| -// static |
| RenderViewHost* RenderViewHost::FromID(int render_process_id, |
| int render_view_id) { |
| return RenderViewHostImpl::FromID(render_process_id, render_view_id); |
| @@ -186,11 +177,12 @@ RenderViewHostImpl::RenderViewHostImpl( |
| waiting_for_drag_context_response_(false), |
| enabled_bindings_(0), |
| page_id_(-1), |
| + is_active_(!swapped_out), |
| + is_swapped_out_(swapped_out), |
| main_frame_routing_id_(main_frame_routing_id), |
| run_modal_reply_msg_(NULL), |
| run_modal_opener_id_(MSG_ROUTING_NONE), |
| - is_waiting_for_beforeunload_ack_(false), |
| - unload_ack_is_for_cross_site_transition_(false), |
| + is_waiting_for_close_ack_(false), |
| sudden_termination_allowed_(false), |
| render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| virtual_keyboard_requested_(false), |
| @@ -202,13 +194,6 @@ RenderViewHostImpl::RenderViewHostImpl( |
| GetProcess()->EnableSendQueue(); |
| - if (swapped_out) { |
| - rvh_state_ = STATE_SWAPPED_OUT; |
| - } else { |
| - rvh_state_ = STATE_DEFAULT; |
| - instance_->increment_active_view_count(); |
| - } |
| - |
| if (ResourceDispatcherHostImpl::Get()) { |
| BrowserThread::PostTask( |
| BrowserThread::IO, FROM_HERE, |
| @@ -220,9 +205,6 @@ RenderViewHostImpl::RenderViewHostImpl( |
| #if defined(ENABLE_BROWSER_CDMS) |
| media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); |
| #endif |
| - |
| - unload_event_monitor_timeout_.reset(new TimeoutMonitor(base::Bind( |
| - &RenderViewHostImpl::OnSwappedOut, weak_factory_.GetWeakPtr(), true))); |
| } |
| RenderViewHostImpl::~RenderViewHostImpl() { |
| @@ -235,18 +217,13 @@ RenderViewHostImpl::~RenderViewHostImpl() { |
| } |
| delegate_->RenderViewDeleted(this); |
| - |
| - // If this was swapped out, it already decremented the active view |
| - // count of the SiteInstance it belongs to. |
| - if (IsRVHStateActive(rvh_state_)) |
| - instance_->decrement_active_view_count(); |
| } |
| RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { |
| return delegate_; |
| } |
| -SiteInstance* RenderViewHostImpl::GetSiteInstance() const { |
| +SiteInstanceImpl* RenderViewHostImpl::GetSiteInstance() const { |
| return instance_.get(); |
| } |
| @@ -292,7 +269,7 @@ bool RenderViewHostImpl::CreateRenderView( |
| params.frame_name = frame_name; |
| // Ensure the RenderView sets its opener correctly. |
| params.opener_route_id = opener_route_id; |
| - params.swapped_out = !IsRVHStateActive(rvh_state_); |
| + params.swapped_out = !is_active_; |
| params.proxy_routing_id = proxy_route_id; |
| params.hidden = is_hidden(); |
| params.never_visible = delegate_->IsNeverVisible(); |
| @@ -490,73 +467,8 @@ void RenderViewHostImpl::SuppressDialogsUntilSwapOut() { |
| Send(new ViewMsg_SuppressDialogsUntilSwapOut(GetRoutingID())); |
| } |
| -void RenderViewHostImpl::OnSwappedOut(bool timed_out) { |
| - // Ignore spurious swap out ack. |
| - if (!IsWaitingForUnloadACK()) |
| - return; |
| - |
| - TRACE_EVENT0("navigation", "RenderViewHostImpl::OnSwappedOut"); |
| - unload_event_monitor_timeout_->Stop(); |
| - if (timed_out) { |
|
Charlie Reis
2014/09/29 16:52:57
All this is basically a no-op leftover from 104346
|
| - base::ProcessHandle process_handle = GetProcess()->GetHandle(); |
| - int views = 0; |
| - |
| - // Count the number of active widget hosts for the process, which |
| - // is equivalent to views using the process as of this writing. |
| - scoped_ptr<RenderWidgetHostIterator> widgets( |
| - RenderWidgetHost::GetRenderWidgetHosts()); |
| - while (RenderWidgetHost* widget = widgets->GetNextHost()) { |
| - if (widget->GetProcess()->GetID() == GetProcess()->GetID()) |
| - ++views; |
| - } |
| - |
| - if (!RenderProcessHost::run_renderer_in_process() && |
| - process_handle && views <= 1) { |
| - // The process can safely be terminated, only if WebContents sets |
| - // SuddenTerminationAllowed, which indicates that the timer has expired. |
| - // This is not the case if we load data URLs or about:blank. The reason |
| - // is that those have no network requests and this code is hit without |
| - // setting the unresponsiveness timer. This allows a corner case where a |
| - // navigation to a data URL will leave a process running, if the |
| - // beforeunload handler completes fine, but the unload handler hangs. |
| - // At this time, the complexity to solve this edge case is not worthwhile. |
| - if (SuddenTerminationAllowed()) { |
| - // We should kill the process, but for now, just log the data so we can |
| - // diagnose the kill rate and investigate if separate timer is needed. |
| - // http://crbug.com/104346. |
| - |
| - // Log a histogram point to help us diagnose how many of those kills |
| - // we have performed. 1 is the enum value for RendererType Normal for |
| - // the histogram. |
| - UMA_HISTOGRAM_PERCENTAGE( |
| - "BrowserRenderProcessHost.ChildKillsUnresponsive", 1); |
| - } |
| - } |
| - // This is going to be incorrect for subframes and will only hit if |
| - // --site-per-process is specified. |
| - TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this); |
| - } |
| - |
| - switch (rvh_state_) { |
| - case STATE_PENDING_SWAP_OUT: |
| - SetState(STATE_SWAPPED_OUT); |
| - break; |
| - case STATE_PENDING_SHUTDOWN: |
| - DCHECK(!pending_shutdown_on_swap_out_.is_null()); |
| - pending_shutdown_on_swap_out_.Run(); |
| - break; |
| - default: |
| - NOTREACHED(); |
| - } |
| -} |
| - |
| -void RenderViewHostImpl::SetPendingShutdown(const base::Closure& on_swap_out) { |
| - pending_shutdown_on_swap_out_ = on_swap_out; |
| - SetState(STATE_PENDING_SHUTDOWN); |
| -} |
| - |
| void RenderViewHostImpl::ClosePage() { |
| - SetState(STATE_WAITING_FOR_CLOSE); |
| + is_waiting_for_close_ack_ = true; |
| StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
| if (IsRenderViewLive()) { |
| @@ -582,7 +494,7 @@ void RenderViewHostImpl::ClosePage() { |
| void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() { |
| StopHangMonitorTimeout(); |
| - is_waiting_for_beforeunload_ack_ = false; |
| + is_waiting_for_close_ack_ = false; |
| sudden_termination_allowed_ = true; |
| delegate_->Close(this); |
| @@ -873,7 +785,7 @@ bool RenderViewHostImpl::OnMessageReceived(const IPC::Message& msg) { |
| // Filter out most IPC messages if this renderer is swapped out. |
| // We still want to handle certain ACKs to keep our state consistent. |
| - if (IsSwappedOut()) { |
| + if (is_swapped_out_) { |
| if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) { |
| // If this is a synchronous message and we decided not to handle it, |
| // we must send an error reply, or else the renderer will be stuck |
| @@ -1017,7 +929,7 @@ void RenderViewHostImpl::OnShowView(int route_id, |
| WindowOpenDisposition disposition, |
| const gfx::Rect& initial_pos, |
| bool user_gesture) { |
| - if (IsRVHStateActive(rvh_state_)) { |
| + if (is_active_) { |
| delegate_->ShowCreatedWindow( |
| route_id, disposition, initial_pos, user_gesture); |
| } |
| @@ -1026,13 +938,13 @@ void RenderViewHostImpl::OnShowView(int route_id, |
| void RenderViewHostImpl::OnShowWidget(int route_id, |
| const gfx::Rect& initial_pos) { |
| - if (IsRVHStateActive(rvh_state_)) |
| + if (is_active_) |
| delegate_->ShowCreatedWidget(route_id, initial_pos); |
| Send(new ViewMsg_Move_ACK(route_id)); |
| } |
| void RenderViewHostImpl::OnShowFullscreenWidget(int route_id) { |
| - if (IsRVHStateActive(rvh_state_)) |
| + if (is_active_) |
| delegate_->ShowCreatedFullscreenWidget(route_id); |
| Send(new ViewMsg_Move_ACK(route_id)); |
| } |
| @@ -1095,7 +1007,7 @@ void RenderViewHostImpl::OnUpdateState(int32 page_id, const PageState& state) { |
| } |
| void RenderViewHostImpl::OnUpdateTargetURL(const GURL& url) { |
| - if (IsRVHStateActive(rvh_state_)) |
| + if (is_active_) |
| delegate_->UpdateTargetURL(url); |
| // Send a notification back to the renderer that we are ready to |
| @@ -1110,7 +1022,7 @@ void RenderViewHostImpl::OnClose() { |
| } |
| void RenderViewHostImpl::OnRequestMove(const gfx::Rect& pos) { |
| - if (IsRVHStateActive(rvh_state_)) |
| + if (is_active_) |
| delegate_->RequestMove(pos); |
| Send(new ViewMsg_Move_ACK(GetRoutingID())); |
| } |
| @@ -1260,8 +1172,7 @@ void RenderViewHostImpl::OnClosePageACK() { |
| } |
| void RenderViewHostImpl::NotifyRendererUnresponsive() { |
| - delegate_->RendererUnresponsive( |
| - this, is_waiting_for_beforeunload_ack_, IsWaitingForUnloadACK()); |
| + delegate_->RendererUnresponsive(this); |
| } |
| void RenderViewHostImpl::NotifyRendererResponsive() { |
| @@ -1335,12 +1246,6 @@ void RenderViewHostImpl::ForwardKeyboardEvent( |
| RenderWidgetHostImpl::ForwardKeyboardEvent(key_event); |
| } |
| -bool RenderViewHostImpl::IsWaitingForUnloadACK() const { |
| - return rvh_state_ == STATE_WAITING_FOR_CLOSE || |
| - rvh_state_ == STATE_PENDING_SHUTDOWN || |
| - rvh_state_ == STATE_PENDING_SWAP_OUT; |
| -} |
| - |
| void RenderViewHostImpl::OnTextSurroundingSelectionResponse( |
| const base::string16& content, |
| size_t start_offset, |
| @@ -1469,27 +1374,6 @@ void RenderViewHostImpl::OnFocusedNodeTouched(bool editable) { |
| #endif |
| } |
| -void RenderViewHostImpl::SetState(RenderViewHostImplState rvh_state) { |
| - // We update the number of RenderViews in a SiteInstance when the |
| - // swapped out status of this RenderView gets flipped to/from live. |
| - if (!IsRVHStateActive(rvh_state_) && IsRVHStateActive(rvh_state)) |
| - instance_->increment_active_view_count(); |
| - else if (IsRVHStateActive(rvh_state_) && !IsRVHStateActive(rvh_state)) |
| - instance_->decrement_active_view_count(); |
| - |
| - // Whenever we change the RVH state to and from live or swapped out state, we |
| - // should not be waiting for beforeunload or unload acks. We clear them here |
| - // to be safe, since they can cause navigations to be ignored in OnNavigate. |
| - if (rvh_state == STATE_DEFAULT || |
| - rvh_state == STATE_SWAPPED_OUT || |
| - rvh_state_ == STATE_DEFAULT || |
| - rvh_state_ == STATE_SWAPPED_OUT) { |
| - is_waiting_for_beforeunload_ack_ = false; |
| - } |
| - rvh_state_ = rvh_state; |
| - |
| -} |
| - |
| bool RenderViewHostImpl::CanAccessFilesOfPageState( |
| const PageState& state) const { |
| ChildProcessSecurityPolicyImpl* policy = |