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

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

Issue 2226023003: Fix RenderView reuse issues after a pending RenderFrameHost dies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve conflicts Created 4 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_host_manager.h" 5 #include "content/browser/frame_host/render_frame_host_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // occur before initializing the RenderView; the flow of creating the 234 // occur before initializing the RenderView; the flow of creating the
235 // RenderView can cause browser-side code to execute that expects the this 235 // RenderView can cause browser-side code to execute that expects the this
236 // RFH's shell::InterfaceRegistry to be initialized (e.g., if the site is a 236 // RFH's shell::InterfaceRegistry to be initialized (e.g., if the site is a
237 // WebUI site that is handled via Mojo, then Mojo WebUI code in //chrome 237 // WebUI site that is handled via Mojo, then Mojo WebUI code in //chrome
238 // will add an interface to this RFH's InterfaceRegistry). 238 // will add an interface to this RFH's InterfaceRegistry).
239 dest_render_frame_host->SetUpMojoIfNeeded(); 239 dest_render_frame_host->SetUpMojoIfNeeded();
240 240
241 // Recreate the opener chain. 241 // Recreate the opener chain.
242 CreateOpenerProxies(dest_render_frame_host->GetSiteInstance(), 242 CreateOpenerProxies(dest_render_frame_host->GetSiteInstance(),
243 frame_tree_node_); 243 frame_tree_node_);
244 if (!InitRenderView(dest_render_frame_host->render_view_host(), nullptr)) 244 if (!InitRenderView(dest_render_frame_host->render_view_host(), nullptr))
alexmos 2016/08/08 23:59:02 This was where we actually crashed in CreateRender
245 return nullptr; 245 return nullptr;
246 246
247 if (GetNavigatingWebUI()) { 247 if (GetNavigatingWebUI()) {
248 // A new RenderView was created and there is a navigating WebUI which 248 // A new RenderView was created and there is a navigating WebUI which
249 // never interacted with it. So notify the WebUI using RenderViewCreated. 249 // never interacted with it. So notify the WebUI using RenderViewCreated.
250 GetNavigatingWebUI()->RenderViewCreated( 250 GetNavigatingWebUI()->RenderViewCreated(
251 dest_render_frame_host->render_view_host()); 251 dest_render_frame_host->render_view_host());
252 } 252 }
253 253
254 // Now that we've created a new renderer, be sure to hide it if it isn't 254 // Now that we've created a new renderer, be sure to hide it if it isn't
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 GURL dest_url, 1022 GURL dest_url,
1023 SiteInstanceRelation relation_to_current) 1023 SiteInstanceRelation relation_to_current)
1024 : existing_site_instance(nullptr), relation(relation_to_current) { 1024 : existing_site_instance(nullptr), relation(relation_to_current) {
1025 new_site_url = SiteInstance::GetSiteForURL(browser_context, dest_url); 1025 new_site_url = SiteInstance::GetSiteForURL(browser_context, dest_url);
1026 } 1026 }
1027 1027
1028 void RenderFrameHostManager::RenderProcessGone(SiteInstanceImpl* instance) { 1028 void RenderFrameHostManager::RenderProcessGone(SiteInstanceImpl* instance) {
1029 GetRenderFrameProxyHost(instance)->set_render_frame_proxy_created(false); 1029 GetRenderFrameProxyHost(instance)->set_render_frame_proxy_created(false);
1030 } 1030 }
1031 1031
1032 void RenderFrameHostManager::CancelPendingIfNecessary(
Charlie Reis 2016/08/09 16:31:18 Drive-by: I just made CancelPending() public in ht
alexmos 2016/08/09 23:09:46 Done.
1033 RenderFrameHostImpl* render_frame_host) {
1034 if (render_frame_host == pending_render_frame_host_.get())
1035 CancelPending();
1036 else if (render_frame_host == speculative_render_frame_host_.get()) {
1037 frame_tree_node_->ResetNavigationRequest(false);
alexmos 2016/08/08 23:59:02 Does this make sense in the PlzNavigate case? I f
nasko 2016/08/09 18:32:32 We shouldn't be cancelling the request if the spec
alexmos 2016/08/09 23:09:46 Done. Filed https://crbug.com/636119 and referenc
1038 }
1039 }
1040
1032 void RenderFrameHostManager::ActiveFrameCountIsZero( 1041 void RenderFrameHostManager::ActiveFrameCountIsZero(
1033 SiteInstanceImpl* site_instance) { 1042 SiteInstanceImpl* site_instance) {
1034 // |site_instance| no longer contains any active RenderFrameHosts, so we don't 1043 // |site_instance| no longer contains any active RenderFrameHosts, so we don't
1035 // need to maintain a proxy there anymore. 1044 // need to maintain a proxy there anymore.
1036 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(site_instance); 1045 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(site_instance);
1037 CHECK(proxy); 1046 CHECK(proxy);
1038 1047
1039 DeleteRenderFrameProxyHost(site_instance); 1048 DeleteRenderFrameProxyHost(site_instance);
1040 } 1049 }
1041 1050
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
2129 delegate_->NotifySwappedFromRenderManager( 2138 delegate_->NotifySwappedFromRenderManager(
2130 old_render_frame_host.get(), render_frame_host_.get(), is_main_frame); 2139 old_render_frame_host.get(), render_frame_host_.get(), is_main_frame);
2131 2140
2132 // The RenderViewHost keeps track of the main RenderFrameHost routing id. 2141 // The RenderViewHost keeps track of the main RenderFrameHost routing id.
2133 // If this is committing a main frame navigation, update it and set the 2142 // If this is committing a main frame navigation, update it and set the
2134 // routing id in the RenderViewHost associated with the old RenderFrameHost 2143 // routing id in the RenderViewHost associated with the old RenderFrameHost
2135 // to MSG_ROUTING_NONE. 2144 // to MSG_ROUTING_NONE.
2136 if (is_main_frame) { 2145 if (is_main_frame) {
2137 render_frame_host_->render_view_host()->set_main_frame_routing_id( 2146 render_frame_host_->render_view_host()->set_main_frame_routing_id(
2138 render_frame_host_->routing_id()); 2147 render_frame_host_->routing_id());
2148 render_frame_host_->render_view_host()->set_is_active(true);
2149 render_frame_host_->render_view_host()->set_is_swapped_out(false);
2139 old_render_frame_host->render_view_host()->set_main_frame_routing_id( 2150 old_render_frame_host->render_view_host()->set_main_frame_routing_id(
2140 MSG_ROUTING_NONE); 2151 MSG_ROUTING_NONE);
2141 } 2152 }
2142 2153
2143 // Swap out the old frame now that the new one is visible. 2154 // Swap out the old frame now that the new one is visible.
2144 // This will swap it out and schedule it for deletion when the swap out ack 2155 // This will swap it out and schedule it for deletion when the swap out ack
2145 // arrives (or immediately if the process isn't live). 2156 // arrives (or immediately if the process isn't live).
2146 SwapOutOldFrame(std::move(old_render_frame_host)); 2157 SwapOutOldFrame(std::move(old_render_frame_host));
2147 2158
2148 // Since the new RenderFrameHost is now committed, there must be no proxies 2159 // Since the new RenderFrameHost is now committed, there must be no proxies
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2186 2197
2187 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); 2198 SiteInstance* current_instance = render_frame_host_->GetSiteInstance();
2188 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( 2199 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation(
2189 dest_url, source_instance, dest_instance, nullptr, transition, 2200 dest_url, source_instance, dest_instance, nullptr, transition,
2190 dest_is_restore, dest_is_view_source_mode); 2201 dest_is_restore, dest_is_view_source_mode);
2191 2202
2192 // If we are currently navigating cross-process to a pending RFH for a 2203 // If we are currently navigating cross-process to a pending RFH for a
2193 // different SiteInstance, we want to get back to normal and then navigate as 2204 // different SiteInstance, we want to get back to normal and then navigate as
2194 // usual. We will reuse the pending RFH below if it matches the destination 2205 // usual. We will reuse the pending RFH below if it matches the destination
2195 // SiteInstance. 2206 // SiteInstance.
2196 if (pending_render_frame_host_ && 2207 if (pending_render_frame_host_) {
2197 pending_render_frame_host_->GetSiteInstance() != new_instance) 2208 if (pending_render_frame_host_->GetSiteInstance() != new_instance) {
2198 CancelPending(); 2209 CancelPending();
2210 } else {
2211 // When a pending RFH is reused, it should always be live, since it is
2212 // cleared whenever a process dies.
2213 CHECK(pending_render_frame_host_->IsRenderFrameLive());
nasko 2016/08/09 18:32:32 Should this be CHECK or DCHECK?
alexmos 2016/08/09 23:09:46 It'd be safer with a DCHECK, but I was thinking th
nasko 2016/08/09 23:49:15 Acknowledged.
2214 }
2215 }
2199 2216
2200 if (new_instance.get() != current_instance) { 2217 if (new_instance.get() != current_instance) {
2201 TRACE_EVENT_INSTANT2( 2218 TRACE_EVENT_INSTANT2(
2202 "navigation", 2219 "navigation",
2203 "RenderFrameHostManager::UpdateStateForNavigate:New SiteInstance", 2220 "RenderFrameHostManager::UpdateStateForNavigate:New SiteInstance",
2204 TRACE_EVENT_SCOPE_THREAD, 2221 TRACE_EVENT_SCOPE_THREAD,
2205 "current_instance id", current_instance->GetId(), 2222 "current_instance id", current_instance->GetId(),
2206 "new_instance id", new_instance->GetId()); 2223 "new_instance id", new_instance->GetId());
2207 2224
2208 // New SiteInstance: create a pending RFH to navigate. 2225 // New SiteInstance: create a pending RFH to navigate.
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
2605 resolved_url)) { 2622 resolved_url)) {
2606 DCHECK(!dest_instance || 2623 DCHECK(!dest_instance ||
2607 dest_instance == render_frame_host_->GetSiteInstance()); 2624 dest_instance == render_frame_host_->GetSiteInstance());
2608 return false; 2625 return false;
2609 } 2626 }
2610 2627
2611 return true; 2628 return true;
2612 } 2629 }
2613 2630
2614 } // namespace content 2631 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698