| 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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "content/browser/bad_message.h" | 8 #include "content/browser/bad_message.h" |
| 9 #include "content/browser/frame_host/cross_process_frame_connector.h" | 9 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| 10 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 IPC_MESSAGE_HANDLER(FrameHostMsg_Detach, OnDetach) | 122 IPC_MESSAGE_HANDLER(FrameHostMsg_Detach, OnDetach) |
| 123 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) | 123 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) |
| 124 IPC_MESSAGE_HANDLER(FrameHostMsg_RouteMessageEvent, OnRouteMessageEvent) | 124 IPC_MESSAGE_HANDLER(FrameHostMsg_RouteMessageEvent, OnRouteMessageEvent) |
| 125 IPC_MESSAGE_UNHANDLED(handled = false) | 125 IPC_MESSAGE_UNHANDLED(handled = false) |
| 126 IPC_END_MESSAGE_MAP() | 126 IPC_END_MESSAGE_MAP() |
| 127 return handled; | 127 return handled; |
| 128 } | 128 } |
| 129 | 129 |
| 130 bool RenderFrameProxyHost::InitRenderFrameProxy() { | 130 bool RenderFrameProxyHost::InitRenderFrameProxy() { |
| 131 DCHECK(!render_frame_proxy_created_); | 131 DCHECK(!render_frame_proxy_created_); |
| 132 // The process may (if we're sharing a process with another host that already | 132 |
| 133 // initialized it) or may not (we have our own process or the old process | 133 // It is possible to reach this when the process is dead (in particular, when |
| 134 // crashed) have been initialized. Calling Init multiple times will be | 134 // creating proxies from CreateProxiesForChildFrame). In that case, don't |
| 135 // ignored, so this is safe. | 135 // create the proxy. The process shouldn't be resurrected just to create |
| 136 if (!GetProcess()->Init()) | 136 // RenderFrameProxies; it should be restored only if it needs to host a |
| 137 // RenderFrame. When that happens, the process will be reinitialized, and |
| 138 // all necessary proxies, including any of the ones we skipped here, will be |
| 139 // created by CreateProxiesForSiteInstance. See https://crbug.com/476846 |
| 140 if (!GetProcess()->HasConnection()) |
| 137 return false; | 141 return false; |
| 138 | 142 |
| 139 DCHECK(GetProcess()->HasConnection()); | |
| 140 | |
| 141 int parent_routing_id = MSG_ROUTING_NONE; | 143 int parent_routing_id = MSG_ROUTING_NONE; |
| 142 if (frame_tree_node_->parent()) { | 144 if (frame_tree_node_->parent()) { |
| 143 parent_routing_id = frame_tree_node_->parent() | 145 // It is safe to use GetRenderFrameProxyHost to get the parent proxy, since |
| 144 ->render_manager() | 146 // new child frames always start out as local frames, so a new proxy should |
| 145 ->GetRoutingIdForSiteInstance(site_instance_.get()); | 147 // never have a RenderFrameHost as a parent. |
| 148 RenderFrameProxyHost* parent_proxy = |
| 149 frame_tree_node_->parent()->render_manager()->GetRenderFrameProxyHost( |
| 150 site_instance_.get()); |
| 151 CHECK(parent_proxy); |
| 152 // When this is called, the parent RenderFrameProxy should already exist. |
| 153 // The FrameNew_NewFrameProxy will crash on the renderer side if there's no |
| 154 // parent proxy. |
| 155 CHECK(parent_proxy->is_render_frame_proxy_live()); |
| 156 parent_routing_id = parent_proxy->GetRoutingID(); |
| 146 CHECK_NE(parent_routing_id, MSG_ROUTING_NONE); | 157 CHECK_NE(parent_routing_id, MSG_ROUTING_NONE); |
| 147 } | 158 } |
| 148 | 159 |
| 149 Send(new FrameMsg_NewFrameProxy(routing_id_, | 160 Send(new FrameMsg_NewFrameProxy(routing_id_, |
| 150 parent_routing_id, | 161 parent_routing_id, |
| 151 frame_tree_node_->frame_tree() | 162 frame_tree_node_->frame_tree() |
| 152 ->GetRenderViewHost(site_instance_.get()) | 163 ->GetRenderViewHost(site_instance_.get()) |
| 153 ->GetRoutingID(), | 164 ->GetRoutingID(), |
| 154 frame_tree_node_ | 165 frame_tree_node_ |
| 155 ->current_replication_state())); | 166 ->current_replication_state())); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts, | 267 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts, |
| 257 message_port_message_filter, target_rfh->GetRoutingID(), | 268 message_port_message_filter, target_rfh->GetRoutingID(), |
| 258 new_params)); | 269 new_params)); |
| 259 } else { | 270 } else { |
| 260 target_rfh->Send( | 271 target_rfh->Send( |
| 261 new FrameMsg_PostMessageEvent(target_rfh->GetRoutingID(), new_params)); | 272 new FrameMsg_PostMessageEvent(target_rfh->GetRoutingID(), new_params)); |
| 262 } | 273 } |
| 263 } | 274 } |
| 264 | 275 |
| 265 } // namespace content | 276 } // namespace content |
| OLD | NEW |