| OLD | NEW |
| 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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 // or when the timer times out, or when the RFHM itself is deleted (whichever | 654 // or when the timer times out, or when the RFHM itself is deleted (whichever |
| 655 // comes first). | 655 // comes first). |
| 656 pending_delete_hosts_.push_back(std::move(old_render_frame_host)); | 656 pending_delete_hosts_.push_back(std::move(old_render_frame_host)); |
| 657 } | 657 } |
| 658 | 658 |
| 659 void RenderFrameHostManager::DiscardUnusedFrame( | 659 void RenderFrameHostManager::DiscardUnusedFrame( |
| 660 std::unique_ptr<RenderFrameHostImpl> render_frame_host) { | 660 std::unique_ptr<RenderFrameHostImpl> render_frame_host) { |
| 661 // TODO(carlosk): this code is very similar to what can be found in | 661 // TODO(carlosk): this code is very similar to what can be found in |
| 662 // SwapOutOldFrame and we should see that these are unified at some point. | 662 // SwapOutOldFrame and we should see that these are unified at some point. |
| 663 | 663 |
| 664 // If the SiteInstance for the pending RFH is being used by others don't | 664 // If the SiteInstance for the pending RFH is being used by others, ensure |
| 665 // delete the RFH. Just swap it out and it can be reused at a later point. | 665 // that it is replaced by a RenderFrameProxyHost to allow other frames to |
| 666 // In --site-per-process, RenderFrameHosts are not kept around and are | 666 // communicate to this frame. |
| 667 // deleted when not used, replaced by RenderFrameProxyHosts. | |
| 668 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); | 667 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); |
| 668 RenderViewHostImpl* rvh = render_frame_host->render_view_host(); |
| 669 RenderFrameProxyHost* proxy = nullptr; |
| 669 if (site_instance->HasSite() && site_instance->active_frame_count() > 1) { | 670 if (site_instance->HasSite() && site_instance->active_frame_count() > 1) { |
| 670 // Any currently suspended navigations are no longer needed. | 671 // Any currently suspended navigations are no longer needed. |
| 671 render_frame_host->CancelSuspendedNavigations(); | 672 render_frame_host->CancelSuspendedNavigations(); |
| 672 | 673 |
| 673 // If a proxy already exists for the |site_instance|, just reuse it instead | 674 // If a proxy already exists for the |site_instance|, just reuse it instead |
| 674 // of creating a new one. There is no need to call SwapOut on the | 675 // of creating a new one. There is no need to call SwapOut on the |
| 675 // |render_frame_host|, as this method is only called to discard a pending | 676 // |render_frame_host|, as this method is only called to discard a pending |
| 676 // or speculative RenderFrameHost, i.e. one that has never hosted an actual | 677 // or speculative RenderFrameHost, i.e. one that has never hosted an actual |
| 677 // document. | 678 // document. |
| 678 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(site_instance); | 679 proxy = GetRenderFrameProxyHost(site_instance); |
| 679 if (!proxy) { | 680 if (!proxy) |
| 680 proxy = CreateRenderFrameProxyHost(site_instance, | 681 proxy = CreateRenderFrameProxyHost(site_instance, rvh); |
| 681 render_frame_host->render_view_host()); | 682 } |
| 682 } | 683 |
| 684 // Doing this is important in the case where the replacement proxy is created |
| 685 // above, as the RenderViewHost will continue to exist and should be |
| 686 // considered swapped out if it is ever reused. When there's no replacement |
| 687 // proxy, this doesn't really matter, as the RenderViewHost will be destroyed |
| 688 // shortly, since |render_frame_host| is its last active frame and will be |
| 689 // deleted below. See https://crbug.com/627400. |
| 690 if (frame_tree_node_->IsMainFrame()) { |
| 691 rvh->set_main_frame_routing_id(MSG_ROUTING_NONE); |
| 692 rvh->set_is_active(false); |
| 693 rvh->set_is_swapped_out(true); |
| 683 } | 694 } |
| 684 | 695 |
| 685 render_frame_host.reset(); | 696 render_frame_host.reset(); |
| 697 |
| 698 // If a new RenderFrameProxyHost was created above, or if the old proxy isn't |
| 699 // live, create the RenderFrameProxy in the renderer, so that other frames |
| 700 // can still communicate with this frame. See https://crbug.com/653746. |
| 701 if (proxy && !proxy->is_render_frame_proxy_live()) |
| 702 proxy->InitRenderFrameProxy(); |
| 686 } | 703 } |
| 687 | 704 |
| 688 bool RenderFrameHostManager::DeleteFromPendingList( | 705 bool RenderFrameHostManager::DeleteFromPendingList( |
| 689 RenderFrameHostImpl* render_frame_host) { | 706 RenderFrameHostImpl* render_frame_host) { |
| 690 for (RFHPendingDeleteList::iterator iter = pending_delete_hosts_.begin(); | 707 for (RFHPendingDeleteList::iterator iter = pending_delete_hosts_.begin(); |
| 691 iter != pending_delete_hosts_.end(); | 708 iter != pending_delete_hosts_.end(); |
| 692 iter++) { | 709 iter++) { |
| 693 if (iter->get() == render_frame_host) { | 710 if (iter->get() == render_frame_host) { |
| 694 pending_delete_hosts_.erase(iter); | 711 pending_delete_hosts_.erase(iter); |
| 695 return true; | 712 return true; |
| (...skipping 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2699 resolved_url)) { | 2716 resolved_url)) { |
| 2700 DCHECK(!dest_instance || | 2717 DCHECK(!dest_instance || |
| 2701 dest_instance == render_frame_host_->GetSiteInstance()); | 2718 dest_instance == render_frame_host_->GetSiteInstance()); |
| 2702 return false; | 2719 return false; |
| 2703 } | 2720 } |
| 2704 | 2721 |
| 2705 return true; | 2722 return true; |
| 2706 } | 2723 } |
| 2707 | 2724 |
| 2708 } // namespace content | 2725 } // namespace content |
| OLD | NEW |