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

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

Issue 2410153005: Fix RenderView reuse issues when canceling a pending RenderFrameHost. (Closed)
Patch Set: Nits Created 4 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 void RenderFrameHostManager::DiscardUnusedFrame( 651 void RenderFrameHostManager::DiscardUnusedFrame(
652 std::unique_ptr<RenderFrameHostImpl> render_frame_host) { 652 std::unique_ptr<RenderFrameHostImpl> render_frame_host) {
653 // TODO(carlosk): this code is very similar to what can be found in 653 // TODO(carlosk): this code is very similar to what can be found in
654 // SwapOutOldFrame and we should see that these are unified at some point. 654 // SwapOutOldFrame and we should see that these are unified at some point.
655 655
656 // If the SiteInstance for the pending RFH is being used by others don't 656 // If the SiteInstance for the pending RFH is being used by others don't
657 // delete the RFH. Just swap it out and it can be reused at a later point. 657 // delete the RFH. Just swap it out and it can be reused at a later point.
658 // In --site-per-process, RenderFrameHosts are not kept around and are 658 // In --site-per-process, RenderFrameHosts are not kept around and are
659 // deleted when not used, replaced by RenderFrameProxyHosts. 659 // deleted when not used, replaced by RenderFrameProxyHosts.
660 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); 660 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance();
661 RenderViewHostImpl* rvh = render_frame_host->render_view_host();
662 RenderFrameProxyHost* proxy = nullptr;
661 if (site_instance->HasSite() && site_instance->active_frame_count() > 1) { 663 if (site_instance->HasSite() && site_instance->active_frame_count() > 1) {
662 // Any currently suspended navigations are no longer needed. 664 // Any currently suspended navigations are no longer needed.
663 render_frame_host->CancelSuspendedNavigations(); 665 render_frame_host->CancelSuspendedNavigations();
664 666
665 // If a proxy already exists for the |site_instance|, just reuse it instead 667 // If a proxy already exists for the |site_instance|, just reuse it instead
666 // of creating a new one. There is no need to call SwapOut on the 668 // of creating a new one. There is no need to call SwapOut on the
667 // |render_frame_host|, as this method is only called to discard a pending 669 // |render_frame_host|, as this method is only called to discard a pending
668 // or speculative RenderFrameHost, i.e. one that has never hosted an actual 670 // or speculative RenderFrameHost, i.e. one that has never hosted an actual
669 // document. 671 // document.
670 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(site_instance); 672 proxy = GetRenderFrameProxyHost(site_instance);
671 if (!proxy) { 673 if (!proxy)
672 proxy = CreateRenderFrameProxyHost(site_instance, 674 proxy = CreateRenderFrameProxyHost(site_instance, rvh);
673 render_frame_host->render_view_host()); 675 }
674 } 676
677 if (frame_tree_node_->IsMainFrame()) {
678 rvh->set_main_frame_routing_id(MSG_ROUTING_NONE);
679 rvh->set_is_active(false);
alexmos 2016/10/12 20:29:46 Doing this is important in the case where the repl
nasko 2016/10/13 21:26:28 Acknowledged.
Charlie Reis 2016/10/14 16:25:10 Could you add this as a comment in the code?
alexmos 2016/10/14 17:07:38 Done. I also updated the (stale) comment on top o
680 rvh->set_is_swapped_out(true);
675 } 681 }
676 682
677 render_frame_host.reset(); 683 render_frame_host.reset();
684
685 // If a new RenderFrameProxyHost was created above, or if the old proxy isn't
686 // live, create the RenderFrameProxy in the renderer, so that other frames
687 // can still communicate with this frame. See https://crbug.com/653746.
688 if (proxy && !proxy->is_render_frame_proxy_live())
689 proxy->InitRenderFrameProxy();
alexmos 2016/10/12 20:29:46 I think it makes more sense to initialize the prox
nasko 2016/10/13 21:26:28 Acknowledged.
678 } 690 }
679 691
680 bool RenderFrameHostManager::DeleteFromPendingList( 692 bool RenderFrameHostManager::DeleteFromPendingList(
681 RenderFrameHostImpl* render_frame_host) { 693 RenderFrameHostImpl* render_frame_host) {
682 for (RFHPendingDeleteList::iterator iter = pending_delete_hosts_.begin(); 694 for (RFHPendingDeleteList::iterator iter = pending_delete_hosts_.begin();
683 iter != pending_delete_hosts_.end(); 695 iter != pending_delete_hosts_.end();
684 iter++) { 696 iter++) {
685 if (iter->get() == render_frame_host) { 697 if (iter->get() == render_frame_host) {
686 pending_delete_hosts_.erase(iter); 698 pending_delete_hosts_.erase(iter);
687 return true; 699 return true;
(...skipping 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after
2691 resolved_url)) { 2703 resolved_url)) {
2692 DCHECK(!dest_instance || 2704 DCHECK(!dest_instance ||
2693 dest_instance == render_frame_host_->GetSiteInstance()); 2705 dest_instance == render_frame_host_->GetSiteInstance());
2694 return false; 2706 return false;
2695 } 2707 }
2696 2708
2697 return true; 2709 return true;
2698 } 2710 }
2699 2711
2700 } // namespace content 2712 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698