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

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

Issue 525583002: Fix RenderFrameHost lifetime and clean up CommitPending. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up Created 6 years, 2 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 <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 begin_navigation_params.load_flags = 83 begin_navigation_params.load_flags =
84 LoadFlagFromNavigationType(navigation_type); 84 LoadFlagFromNavigationType(navigation_type);
85 85
86 // TODO(clamy): Post data from the browser should be put in the request body. 86 // TODO(clamy): Post data from the browser should be put in the request body.
87 // Headers should be filled in as well. 87 // Headers should be filled in as well.
88 88
89 begin_navigation_params.has_user_gesture = false; 89 begin_navigation_params.has_user_gesture = false;
90 return begin_navigation_params; 90 return begin_navigation_params;
91 } 91 }
92 92
93 // static
93 bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) { 94 bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) {
94 node->render_manager()->pending_delete_hosts_.clear(); 95 node->render_manager()->pending_delete_hosts_.clear();
95 return true; 96 return true;
96 } 97 }
97 98
98 RenderFrameHostManager::RenderFrameHostManager( 99 RenderFrameHostManager::RenderFrameHostManager(
99 FrameTreeNode* frame_tree_node, 100 FrameTreeNode* frame_tree_node,
100 RenderFrameHostDelegate* render_frame_delegate, 101 RenderFrameHostDelegate* render_frame_delegate,
101 RenderViewHostDelegate* render_view_delegate, 102 RenderViewHostDelegate* render_view_delegate,
102 RenderWidgetHostDelegate* render_widget_delegate, 103 RenderWidgetHostDelegate* render_widget_delegate,
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 } 520 }
520 521
521 // Now delete them. 522 // Now delete them.
522 while (!ids_to_remove.empty()) { 523 while (!ids_to_remove.empty()) {
523 delete proxy_hosts_[ids_to_remove.back()]; 524 delete proxy_hosts_[ids_to_remove.back()];
524 proxy_hosts_.erase(ids_to_remove.back()); 525 proxy_hosts_.erase(ids_to_remove.back());
525 ids_to_remove.pop_back(); 526 ids_to_remove.pop_back();
526 } 527 }
527 } 528 }
528 529
529 void RenderFrameHostManager::SwapOutOldPage( 530 void RenderFrameHostManager::SwapOutOldFrame(
530 RenderFrameHostImpl* old_render_frame_host) { 531 scoped_ptr<RenderFrameHostImpl> old_render_frame_host) {
nasko 2014/10/02 16:04:02 I love that we are using scoped_ptrs more now. It
531 TRACE_EVENT1("navigation", "RenderFrameHostManager::SwapOutOldPage", 532 TRACE_EVENT1("navigation", "RenderFrameHostManager::SwapOutOldFrame",
532 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); 533 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id());
533 // Should only see this while we have a pending renderer.
534 CHECK(cross_navigation_pending_);
535 534
536 // Tell the renderer to suppress any further modal dialogs so that we can swap 535 // Tell the renderer to suppress any further modal dialogs so that we can swap
537 // it out. This must be done before canceling any current dialog, in case 536 // it out. This must be done before canceling any current dialog, in case
538 // there is a loop creating additional dialogs. 537 // there is a loop creating additional dialogs.
539 // TODO(creis): Handle modal dialogs in subframe processes. 538 // TODO(creis): Handle modal dialogs in subframe processes.
540 old_render_frame_host->render_view_host()->SuppressDialogsUntilSwapOut(); 539 old_render_frame_host->render_view_host()->SuppressDialogsUntilSwapOut();
541 540
542 // Now close any modal dialogs that would prevent us from swapping out. This 541 // Now close any modal dialogs that would prevent us from swapping out. This
543 // must be done separately from SwapOut, so that the PageGroupLoadDeferrer is 542 // must be done separately from SwapOut, so that the PageGroupLoadDeferrer is
544 // no longer on the stack when we send the SwapOut message. 543 // no longer on the stack when we send the SwapOut message.
545 delegate_->CancelModalDialogsForRenderManager(); 544 delegate_->CancelModalDialogsForRenderManager();
546 545
547 // Create the RenderFrameProxyHost that will replace the 546 // If the old RFH is not live, just return as there is no further work to do.
548 // RenderFrameHost which is swapping out. If one exists, ensure it is deleted 547 // It will be deleted and there will be no proxy created.
549 // from the map and not leaked. 548 int32 old_site_instance_id =
550 DeleteRenderFrameProxyHost(old_render_frame_host->GetSiteInstance()); 549 old_render_frame_host->GetSiteInstance()->GetId();
550 if (!old_render_frame_host->IsRenderFrameLive()) {
551 ShutdownRenderFrameProxyHostsInSiteInstance(old_site_instance_id);
552 return;
553 }
551 554
555 // If there are no active frames besides this one, we can delete the old
556 // RenderFrameHost once it runs its unload handler, without replacing it with
557 // a proxy.
558 size_t active_frame_count =
559 old_render_frame_host->GetSiteInstance()->active_frame_count();
560 if (active_frame_count <= 1) {
561 // Tell the old RenderFrameHost to swap out, with no proxy to replace it.
562 old_render_frame_host->SwapOut(NULL);
563 MoveToPendingDeleteHosts(old_render_frame_host.Pass());
564
565 // Also clear out any proxies from this SiteInstance, in case this was the
566 // last one keeping other proxies alive.
567 ShutdownRenderFrameProxyHostsInSiteInstance(old_site_instance_id);
568
569 return;
570 }
571
572 // Otherwise there are active views and we need a proxy for the old RFH.
573 // (There should not be one yet.)
574 CHECK(!GetRenderFrameProxyHost(old_render_frame_host->GetSiteInstance()));
552 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( 575 RenderFrameProxyHost* proxy = new RenderFrameProxyHost(
553 old_render_frame_host->GetSiteInstance(), frame_tree_node_); 576 old_render_frame_host->GetSiteInstance(), frame_tree_node_);
554 std::pair<RenderFrameProxyHostMap::iterator, bool> result = 577 CHECK(proxy_hosts_.insert(std::make_pair(old_site_instance_id, proxy)).second)
555 proxy_hosts_.insert(std::make_pair( 578 << "Inserting a duplicate item.";
556 old_render_frame_host->GetSiteInstance()->GetId(), proxy));
557 CHECK(result.second) << "Inserting a duplicate item.";
558 579
559 // Tell the old frame it is being swapped out. This will fire the unload 580 // Tell the old RenderFrameHost to swap out and be replaced by the proxy.
560 // handler in the background (without firing the beforeunload handler a second
561 // time). This is done right after we commit the new RenderFrameHost.
562 old_render_frame_host->SwapOut(proxy); 581 old_render_frame_host->SwapOut(proxy);
582
583 bool is_main_frame = frame_tree_node_->IsMainFrame();
584 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess) &&
585 !is_main_frame) {
586 // In --site-per-process, subframes delete their RFH rather than storing it
587 // in the proxy. Schedule it for deletion once the SwapOutACK comes in.
588 // TODO(creis): This will be the default when we remove swappedout://.
589 MoveToPendingDeleteHosts(old_render_frame_host.Pass());
590 } else {
591 // We shouldn't get here for subframes, since we only swap subframes when
592 // --site-per-process is used.
593 DCHECK(is_main_frame);
594
595 // The old RenderFrameHost will stay alive inside the proxy so that existing
596 // JavaScript window references to it stay valid.
597 proxy->TakeFrameHostOwnership(old_render_frame_host.Pass());
598 }
563 } 599 }
564 600
565 void RenderFrameHostManager::ClearPendingShutdownRFHForSiteInstance( 601 void RenderFrameHostManager::MoveToPendingDeleteHosts(
566 int32 site_instance_id, 602 scoped_ptr<RenderFrameHostImpl> render_frame_host) {
567 RenderFrameHostImpl* rfh) { 603 // |render_frame_host| will be deleted when its SwapOut ACK is received, or
568 RFHPendingDeleteMap::iterator iter = 604 // when the timer times out, or when the RFHM itself is deleted (whichever
569 pending_delete_hosts_.find(site_instance_id); 605 // comes first).
570 if (iter != pending_delete_hosts_.end() && iter->second.get() == rfh) 606 pending_delete_hosts_.push_back(
571 pending_delete_hosts_.erase(site_instance_id); 607 linked_ptr<RenderFrameHostImpl>(render_frame_host.release()));
608 }
609
610 bool RenderFrameHostManager::IsPendingDeletion(
611 RenderFrameHostImpl* render_frame_host) {
612 for (const auto& rfh : pending_delete_hosts_) {
613 if (rfh == render_frame_host)
614 return true;
615 }
616 return false;
617 }
618
619 bool RenderFrameHostManager::DeleteFromPendingList(
620 RenderFrameHostImpl* render_frame_host) {
621 for (RFHPendingDeleteList::iterator iter = pending_delete_hosts_.begin();
622 iter != pending_delete_hosts_.end();
623 iter++) {
624 if (*iter == render_frame_host) {
625 pending_delete_hosts_.erase(iter);
626 return true;
627 }
628 }
629 return false;
572 } 630 }
573 631
574 void RenderFrameHostManager::ResetProxyHosts() { 632 void RenderFrameHostManager::ResetProxyHosts() {
575 STLDeleteValues(&proxy_hosts_); 633 STLDeleteValues(&proxy_hosts_);
576 } 634 }
577 635
578 // PlzNavigate 636 // PlzNavigate
579 bool RenderFrameHostManager::RequestNavigation( 637 bool RenderFrameHostManager::RequestNavigation(
580 scoped_ptr<NavigationRequest> navigation_request, 638 scoped_ptr<NavigationRequest> navigation_request,
581 const RequestNavigationParams& request_params) { 639 const RequestNavigationParams& request_params) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 case NOTIFICATION_RENDERER_PROCESS_CLOSING: 760 case NOTIFICATION_RENDERER_PROCESS_CLOSING:
703 RendererProcessClosing( 761 RendererProcessClosing(
704 Source<RenderProcessHost>(source).ptr()); 762 Source<RenderProcessHost>(source).ptr());
705 break; 763 break;
706 764
707 default: 765 default:
708 NOTREACHED(); 766 NOTREACHED();
709 } 767 }
710 } 768 }
711 769
770 // static
712 bool RenderFrameHostManager::ClearProxiesInSiteInstance( 771 bool RenderFrameHostManager::ClearProxiesInSiteInstance(
713 int32 site_instance_id, 772 int32 site_instance_id,
714 FrameTreeNode* node) { 773 FrameTreeNode* node) {
715 RenderFrameProxyHostMap::iterator iter = 774 RenderFrameProxyHostMap::iterator iter =
716 node->render_manager()->proxy_hosts_.find(site_instance_id); 775 node->render_manager()->proxy_hosts_.find(site_instance_id);
717 if (iter != node->render_manager()->proxy_hosts_.end()) { 776 if (iter != node->render_manager()->proxy_hosts_.end()) {
718 RenderFrameProxyHost* proxy = iter->second; 777 RenderFrameProxyHost* proxy = iter->second;
719 // If the RVH is pending swap out, it needs to switch state to 778 // Delete the proxy. If it is for a main frame (and thus the RFH is stored
720 // pending shutdown. Otherwise it is deleted. 779 // in the proxy) and it was still pending swap out, move the RFH to the
721 if (proxy->render_frame_host()->rfh_state() == 780 // pending deletion list first.
781 if (node->IsMainFrame() &&
782 proxy->render_frame_host()->rfh_state() ==
722 RenderFrameHostImpl::STATE_PENDING_SWAP_OUT) { 783 RenderFrameHostImpl::STATE_PENDING_SWAP_OUT) {
723 scoped_ptr<RenderFrameHostImpl> swapped_out_rfh = 784 scoped_ptr<RenderFrameHostImpl> swapped_out_rfh =
724 proxy->PassFrameHostOwnership(); 785 proxy->PassFrameHostOwnership();
725 786 node->render_manager()->MoveToPendingDeleteHosts(swapped_out_rfh.Pass());
726 swapped_out_rfh->SetPendingShutdown(base::Bind(
727 &RenderFrameHostManager::ClearPendingShutdownRFHForSiteInstance,
728 node->render_manager()->weak_factory_.GetWeakPtr(),
729 site_instance_id,
730 swapped_out_rfh.get()));
731 RFHPendingDeleteMap::iterator pending_delete_iter =
732 node->render_manager()->pending_delete_hosts_.find(site_instance_id);
733 if (pending_delete_iter ==
734 node->render_manager()->pending_delete_hosts_.end() ||
735 pending_delete_iter->second.get() != swapped_out_rfh) {
736 node->render_manager()->pending_delete_hosts_[site_instance_id] =
737 linked_ptr<RenderFrameHostImpl>(swapped_out_rfh.release());
738 }
739 } 787 }
740 delete proxy; 788 delete proxy;
741 node->render_manager()->proxy_hosts_.erase(site_instance_id); 789 node->render_manager()->proxy_hosts_.erase(site_instance_id);
742 } 790 }
743 791
744 return true; 792 return true;
745 } 793 }
746 794
747 bool RenderFrameHostManager::ShouldTransitionCrossSite() { 795 bool RenderFrameHostManager::ShouldTransitionCrossSite() {
748 // False in the single-process mode, as it makes RVHs to accumulate 796 // False in the single-process mode, as it makes RVHs to accumulate
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 delegate_->SetFocusToLocationBar(false); 1370 delegate_->SetFocusToLocationBar(false);
1323 return; 1371 return;
1324 } 1372 }
1325 1373
1326 // Remember if the page was focused so we can focus the new renderer in 1374 // Remember if the page was focused so we can focus the new renderer in
1327 // that case. 1375 // that case.
1328 bool focus_render_view = !will_focus_location_bar && 1376 bool focus_render_view = !will_focus_location_bar &&
1329 render_frame_host_->render_view_host()->GetView() && 1377 render_frame_host_->render_view_host()->GetView() &&
1330 render_frame_host_->render_view_host()->GetView()->HasFocus(); 1378 render_frame_host_->render_view_host()->GetView()->HasFocus();
1331 1379
1332 // TODO(creis): As long as show/hide are on RVH, we don't want to do them for
1333 // subframe navigations or they'll interfere with the top-level page.
1334 bool is_main_frame = frame_tree_node_->IsMainFrame(); 1380 bool is_main_frame = frame_tree_node_->IsMainFrame();
1335 1381
1336 // Swap in the pending frame and make it active. Also ensure the FrameTree 1382 // Swap in the pending frame and make it active. Also ensure the FrameTree
1337 // stays in sync. 1383 // stays in sync.
1338 scoped_ptr<RenderFrameHostImpl> old_render_frame_host = 1384 scoped_ptr<RenderFrameHostImpl> old_render_frame_host =
1339 SetRenderFrameHost(pending_render_frame_host_.Pass()); 1385 SetRenderFrameHost(pending_render_frame_host_.Pass());
1340 if (is_main_frame) 1386 if (is_main_frame)
1341 render_frame_host_->render_view_host()->AttachToFrameTree(); 1387 render_frame_host_->render_view_host()->AttachToFrameTree();
1342 1388
1343 // The process will no longer try to exit, so we can decrement the count. 1389 // The process will no longer try to exit, so we can decrement the count.
1344 render_frame_host_->GetProcess()->RemovePendingView(); 1390 render_frame_host_->GetProcess()->RemovePendingView();
1345 1391
1346 // If the view is gone, then this RenderViewHost died while it was hidden. 1392 // Show the new view (or a sad tab) if necessary.
1347 // We ignored the RenderProcessGone call at the time, so we should send it now 1393 bool new_rfh_has_view = !!render_frame_host_->render_view_host()->GetView();
1348 // to make sure the sad tab shows up, etc. 1394 if (!delegate_->IsHidden() && new_rfh_has_view) {
1349 if (!render_frame_host_->render_view_host()->GetView()) { 1395 // In most cases, we need to show the new view.
1396 render_frame_host_->render_view_host()->GetView()->Show();
1397 }
1398 if (!new_rfh_has_view) {
1399 // If the view is gone, then this RenderViewHost died while it was hidden.
1400 // We ignored the RenderProcessGone call at the time, so we should send it
1401 // now to make sure the sad tab shows up, etc.
1402 DCHECK(!render_frame_host_->IsRenderFrameLive());
1403 DCHECK(!render_frame_host_->render_view_host()->IsRenderViewLive());
1350 delegate_->RenderProcessGoneFromRenderManager( 1404 delegate_->RenderProcessGoneFromRenderManager(
1351 render_frame_host_->render_view_host()); 1405 render_frame_host_->render_view_host());
1352 } else if (!delegate_->IsHidden()) {
1353 render_frame_host_->render_view_host()->GetView()->Show();
1354 }
1355
1356 // If the old frame is live, swap it out now that the new frame is visible.
1357 int32 old_site_instance_id =
1358 old_render_frame_host->GetSiteInstance()->GetId();
1359 if (old_render_frame_host->IsRenderFrameLive()) {
1360 SwapOutOldPage(old_render_frame_host.get());
1361
1362 // Schedule the old frame to shut down after it swaps out, if there are no
1363 // other active frames in its SiteInstance.
1364 if (!old_render_frame_host->GetSiteInstance()->active_frame_count()) {
1365 old_render_frame_host->SetPendingShutdown(base::Bind(
1366 &RenderFrameHostManager::ClearPendingShutdownRFHForSiteInstance,
1367 weak_factory_.GetWeakPtr(),
1368 old_site_instance_id,
1369 old_render_frame_host.get()));
1370 }
1371 } 1406 }
1372 1407
1373 // For top-level frames, also hide the old RenderViewHost's view. 1408 // For top-level frames, also hide the old RenderViewHost's view.
1409 // TODO(creis): As long as show/hide are on RVH, we don't want to hide on
1410 // subframe navigations or we will interfere with the top-level frame.
1374 if (is_main_frame && old_render_frame_host->render_view_host()->GetView()) 1411 if (is_main_frame && old_render_frame_host->render_view_host()->GetView())
1375 old_render_frame_host->render_view_host()->GetView()->Hide(); 1412 old_render_frame_host->render_view_host()->GetView()->Hide();
1376 1413
1377 // Make sure the size is up to date. (Fix for bug 1079768.) 1414 // Make sure the size is up to date. (Fix for bug 1079768.)
1378 delegate_->UpdateRenderViewSizeForRenderManager(); 1415 delegate_->UpdateRenderViewSizeForRenderManager();
1379 1416
1380 if (will_focus_location_bar) { 1417 if (will_focus_location_bar) {
1381 delegate_->SetFocusToLocationBar(false); 1418 delegate_->SetFocusToLocationBar(false);
1382 } else if (focus_render_view && 1419 } else if (focus_render_view &&
1383 render_frame_host_->render_view_host()->GetView()) { 1420 render_frame_host_->render_view_host()->GetView()) {
1384 render_frame_host_->render_view_host()->GetView()->Focus(); 1421 render_frame_host_->render_view_host()->GetView()->Focus();
1385 } 1422 }
1386 1423
1387 // Notify that we've swapped RenderFrameHosts. We do this before shutting down 1424 // Notify that we've swapped RenderFrameHosts. We do this before shutting down
1388 // the RFH so that we can clean up RendererResources related to the RFH first. 1425 // the RFH so that we can clean up RendererResources related to the RFH first.
1389 delegate_->NotifySwappedFromRenderManager( 1426 delegate_->NotifySwappedFromRenderManager(
1390 old_render_frame_host.get(), render_frame_host_.get(), is_main_frame); 1427 old_render_frame_host.get(), render_frame_host_.get(), is_main_frame);
1391 1428
1392 // If the old RFH is not live, just return as there is no further work to do. 1429 // Swap out the old frame now that the new one is visible.
1393 if (!old_render_frame_host->IsRenderFrameLive()) 1430 // This will swap it out and then put it on the proxy list (if there are other
1394 return; 1431 // active views in its SiteInstance) or schedule it for deletion when the swap
1395 1432 // out ack arrives (or immediately if the process isn't live).
1396 // If the old RFH is live, we are swapping it out and should keep track of 1433 // In the --site-per-process case, old subframe RHFs are not kept alive inside
1397 // it in case we navigate back to it, or it is waiting for the unload event 1434 // the proxy.
1398 // to execute in the background. 1435 SwapOutOldFrame(old_render_frame_host.Pass());
1399 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) {
1400 DCHECK(old_render_frame_host->is_swapped_out() ||
1401 !RenderFrameHostImpl::IsRFHStateActive(
1402 old_render_frame_host->rfh_state()));
1403 }
1404
1405 // If the RenderViewHost backing the RenderFrameHost is pending shutdown,
1406 // the RenderFrameHost should be put in the map of RenderFrameHosts pending
1407 // shutdown. Otherwise, it is stored in the map of proxy hosts.
1408 if (old_render_frame_host->rfh_state() ==
1409 RenderFrameHostImpl::STATE_PENDING_SHUTDOWN) {
1410 // The proxy for this RenderFrameHost is created when sending the
1411 // SwapOut message, so check if it already exists and delete it.
1412 RenderFrameProxyHostMap::iterator iter =
1413 proxy_hosts_.find(old_site_instance_id);
1414 if (iter != proxy_hosts_.end()) {
1415 delete iter->second;
1416 proxy_hosts_.erase(iter);
1417 }
1418 RFHPendingDeleteMap::iterator pending_delete_iter =
1419 pending_delete_hosts_.find(old_site_instance_id);
1420 if (pending_delete_iter == pending_delete_hosts_.end() ||
1421 pending_delete_iter->second.get() != old_render_frame_host) {
1422 pending_delete_hosts_[old_site_instance_id] =
1423 linked_ptr<RenderFrameHostImpl>(old_render_frame_host.release());
1424 }
1425 } else {
1426 CHECK(proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()) ==
1427 proxy_hosts_.end());
1428
1429 // Capture the active frame count on the old RFH SiteInstance, since the
1430 // ownership might be passed into the proxy and the pointer will be
1431 // invalid.
1432 int active_frame_count =
1433 old_render_frame_host->GetSiteInstance()->active_frame_count();
1434
1435 if (is_main_frame) {
1436 RenderFrameProxyHostMap::iterator iter =
1437 proxy_hosts_.find(old_site_instance_id);
1438 CHECK(iter != proxy_hosts_.end());
1439 iter->second->TakeFrameHostOwnership(old_render_frame_host.Pass());
1440 }
1441
1442 // If there are no active frames in this SiteInstance, it means that
1443 // this RFH was the last active one in the SiteInstance. Now that we
1444 // know that all RFHs are swapped out, we can delete all the RFPHs and
1445 // RVHs in this SiteInstance.
1446 if (!active_frame_count) {
1447 ShutdownRenderFrameProxyHostsInSiteInstance(old_site_instance_id);
1448 }
1449 }
1450 1436
1451 // If this is a subframe, it should have a CrossProcessFrameConnector 1437 // If this is a subframe, it should have a CrossProcessFrameConnector
1452 // created already and we just need to link it to the proper view in the 1438 // created already. Use it to link the new RFH's view to the proxy that
1453 // new process. 1439 // belongs to the parent frame's SiteInstance. (We do this after swapping out
nasko 2014/10/02 16:04:02 nit: I'd put the sentence in () on a new line star
Charlie Reis 2014/10/02 19:41:19 Done.
1454 if (!is_main_frame) { 1440 // the old RFH because that may create the proxy we're looking for.)
1455 RenderFrameProxyHost* proxy = GetProxyToParent(); 1441 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess) &&
1456 if (proxy) { 1442 !is_main_frame) {
1457 proxy->SetChildRWHView( 1443 RenderFrameProxyHost* proxy_to_parent = GetProxyToParent();
1444 if (proxy_to_parent) {
1445 proxy_to_parent->SetChildRWHView(
1458 render_frame_host_->render_view_host()->GetView()); 1446 render_frame_host_->render_view_host()->GetView());
1459 } 1447 }
1460 } 1448 }
1461 } 1449 }
1462 1450
1463 void RenderFrameHostManager::ShutdownRenderFrameProxyHostsInSiteInstance( 1451 void RenderFrameHostManager::ShutdownRenderFrameProxyHostsInSiteInstance(
1464 int32 site_instance_id) { 1452 int32 site_instance_id) {
1465 // First remove any swapped out RFH for this SiteInstance from our own list. 1453 // First remove any swapped out RFH for this SiteInstance from our own list.
1466 ClearProxiesInSiteInstance(site_instance_id, frame_tree_node_); 1454 ClearProxiesInSiteInstance(site_instance_id, frame_tree_node_);
1467 1455
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 void RenderFrameHostManager::DeleteRenderFrameProxyHost( 1725 void RenderFrameHostManager::DeleteRenderFrameProxyHost(
1738 SiteInstance* instance) { 1726 SiteInstance* instance) {
1739 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); 1727 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId());
1740 if (iter != proxy_hosts_.end()) { 1728 if (iter != proxy_hosts_.end()) {
1741 delete iter->second; 1729 delete iter->second;
1742 proxy_hosts_.erase(iter); 1730 proxy_hosts_.erase(iter);
1743 } 1731 }
1744 } 1732 }
1745 1733
1746 } // namespace content 1734 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698