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

Side by Side Diff: content/browser/web_contents/render_view_host_manager.cc

Issue 10827078: Support frame tree propagation between renderers in the same browsing instance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another round of fixes based on Charlie's review. Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/web_contents/render_view_host_manager.h" 5 #include "content/browser/web_contents/render_view_host_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // A navigation in the original page has taken place. Cancel the pending 232 // A navigation in the original page has taken place. Cancel the pending
233 // one. 233 // one.
234 CancelPending(); 234 CancelPending();
235 cross_navigation_pending_ = false; 235 cross_navigation_pending_ = false;
236 } else { 236 } else {
237 // No one else should be sending us DidNavigate in this state. 237 // No one else should be sending us DidNavigate in this state.
238 DCHECK(false); 238 DCHECK(false);
239 } 239 }
240 } 240 }
241 241
242 void RenderViewHostManager::DidUpdateFrameTree(
243 RenderViewHost* render_view_host) {
244 CHECK_EQ(render_view_host, current_host());
245
246 RenderViewHostImpl* render_view_host_impl = static_cast<RenderViewHostImpl*>(
247 render_view_host);
248
249 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin();
250 iter != swapped_out_hosts_.end();
251 ++iter) {
252 DCHECK_NE(iter->second->GetSiteInstance(),
253 current_host()->GetSiteInstance());
not at google - send to devlin 2012/08/30 05:01:41 This check seems to be flakily but consistently fa
254
255 iter->second->UpdateFrameTree(
256 render_view_host_impl->GetProcess()->GetID(),
257 render_view_host_impl->GetRoutingID(),
258 render_view_host_impl->frame_tree());
259 }
260 }
261
242 void RenderViewHostManager::SetWebUIPostCommit(WebUIImpl* web_ui) { 262 void RenderViewHostManager::SetWebUIPostCommit(WebUIImpl* web_ui) {
243 DCHECK(!web_ui_.get()); 263 DCHECK(!web_ui_.get());
244 web_ui_.reset(web_ui); 264 web_ui_.reset(web_ui);
245 } 265 }
246 266
247 void RenderViewHostManager::RendererAbortedProvisionalLoad( 267 void RenderViewHostManager::RendererAbortedProvisionalLoad(
248 RenderViewHost* render_view_host) { 268 RenderViewHost* render_view_host) {
249 // We used to cancel the pending renderer here for cross-site downloads. 269 // We used to cancel the pending renderer here for cross-site downloads.
250 // However, it's not safe to do that because the download logic repeatedly 270 // However, it's not safe to do that because the download logic repeatedly
251 // looks for this WebContents based on a render view ID. Instead, we just 271 // looks for this WebContents based on a render view ID. Instead, we just
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 if (curr_site_instance->HasWrongProcessForURL(dest_url)) 508 if (curr_site_instance->HasWrongProcessForURL(dest_url))
489 return curr_site_instance->GetRelatedSiteInstance(dest_url); 509 return curr_site_instance->GetRelatedSiteInstance(dest_url);
490 510
491 // View-source URLs must use a new SiteInstance and BrowsingInstance. 511 // View-source URLs must use a new SiteInstance and BrowsingInstance.
492 // TODO(nasko): This is the same condition as later in the function. This 512 // TODO(nasko): This is the same condition as later in the function. This
493 // should be taken into account when refactoring this method as part of 513 // should be taken into account when refactoring this method as part of
494 // http://crbug.com/123007. 514 // http://crbug.com/123007.
495 if (entry.IsViewSourceMode()) 515 if (entry.IsViewSourceMode())
496 return SiteInstance::CreateForURL(browser_context, dest_url); 516 return SiteInstance::CreateForURL(browser_context, dest_url);
497 517
518 // If we are navigating from a blank SiteInstance to a WebUI, make sure we
519 // create a new SiteInstance.
520 const WebUIControllerFactory* web_ui_factory =
521 content::GetContentClient()->browser()->GetWebUIControllerFactory();
522 if (web_ui_factory &&
523 web_ui_factory->UseWebUIForURL(browser_context, dest_url)) {
524 return SiteInstance::CreateForURL(browser_context, dest_url);
525 }
526
498 // Normally the "site" on the SiteInstance is set lazily when the load 527 // Normally the "site" on the SiteInstance is set lazily when the load
499 // actually commits. This is to support better process sharing in case 528 // actually commits. This is to support better process sharing in case
500 // the site redirects to some other site: we want to use the destination 529 // the site redirects to some other site: we want to use the destination
501 // site in the site instance. 530 // site in the site instance.
502 // 531 //
503 // In the case of session restore, as it loads all the pages immediately 532 // In the case of session restore, as it loads all the pages immediately
504 // we need to set the site first, otherwise after a restore none of the 533 // we need to set the site first, otherwise after a restore none of the
505 // pages would share renderers in process-per-site. 534 // pages would share renderers in process-per-site.
506 if (entry.restore_type() != NavigationEntryImpl::RESTORE_NONE) 535 if (entry.restore_type() != NavigationEntryImpl::RESTORE_NONE)
507 curr_site_instance->SetSite(dest_url); 536 curr_site_instance->SetSite(dest_url);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 if (swapped_out) { 629 if (swapped_out) {
601 swapped_out_hosts_[instance->GetId()] = new_render_view_host; 630 swapped_out_hosts_[instance->GetId()] = new_render_view_host;
602 } else { 631 } else {
603 new_render_view_host->GetProcess()->AddPendingView(); 632 new_render_view_host->GetProcess()->AddPendingView();
604 } 633 }
605 634
606 bool success = InitRenderView(new_render_view_host, opener_route_id); 635 bool success = InitRenderView(new_render_view_host, opener_route_id);
607 if (success) { 636 if (success) {
608 // Don't show the view until we get a DidNavigate from it. 637 // Don't show the view until we get a DidNavigate from it.
609 new_render_view_host->GetView()->Hide(); 638 new_render_view_host->GetView()->Hide();
639
640 // If we are creating a swapped out RVH, send a message to update its
641 // frame tree based on the active RVH for this RenderViewHostManager.
642 if (swapped_out) {
643 new_render_view_host->UpdateFrameTree(
644 current_host()->GetProcess()->GetID(),
645 current_host()->GetRoutingID(),
646 current_host()->frame_tree());
647 }
610 } else if (!swapped_out) { 648 } else if (!swapped_out) {
611 CancelPending(); 649 CancelPending();
612 } 650 }
613 } 651 }
614 652
615 // Use this as our new pending RVH if it isn't swapped out. 653 // Use this as our new pending RVH if it isn't swapped out.
616 if (!swapped_out) 654 if (!swapped_out)
617 pending_render_view_host_ = new_render_view_host; 655 pending_render_view_host_ = new_render_view_host;
618 656
619 return new_render_view_host->GetRoutingID(); 657 return new_render_view_host->GetRoutingID();
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 } 951 }
914 952
915 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { 953 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) {
916 if (!rvh->GetSiteInstance()) 954 if (!rvh->GetSiteInstance())
917 return false; 955 return false;
918 956
919 return swapped_out_hosts_.find(rvh->GetSiteInstance()->GetId()) != 957 return swapped_out_hosts_.find(rvh->GetSiteInstance()->GetId()) !=
920 swapped_out_hosts_.end(); 958 swapped_out_hosts_.end();
921 } 959 }
922 960
923 RenderViewHost* RenderViewHostManager::GetSwappedOutRenderViewHost( 961 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost(
924 SiteInstance* instance) { 962 SiteInstance* instance) {
925 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); 963 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId());
926 if (iter != swapped_out_hosts_.end()) 964 if (iter != swapped_out_hosts_.end())
927 return iter->second; 965 return iter->second;
928 966
929 return NULL; 967 return NULL;
930 } 968 }
OLDNEW
« no previous file with comments | « content/browser/web_contents/render_view_host_manager.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698