Chromium Code Reviews| Index: content/browser/frame_host/render_frame_host_impl.cc |
| diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc |
| index bfeee98bd53588b5fd912e02fbeef89ebd1dda74..d890126ff74ee6052f32883c4dbfcfebfdf70815 100644 |
| --- a/content/browser/frame_host/render_frame_host_impl.cc |
| +++ b/content/browser/frame_host/render_frame_host_impl.cc |
| @@ -132,8 +132,8 @@ RenderFrameHost* RenderFrameHost::FromID(int render_process_id, |
| } |
| // static |
| -RenderFrameHostImpl* RenderFrameHostImpl::FromID( |
| - int process_id, int routing_id) { |
| +RenderFrameHostImpl* RenderFrameHostImpl::FromID(int process_id, |
| + int routing_id) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| RoutingIDFrameMap* frames = g_routing_id_frame_map.Pointer(); |
| RoutingIDFrameMap::iterator it = frames->find( |
| @@ -156,7 +156,18 @@ RenderFrameHostImpl::RenderFrameHostImpl( |
| frame_tree_node_(frame_tree_node), |
| routing_id_(routing_id), |
| is_swapped_out_(is_swapped_out), |
| + renderer_initialized_(false), |
| + has_received_swap_out_ack_(false), |
| weak_ptr_factory_(this) { |
| + RenderFrameHostManager* manager = NULL; |
| + if (frame_tree_node_->parent()) { |
| + manager = frame_tree_node_->parent()->render_manager(); |
| + } |
| + LOG(ERROR) << "RFHI::RFHI[" << this << "]: " |
| + << " process:" << GetProcess()->GetID() |
| + << ", routing:" << routing_id |
| + << ", site:" << GetSiteInstance()->GetSiteURL() |
| + << ", parent: " << manager; |
| frame_tree_->RegisterRenderFrameHost(this); |
| GetProcess()->AddRoute(routing_id_, this); |
| g_routing_id_frame_map.Get().insert(std::make_pair( |
| @@ -174,6 +185,7 @@ RenderFrameHostImpl::~RenderFrameHostImpl() { |
| // Notify the FrameTree that this RFH is going away, allowing it to shut down |
| // the corresponding RenderViewHost if it is no longer needed. |
| frame_tree_->UnregisterRenderFrameHost(this); |
| + LOG(ERROR) << "RFHI::~RFHI[" << this << "]"; |
| } |
| int RenderFrameHostImpl::GetRoutingID() { |
| @@ -248,7 +260,10 @@ bool RenderFrameHostImpl::Send(IPC::Message* message) { |
| make_scoped_ptr(message)); |
| } |
| - if (render_view_host_->IsSwappedOut()) { |
| + // Route IPCs through the RenderFrameProxyHost when in swapped out state. |
| + // Note: For subframes in --site-per-process mode, we don't use swapped out |
| + // RenderFrameHosts. |
| + if (frame_tree_node_->IsMainFrame() && render_view_host_->IsSwappedOut()) { |
| DCHECK(render_frame_proxy_host_); |
| return render_frame_proxy_host_->Send(message); |
| } |
| @@ -331,6 +346,31 @@ bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { |
| return handled; |
| } |
| +bool RenderFrameHostImpl::CreateRenderFrame( |
| + int parent_routing_id) { |
|
ncarter (slow)
2014/06/25 01:07:55
NIT PLEASE INDENT FOUR SPACES OR USE CLANG FORMAT
|
| + TRACE_EVENT0("frame_host", "RenderFrameHostImpl::CreateRenderFrame"); |
| + DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; |
| + |
| + // The process may (if we're sharing a process with another host that already |
| + // initialized it) or may not (we have our own process or the old process |
| + // crashed) have been initialized. Calling Init multiple times will be |
| + // ignored, so this is safe. |
| + if (!GetProcess()->Init()) |
| + return false; |
| + |
| + DCHECK(GetProcess()->HasConnection()); |
| + DCHECK(GetProcess()->GetBrowserContext()); |
| + |
| + renderer_initialized_ = true; |
| + Send(new FrameMsg_NewFrame(routing_id_, parent_routing_id)); |
| + |
| + return true; |
| +} |
| + |
| +bool RenderFrameHostImpl::IsRenderFrameLive() { |
| + return GetProcess()->HasConnection() && renderer_initialized_; |
|
ncarter (slow)
2014/06/25 01:07:55
If I recall correctly, RVHImpl::IsRenderFrameLive
|
| +} |
| + |
| void RenderFrameHostImpl::Init() { |
| GetProcess()->ResumeRequestsForView(routing_id_); |
| } |
| @@ -433,6 +473,9 @@ void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) { |
| Read(&msg, &iter, &validated_params)) |
| return; |
| + LOG(ERROR) << "RFH[" << this << "]::OnNavigate:" |
| + << " url:" << validated_params.url; |
| + |
| // If we're waiting for a cross-site beforeunload ack from this renderer and |
| // we receive a Navigate message from the main frame, then the renderer was |
| // navigating already and sent it before hearing the ViewMsg_Stop message. |
| @@ -544,8 +587,10 @@ void RenderFrameHostImpl::SwapOut(RenderFrameProxyHost* proxy) { |
| set_render_frame_proxy_host(proxy); |
| - if (render_view_host_->IsRenderViewLive()) |
| + if (render_view_host_->IsRenderViewLive()) { |
| + has_received_swap_out_ack_ = false; |
|
ncarter (slow)
2014/06/25 01:07:56
Do we need this at all? (when looking through this
|
| Send(new FrameMsg_SwapOut(routing_id_, proxy->GetRoutingID())); |
| + } |
| if (!GetParent()) |
| delegate_->SwappedOut(this); |
| @@ -558,6 +603,7 @@ void RenderFrameHostImpl::OnBeforeUnloadACK( |
| bool proceed, |
| const base::TimeTicks& renderer_before_unload_start_time, |
| const base::TimeTicks& renderer_before_unload_end_time) { |
| + LOG(ERROR) << "RFHI::OnBeforeUnloadACK[" << this << "]: "; |
| // TODO(creis): Support properly beforeunload on subframes. For now just |
| // pretend that the handler ran and allowed the navigation to proceed. |
| if (GetParent()) { |
| @@ -579,6 +625,8 @@ void RenderFrameHostImpl::OnBeforeUnloadACK( |
| // before OnNavigate while current RVH is waiting for commit but second |
| // navigation is started from the beginning. |
| if (!render_view_host_->is_waiting_for_beforeunload_ack_) { |
| + LOG(ERROR) << "RFHI::OnBeforeUnloadACK[" << this << "]: " |
| + << "!is_waiting_for_beforeunload_ack_"; |
| return; |
| } |
| @@ -612,6 +660,7 @@ void RenderFrameHostImpl::OnBeforeUnloadACK( |
| } |
| void RenderFrameHostImpl::OnSwapOutACK() { |
| + has_received_swap_out_ack_ = true; |
| OnSwappedOut(false); |
| } |
| @@ -830,7 +879,10 @@ void RenderFrameHostImpl::NavigateToURL(const GURL& url) { |
| void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { |
| // TODO(creis): Support subframes. |
| + LOG(ERROR) << "RFHI::DispatchBeforeUnload[" << this << "]: "; |
| if (!render_view_host_->IsRenderViewLive() || GetParent()) { |
| + LOG(ERROR) << "RFHI::DispatchBeforeUnload[" << this << "]: " |
| + << "!RenderViewLive or GetParent()"; |
| // We don't have a live renderer, so just skip running beforeunload. |
| render_view_host_->is_waiting_for_beforeunload_ack_ = true; |
| render_view_host_->unload_ack_is_for_cross_site_transition_ = |
| @@ -844,6 +896,8 @@ void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { |
| // several times, or if she clicks the tab close button then the browser close |
| // button), and we only send the message once. |
| if (render_view_host_->is_waiting_for_beforeunload_ack_) { |
| + LOG(ERROR) << "RFHI::DispatchBeforeUnload[" << this << "]: " |
| + << "is_waiting_for_beforeunload_ack"; |
| // Some of our close messages could be for the tab, others for cross-site |
| // transitions. We always want to think it's for closing the tab if any |
| // of the messages were, since otherwise it might be impossible to close |
| @@ -854,6 +908,8 @@ void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { |
| render_view_host_->unload_ack_is_for_cross_site_transition_ && |
| for_cross_site_transition; |
| } else { |
| + LOG(ERROR) << "RFHI::DispatchBeforeUnload[" << this << "]: " |
| + << "send IPC"; |
| // Start the hang monitor in case the renderer hangs in the beforeunload |
| // handler. |
| render_view_host_->is_waiting_for_beforeunload_ack_ = true; |