Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1145)

Side by Side Diff: content/browser/frame_host/render_frame_proxy_host.cc

Issue 782093002: Ensure that before creating proxy of site A, RVH of site A is initialized. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix RenderFrameHostManagerTest.CleanUpSwappedOutRVHOnProcessCrash Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 26 matching lines...) Expand all
37 RoutingIDFrameProxyMap* frames = g_routing_id_frame_proxy_map.Pointer(); 37 RoutingIDFrameProxyMap* frames = g_routing_id_frame_proxy_map.Pointer();
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 frame_tree_node_(frame_tree_node) { 47 frame_tree_node_(frame_tree_node),
48 render_frame_proxy_created_(false) {
48 GetProcess()->AddRoute(routing_id_, this); 49 GetProcess()->AddRoute(routing_id_, this);
49 CHECK(g_routing_id_frame_proxy_map.Get().insert( 50 CHECK(g_routing_id_frame_proxy_map.Get().insert(
50 std::make_pair( 51 std::make_pair(
51 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_), 52 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_),
52 this)).second); 53 this)).second);
53 54
54 if (!frame_tree_node_->IsMainFrame() && 55 if (!frame_tree_node_->IsMainFrame() &&
55 frame_tree_node_->parent() 56 frame_tree_node_->parent()
56 ->render_manager() 57 ->render_manager()
57 ->current_frame_host() 58 ->current_frame_host()
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 115
115 bool handled = true; 116 bool handled = true;
116 IPC_BEGIN_MESSAGE_MAP(RenderFrameProxyHost, msg) 117 IPC_BEGIN_MESSAGE_MAP(RenderFrameProxyHost, msg)
117 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) 118 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL)
118 IPC_MESSAGE_UNHANDLED(handled = false) 119 IPC_MESSAGE_UNHANDLED(handled = false)
119 IPC_END_MESSAGE_MAP() 120 IPC_END_MESSAGE_MAP()
120 return handled; 121 return handled;
121 } 122 }
122 123
123 bool RenderFrameProxyHost::InitRenderFrameProxy() { 124 bool RenderFrameProxyHost::InitRenderFrameProxy() {
125 DCHECK(!render_frame_proxy_created_);
124 // The process may (if we're sharing a process with another host that already 126 // The process may (if we're sharing a process with another host that already
125 // initialized it) or may not (we have our own process or the old process 127 // initialized it) or may not (we have our own process or the old process
126 // crashed) have been initialized. Calling Init multiple times will be 128 // crashed) have been initialized. Calling Init multiple times will be
127 // ignored, so this is safe. 129 // ignored, so this is safe.
128 if (!site_instance_->GetProcess()->Init()) 130 if (!site_instance_->GetProcess()->Init())
129 return false; 131 return false;
130 132
131 DCHECK(GetProcess()->HasConnection()); 133 DCHECK(GetProcess()->HasConnection());
132 134
133 int parent_routing_id = MSG_ROUTING_NONE; 135 int parent_routing_id = MSG_ROUTING_NONE;
134 if (frame_tree_node_->parent()) { 136 if (frame_tree_node_->parent()) {
135 parent_routing_id = frame_tree_node_->parent() 137 parent_routing_id = frame_tree_node_->parent()
136 ->render_manager() 138 ->render_manager()
137 ->GetRoutingIdForSiteInstance(site_instance_.get()); 139 ->GetRoutingIdForSiteInstance(site_instance_.get());
138 CHECK_NE(parent_routing_id, MSG_ROUTING_NONE); 140 CHECK_NE(parent_routing_id, MSG_ROUTING_NONE);
139 } 141 }
140 142
141 Send(new FrameMsg_NewFrameProxy(routing_id_, 143 Send(new FrameMsg_NewFrameProxy(routing_id_,
142 parent_routing_id, 144 parent_routing_id,
143 frame_tree_node_->frame_tree() 145 frame_tree_node_->frame_tree()
144 ->GetRenderViewHost(site_instance_.get()) 146 ->GetRenderViewHost(site_instance_.get())
145 ->GetRoutingID(), 147 ->GetRoutingID(),
146 frame_tree_node_ 148 frame_tree_node_
147 ->current_replication_state())); 149 ->current_replication_state()));
148 150
151 render_frame_proxy_created_ = true;
149 return true; 152 return true;
150 } 153 }
151 154
152 void RenderFrameProxyHost::DisownOpener() { 155 void RenderFrameProxyHost::DisownOpener() {
153 Send(new FrameMsg_DisownOpener(GetRoutingID())); 156 Send(new FrameMsg_DisownOpener(GetRoutingID()));
154 } 157 }
155 158
156 void RenderFrameProxyHost::OnOpenURL( 159 void RenderFrameProxyHost::OnOpenURL(
157 const FrameHostMsg_OpenURL_Params& params) { 160 const FrameHostMsg_OpenURL_Params& params) {
158 frame_tree_node_->current_frame_host()->OpenURL(params, site_instance_.get()); 161 frame_tree_node_->current_frame_host()->OpenURL(params, site_instance_.get());
159 } 162 }
160 163
161 } // namespace content 164 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698