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/frame_host/cross_process_frame_connector.h" | 8 #include "content/browser/frame_host/cross_process_frame_connector.h" |
9 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
10 #include "content/browser/frame_host/frame_tree_node.h" | 10 #include "content/browser/frame_host/frame_tree_node.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 RoutingIDFrameProxyMap::iterator it = frames->find( | 38 RoutingIDFrameProxyMap::iterator it = frames->find( |
39 RenderFrameProxyHostID(process_id, routing_id)); | 39 RenderFrameProxyHostID(process_id, routing_id)); |
40 return it == frames->end() ? NULL : it->second; | 40 return it == frames->end() ? NULL : it->second; |
41 } | 41 } |
42 | 42 |
43 RenderFrameProxyHost::RenderFrameProxyHost(SiteInstance* site_instance, | 43 RenderFrameProxyHost::RenderFrameProxyHost(SiteInstance* site_instance, |
44 FrameTreeNode* frame_tree_node) | 44 FrameTreeNode* frame_tree_node) |
45 : routing_id_(site_instance->GetProcess()->GetNextRoutingID()), | 45 : routing_id_(site_instance->GetProcess()->GetNextRoutingID()), |
46 site_instance_(site_instance), | 46 site_instance_(site_instance), |
47 process_(site_instance->GetProcess()), | 47 process_(site_instance->GetProcess()), |
48 frame_tree_node_(frame_tree_node) { | 48 frame_tree_node_(frame_tree_node), |
| 49 render_frame_proxy_created_(false) { |
49 GetProcess()->AddRoute(routing_id_, this); | 50 GetProcess()->AddRoute(routing_id_, this); |
50 CHECK(g_routing_id_frame_proxy_map.Get().insert( | 51 CHECK(g_routing_id_frame_proxy_map.Get().insert( |
51 std::make_pair( | 52 std::make_pair( |
52 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_), | 53 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_), |
53 this)).second); | 54 this)).second); |
54 | 55 |
55 if (!frame_tree_node_->IsMainFrame() && | 56 if (!frame_tree_node_->IsMainFrame() && |
56 frame_tree_node_->parent() | 57 frame_tree_node_->parent() |
57 ->render_manager() | 58 ->render_manager() |
58 ->current_frame_host() | 59 ->current_frame_host() |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 116 |
116 bool handled = true; | 117 bool handled = true; |
117 IPC_BEGIN_MESSAGE_MAP(RenderFrameProxyHost, msg) | 118 IPC_BEGIN_MESSAGE_MAP(RenderFrameProxyHost, msg) |
118 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) | 119 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) |
119 IPC_MESSAGE_UNHANDLED(handled = false) | 120 IPC_MESSAGE_UNHANDLED(handled = false) |
120 IPC_END_MESSAGE_MAP() | 121 IPC_END_MESSAGE_MAP() |
121 return handled; | 122 return handled; |
122 } | 123 } |
123 | 124 |
124 bool RenderFrameProxyHost::InitRenderFrameProxy() { | 125 bool RenderFrameProxyHost::InitRenderFrameProxy() { |
| 126 DCHECK(!render_frame_proxy_created_); |
125 // The process may (if we're sharing a process with another host that already | 127 // The process may (if we're sharing a process with another host that already |
126 // initialized it) or may not (we have our own process or the old process | 128 // initialized it) or may not (we have our own process or the old process |
127 // crashed) have been initialized. Calling Init multiple times will be | 129 // crashed) have been initialized. Calling Init multiple times will be |
128 // ignored, so this is safe. | 130 // ignored, so this is safe. |
129 if (!GetProcess()->Init()) | 131 if (!GetProcess()->Init()) |
130 return false; | 132 return false; |
131 | 133 |
132 DCHECK(GetProcess()->HasConnection()); | 134 DCHECK(GetProcess()->HasConnection()); |
133 | 135 |
134 int parent_routing_id = MSG_ROUTING_NONE; | 136 int parent_routing_id = MSG_ROUTING_NONE; |
135 if (frame_tree_node_->parent()) { | 137 if (frame_tree_node_->parent()) { |
136 parent_routing_id = frame_tree_node_->parent() | 138 parent_routing_id = frame_tree_node_->parent() |
137 ->render_manager() | 139 ->render_manager() |
138 ->GetRoutingIdForSiteInstance(site_instance_.get()); | 140 ->GetRoutingIdForSiteInstance(site_instance_.get()); |
139 CHECK_NE(parent_routing_id, MSG_ROUTING_NONE); | 141 CHECK_NE(parent_routing_id, MSG_ROUTING_NONE); |
140 } | 142 } |
141 | 143 |
142 Send(new FrameMsg_NewFrameProxy(routing_id_, | 144 Send(new FrameMsg_NewFrameProxy(routing_id_, |
143 parent_routing_id, | 145 parent_routing_id, |
144 frame_tree_node_->frame_tree() | 146 frame_tree_node_->frame_tree() |
145 ->GetRenderViewHost(site_instance_.get()) | 147 ->GetRenderViewHost(site_instance_.get()) |
146 ->GetRoutingID(), | 148 ->GetRoutingID(), |
147 frame_tree_node_ | 149 frame_tree_node_ |
148 ->current_replication_state())); | 150 ->current_replication_state())); |
149 | 151 |
| 152 render_frame_proxy_created_ = true; |
150 return true; | 153 return true; |
151 } | 154 } |
152 | 155 |
153 void RenderFrameProxyHost::DisownOpener() { | 156 void RenderFrameProxyHost::DisownOpener() { |
154 Send(new FrameMsg_DisownOpener(GetRoutingID())); | 157 Send(new FrameMsg_DisownOpener(GetRoutingID())); |
155 } | 158 } |
156 | 159 |
157 void RenderFrameProxyHost::OnOpenURL( | 160 void RenderFrameProxyHost::OnOpenURL( |
158 const FrameHostMsg_OpenURL_Params& params) { | 161 const FrameHostMsg_OpenURL_Params& params) { |
159 frame_tree_node_->current_frame_host()->OpenURL(params, site_instance_.get()); | 162 frame_tree_node_->current_frame_host()->OpenURL(params, site_instance_.get()); |
160 } | 163 } |
161 | 164 |
162 } // namespace content | 165 } // namespace content |
OLD | NEW |