| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "content/browser/frame_host/render_frame_proxy_host.h" | 5 #include "content/browser/frame_host/render_frame_proxy_host.h" |
| 6 | 6 |
| 7 #include "content/browser/frame_host/cross_process_frame_connector.h" | 7 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| 8 #include "content/browser/frame_host/frame_tree.h" |
| 8 #include "content/browser/frame_host/frame_tree_node.h" | 9 #include "content/browser/frame_host/frame_tree_node.h" |
| 9 #include "content/browser/frame_host/render_frame_host_impl.h" | 10 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 10 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 11 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
| 12 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 11 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 13 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 12 #include "content/browser/site_instance_impl.h" | 14 #include "content/browser/site_instance_impl.h" |
| 13 #include "content/common/frame_messages.h" | 15 #include "content/common/frame_messages.h" |
| 14 #include "ipc/ipc_message.h" | 16 #include "ipc/ipc_message.h" |
| 15 | 17 |
| 16 namespace content { | 18 namespace content { |
| 17 | 19 |
| 18 RenderFrameProxyHost::RenderFrameProxyHost(SiteInstance* site_instance, | 20 RenderFrameProxyHost::RenderFrameProxyHost(SiteInstance* site_instance, |
| 19 FrameTreeNode* frame_tree_node) | 21 FrameTreeNode* frame_tree_node) |
| 20 : routing_id_(site_instance->GetProcess()->GetNextRoutingID()), | 22 : routing_id_(site_instance->GetProcess()->GetNextRoutingID()), |
| 21 site_instance_(site_instance), | 23 site_instance_(site_instance), |
| 22 frame_tree_node_(frame_tree_node) { | 24 frame_tree_node_(frame_tree_node) { |
| 23 GetProcess()->AddRoute(routing_id_, this); | 25 GetProcess()->AddRoute(routing_id_, this); |
| 24 | 26 |
| 25 if (!frame_tree_node_->IsMainFrame() && | 27 if (!frame_tree_node_->IsMainFrame() && |
| 26 frame_tree_node_->parent() | 28 frame_tree_node_->parent() |
| 27 ->render_manager() | 29 ->render_manager() |
| 28 ->current_frame_host() | 30 ->current_frame_host() |
| 29 ->GetSiteInstance() == site_instance) { | 31 ->GetSiteInstance() == site_instance) { |
| 30 // The RenderFrameHost navigating cross-process is destroyed and a proxy for | 32 // The RenderFrameHost navigating cross-process is destroyed and a proxy for |
| 31 // it is created in the parent's process. CrossProcessFrameConnector | 33 // it is created in the parent's process. CrossProcessFrameConnector |
| 32 // initialization only needs to happen on an initial cross-process | 34 // initialization only needs to happen on an initial cross-process |
| 33 // navigation, when the RenderFrameHost leaves the same process as its | 35 // navigation, when the RenderFrameHost leaves the same process as its |
| 34 // parent. The same CrossProcessFrameConnector is used for subsequent cross- | 36 // parent. The same CrossProcessFrameConnector is used for subsequent cross- |
| 35 // process navigations, but it will be destroyed if the frame is | 37 // process navigations, but it will be destroyed if the frame is |
| 36 // navigated back to the same SiteInstance as its parent. | 38 // navigated back to the same SiteInstance as its parent. |
| 37 cross_process_frame_connector_.reset(new CrossProcessFrameConnector(this)); | 39 cross_process_frame_connector_.reset(new CrossProcessFrameConnector(this)); |
| 38 } | 40 } |
| 41 |
| 42 RenderFrameHostManager* manager = NULL; |
| 43 if (frame_tree_node_->parent()) { |
| 44 manager = frame_tree_node_->parent()->render_manager(); |
| 45 } |
| 46 |
| 47 LOG(ERROR) << "RFPH::RFPH[" << this << "]:" |
| 48 " process:" << site_instance_->GetProcess()->GetID() << |
| 49 ", routing:" << routing_id_ << |
| 50 ", site:" << site_instance_->GetSiteURL() << |
| 51 ", parent: " << manager; |
| 52 |
| 39 } | 53 } |
| 40 | 54 |
| 41 RenderFrameProxyHost::~RenderFrameProxyHost() { | 55 RenderFrameProxyHost::~RenderFrameProxyHost() { |
| 42 if (GetProcess()->HasConnection()) | 56 if (GetProcess()->HasConnection()) |
| 43 Send(new FrameMsg_DeleteProxy(routing_id_)); | 57 Send(new FrameMsg_DeleteProxy(routing_id_)); |
| 44 | 58 |
| 59 LOG(ERROR) << "RFPH::~RFPH[" << this << "]: " |
| 60 << site_instance_->GetSiteURL(); |
| 61 |
| 45 GetProcess()->RemoveRoute(routing_id_); | 62 GetProcess()->RemoveRoute(routing_id_); |
| 46 } | 63 } |
| 47 | 64 |
| 48 void RenderFrameProxyHost::SetChildRWHView(RenderWidgetHostView* view) { | 65 void RenderFrameProxyHost::SetChildRWHView(RenderWidgetHostView* view) { |
| 49 cross_process_frame_connector_->set_view( | 66 cross_process_frame_connector_->set_view( |
| 50 static_cast<RenderWidgetHostViewChildFrame*>(view)); | 67 static_cast<RenderWidgetHostViewChildFrame*>(view)); |
| 51 } | 68 } |
| 52 | 69 |
| 53 RenderViewHostImpl* RenderFrameProxyHost::GetRenderViewHost() { | 70 RenderViewHostImpl* RenderFrameProxyHost::GetRenderViewHost() { |
| 54 if (render_frame_host_.get()) | 71 if (render_frame_host_.get()) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 75 return true; | 92 return true; |
| 76 | 93 |
| 77 // TODO(nasko): This can be removed once we don't have a swapped out state on | 94 // TODO(nasko): This can be removed once we don't have a swapped out state on |
| 78 // RenderFrameHosts. See https://crbug.com/357747. | 95 // RenderFrameHosts. See https://crbug.com/357747. |
| 79 if (render_frame_host_.get()) | 96 if (render_frame_host_.get()) |
| 80 return render_frame_host_->OnMessageReceived(msg); | 97 return render_frame_host_->OnMessageReceived(msg); |
| 81 | 98 |
| 82 return false; | 99 return false; |
| 83 } | 100 } |
| 84 | 101 |
| 102 bool RenderFrameProxyHost::InitRenderFrameProxy() { |
| 103 LOG(ERROR) << "RFPH::Init[" << this << "]:"; |
| 104 // The process may (if we're sharing a process with another host that already |
| 105 // initialized it) or may not (we have our own process or the old process |
| 106 // crashed) have been initialized. Calling Init multiple times will be |
| 107 // ignored, so this is safe. |
| 108 if (!site_instance_->GetProcess()->Init()) { |
| 109 LOG(ERROR) << "RFPH::Init[" << this << "]:" |
| 110 << " failed to init process"; |
| 111 return false; |
| 112 } |
| 113 |
| 114 DCHECK(GetProcess()->HasConnection()); |
| 115 DCHECK(GetProcess()->GetBrowserContext()); |
| 116 |
| 117 int parent_routing_id = MSG_ROUTING_NONE; |
| 118 if (frame_tree_node_->parent()) { |
| 119 parent_routing_id = frame_tree_node_->parent()->render_manager()-> |
| 120 GetRoutingIdForSiteInstance(site_instance_); |
| 121 LOG(ERROR) << "RFPH::Init[" << this << "]:" |
| 122 << " parent:" << parent_routing_id; |
| 123 CHECK_NE(parent_routing_id, MSG_ROUTING_NONE); |
| 124 } |
| 125 |
| 126 Send(new FrameMsg_NewFrameProxy( |
| 127 routing_id_, |
| 128 parent_routing_id, |
| 129 frame_tree_node_->frame_tree()->GetRenderViewHost( |
| 130 site_instance_)->GetRoutingID())); |
| 131 |
| 132 return true; |
| 133 } |
| 134 |
| 85 } // namespace content | 135 } // namespace content |
| OLD | NEW |