Chromium Code Reviews| Index: content/browser/web_contents/render_view_host_manager.cc |
| diff --git a/content/browser/web_contents/render_view_host_manager.cc b/content/browser/web_contents/render_view_host_manager.cc |
| index 62fec79d74de5e16ec285817f4bc86b6f9eb9689..92c7f3e8c565bfa474406ebb811ccd59ac8b4efb 100644 |
| --- a/content/browser/web_contents/render_view_host_manager.cc |
| +++ b/content/browser/web_contents/render_view_host_manager.cc |
| @@ -239,6 +239,26 @@ void RenderViewHostManager::DidNavigateMainFrame( |
| } |
| } |
| +void RenderViewHostManager::DidUpdateFrameTree( |
| + RenderViewHost* render_view_host) { |
| + DCHECK_EQ(render_view_host, current_host()); |
|
Charlie Reis
2012/08/22 22:08:34
Are there any races that could cause this to be ca
nasko
2012/08/23 21:55:53
Based on the cross-site transition timeline, it sh
|
| + |
| + RenderViewHostImpl* render_view_host_impl = static_cast<RenderViewHostImpl*>( |
| + render_view_host); |
| + |
| + for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin(); |
| + iter != swapped_out_hosts_.end(); |
| + ++iter) { |
| + DCHECK_NE(iter->second->GetSiteInstance(), |
| + current_host()->GetSiteInstance()); |
| + |
| + iter->second->UpdateFrameTree( |
| + render_view_host_impl->GetProcess()->GetID(), |
|
Charlie Reis
2012/08/22 22:08:34
Interesting... I wonder what happens if one of th
nasko
2012/08/23 21:55:53
GetProcess() returns the RenderProcessHost, which
Charlie Reis
2012/08/24 23:26:07
Ah, right you are! I was thinking of SiteInstance
|
| + render_view_host_impl->GetRoutingID(), |
| + render_view_host_impl->frame_tree()); |
| + } |
| +} |
| + |
| void RenderViewHostManager::SetWebUIPostCommit(WebUIImpl* web_ui) { |
| DCHECK(!web_ui_.get()); |
| web_ui_.reset(web_ui); |
| @@ -495,6 +515,15 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( |
| if (entry.IsViewSourceMode()) |
| return SiteInstance::CreateForURL(browser_context, dest_url); |
| + // If we are navigating from a blank SiteInstance to a WebUI, make sure we |
| + // create a new SiteInstance. |
|
Charlie Reis
2012/08/22 22:08:34
Wait, shouldn't HasWrongProcessForURL have caught
nasko
2012/08/23 21:55:53
The first thing HasWrongProcessForURL checks is wh
Charlie Reis
2012/08/24 23:26:07
:(
Good catch. This is fine, then, and I'll clea
|
| + const WebUIControllerFactory* web_ui_factory = |
| + content::GetContentClient()->browser()->GetWebUIControllerFactory(); |
| + if (web_ui_factory && |
| + web_ui_factory->UseWebUIForURL(browser_context, dest_url)) { |
| + return SiteInstance::CreateForURL(browser_context, dest_url); |
| + } |
| + |
| // Normally the "site" on the SiteInstance is set lazily when the load |
| // actually commits. This is to support better process sharing in case |
| // the site redirects to some other site: we want to use the destination |
| @@ -577,6 +606,16 @@ int RenderViewHostManager::CreateRenderView( |
| bool swapped_out) { |
| CHECK(instance); |
| + // If the current host is already in the site instance we are looking for |
|
Charlie Reis
2012/08/22 22:08:34
nit: site instance -> SiteInstance
nasko
2012/08/23 21:55:53
Done.
|
| + // and we are creating a swapped out renderer, just return the routing id. |
| + if (current_host()->GetSiteInstance() == instance) { |
| + // TODO(nasko): Convert this if statement to a DCHECK once all causes |
| + // of creating a new non-swapped out RVH for the same SiteInstance as the |
| + // active one are tracked down and resolved. |
|
Charlie Reis
2012/08/22 22:08:34
Nice. Please mention http://crbug.com/123007 here
nasko
2012/08/23 21:55:53
Done.
|
| + if (swapped_out) |
|
Charlie Reis
2012/08/22 22:08:34
This is actually a little confusing. The caller i
nasko
2012/08/23 21:55:53
Yes, changing the caller makes a bit more sense. I
Charlie Reis
2012/08/24 23:26:07
Great. Please CC me on the bug.
|
| + return current_host()->GetRoutingID(); |
| + } |
| + |
| // Check if we've already created an RVH for this SiteInstance. If so, try |
| // to re-use the existing one, which has already been initialized. We'll |
| // remove it from the list of swapped out hosts if it commits. |
| @@ -607,6 +646,15 @@ int RenderViewHostManager::CreateRenderView( |
| if (success) { |
| // Don't show the view until we get a DidNavigate from it. |
| new_render_view_host->GetView()->Hide(); |
| + |
| + // If we are creating a swapped out RVH, send a message to update the |
|
Charlie Reis
2012/08/22 22:08:34
nit: the -> its
nasko
2012/08/23 21:55:53
Done.
|
| + // frame tree based on the active RVH for this RenderViewHostManager. |
| + if (swapped_out) { |
| + new_render_view_host->UpdateFrameTree( |
| + current_host()->GetProcess()->GetID(), |
| + current_host()->GetRoutingID(), |
| + current_host()->frame_tree()); |
| + } |
| } else if (!swapped_out) { |
| CancelPending(); |
| } |
| @@ -920,7 +968,7 @@ bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { |
| swapped_out_hosts_.end(); |
| } |
| -RenderViewHost* RenderViewHostManager::GetSwappedOutRenderViewHost( |
| +RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( |
| SiteInstance* instance) { |
| RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); |
| if (iter != swapped_out_hosts_.end()) |