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

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

Issue 1894193002: Remove RenderFrameHostManager::MoveToPendingDeleteHosts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes based on review by alexmos@ Created 4 years, 8 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
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 // It will be deleted and there will be no proxy created. 646 // It will be deleted and there will be no proxy created.
647 if (!old_render_frame_host->IsRenderFrameLive()) 647 if (!old_render_frame_host->IsRenderFrameLive())
648 return; 648 return;
649 649
650 // If there are no active frames besides this one, we can delete the old 650 // If there are no active frames besides this one, we can delete the old
651 // RenderFrameHost once it runs its unload handler, without replacing it with 651 // RenderFrameHost once it runs its unload handler, without replacing it with
652 // a proxy. 652 // a proxy.
653 if (old_render_frame_host->GetSiteInstance()->active_frame_count() <= 1) { 653 if (old_render_frame_host->GetSiteInstance()->active_frame_count() <= 1) {
654 // Tell the old RenderFrameHost to swap out, with no proxy to replace it. 654 // Tell the old RenderFrameHost to swap out, with no proxy to replace it.
655 old_render_frame_host->SwapOut(nullptr, true); 655 old_render_frame_host->SwapOut(nullptr, true);
656 MoveToPendingDeleteHosts(std::move(old_render_frame_host)); 656 } else {
657 return; 657 // Otherwise there are active views and we need a proxy for the old RFH.
658 // (There should not be one yet.)
659 RenderFrameProxyHost* proxy =
660 CreateRenderFrameProxyHost(old_render_frame_host->GetSiteInstance(),
661 old_render_frame_host->render_view_host());
662
663 // Tell the old RenderFrameHost to swap out and be replaced by the proxy.
664 old_render_frame_host->SwapOut(proxy, true);
665
666 // SwapOut creates a RenderFrameProxy, so set the proxy to be initialized.
667 proxy->set_render_frame_proxy_created(true);
658 } 668 }
659 669
660 // Otherwise there are active views and we need a proxy for the old RFH. 670 // |old_render_frame_host| will be deleted when its SwapOut ACK is received,
661 // (There should not be one yet.) 671 // or when the timer times out, or when the RFHM itself is deleted (whichever
662 RenderFrameProxyHost* proxy = 672 // comes first).
663 CreateRenderFrameProxyHost(old_render_frame_host->GetSiteInstance(), 673 pending_delete_hosts_.push_back(std::move(old_render_frame_host));
664 old_render_frame_host->render_view_host());
665
666 // Tell the old RenderFrameHost to swap out and be replaced by the proxy.
667 old_render_frame_host->SwapOut(proxy, true);
668
669 // SwapOut creates a RenderFrameProxy, so set the proxy to be initialized.
670 proxy->set_render_frame_proxy_created(true);
671
672 MoveToPendingDeleteHosts(std::move(old_render_frame_host));
673 } 674 }
674 675
675 void RenderFrameHostManager::DiscardUnusedFrame( 676 void RenderFrameHostManager::DiscardUnusedFrame(
676 std::unique_ptr<RenderFrameHostImpl> render_frame_host) { 677 std::unique_ptr<RenderFrameHostImpl> render_frame_host) {
677 // TODO(carlosk): this code is very similar to what can be found in 678 // TODO(carlosk): this code is very similar to what can be found in
678 // SwapOutOldFrame and we should see that these are unified at some point. 679 // SwapOutOldFrame and we should see that these are unified at some point.
679 680
680 // If the SiteInstance for the pending RFH is being used by others don't 681 // If the SiteInstance for the pending RFH is being used by others don't
681 // delete the RFH. Just swap it out and it can be reused at a later point. 682 // delete the RFH. Just swap it out and it can be reused at a later point.
682 // In --site-per-process, RenderFrameHosts are not kept around and are 683 // In --site-per-process, RenderFrameHosts are not kept around and are
(...skipping 11 matching lines...) Expand all
694 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(site_instance); 695 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(site_instance);
695 if (!proxy) { 696 if (!proxy) {
696 proxy = CreateRenderFrameProxyHost(site_instance, 697 proxy = CreateRenderFrameProxyHost(site_instance,
697 render_frame_host->render_view_host()); 698 render_frame_host->render_view_host());
698 } 699 }
699 } 700 }
700 701
701 render_frame_host.reset(); 702 render_frame_host.reset();
702 } 703 }
703 704
704 void RenderFrameHostManager::MoveToPendingDeleteHosts(
705 std::unique_ptr<RenderFrameHostImpl> render_frame_host) {
706 // |render_frame_host| will be deleted when its SwapOut ACK is received, or
707 // when the timer times out, or when the RFHM itself is deleted (whichever
708 // comes first).
709 pending_delete_hosts_.push_back(std::move(render_frame_host));
710 }
711
712 bool RenderFrameHostManager::IsViewPendingDeletion( 705 bool RenderFrameHostManager::IsViewPendingDeletion(
713 RenderViewHostImpl* render_view_host) { 706 RenderViewHostImpl* render_view_host) {
714 // Only safe to call this on the main frame. 707 // Only safe to call this on the main frame.
715 CHECK(frame_tree_node_->IsMainFrame()); 708 CHECK(frame_tree_node_->IsMainFrame());
716 709
717 // The view is not pending deletion if more than one frame or proxy references 710 // The view is not pending deletion if more than one frame or proxy references
718 // it. 711 // it.
719 if (render_view_host->ref_count() > 1) 712 if (render_view_host->ref_count() > 1)
720 return false; 713 return false;
721 714
(...skipping 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after
2581 resolved_url)) { 2574 resolved_url)) {
2582 DCHECK(!dest_instance || 2575 DCHECK(!dest_instance ||
2583 dest_instance == render_frame_host_->GetSiteInstance()); 2576 dest_instance == render_frame_host_->GetSiteInstance());
2584 return false; 2577 return false;
2585 } 2578 }
2586 2579
2587 return true; 2580 return true;
2588 } 2581 }
2589 2582
2590 } // namespace content 2583 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698