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

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

Issue 1074843002: Fix RenderFrameProxyHost leak. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lucasfix
Patch Set: Add comment suggested by Charlie Created 5 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
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/logging.h" 10 #include "base/logging.h"
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 ShutdownProxiesIfLastActiveFrameInSiteInstance(old_render_frame_host.get()); 601 ShutdownProxiesIfLastActiveFrameInSiteInstance(old_render_frame_host.get());
602 return; 602 return;
603 } 603 }
604 604
605 // If there are no active frames besides this one, we can delete the old 605 // If there are no active frames besides this one, we can delete the old
606 // RenderFrameHost once it runs its unload handler, without replacing it with 606 // RenderFrameHost once it runs its unload handler, without replacing it with
607 // a proxy. 607 // a proxy.
608 size_t active_frame_count = 608 size_t active_frame_count =
609 old_render_frame_host->GetSiteInstance()->active_frame_count(); 609 old_render_frame_host->GetSiteInstance()->active_frame_count();
610 if (active_frame_count <= 1) { 610 if (active_frame_count <= 1) {
611 // Clear out any proxies from this SiteInstance, in case this was the
612 // last one keeping other proxies alive.
613 ShutdownProxiesIfLastActiveFrameInSiteInstance(old_render_frame_host.get());
614
611 // Tell the old RenderFrameHost to swap out, with no proxy to replace it. 615 // Tell the old RenderFrameHost to swap out, with no proxy to replace it.
612 old_render_frame_host->SwapOut(NULL, true); 616 old_render_frame_host->SwapOut(NULL, true);
613 MoveToPendingDeleteHosts(old_render_frame_host.Pass()); 617 MoveToPendingDeleteHosts(old_render_frame_host.Pass());
614
615 // Also clear out any proxies from this SiteInstance, in case this was the
616 // last one keeping other proxies alive.
617 ShutdownProxiesIfLastActiveFrameInSiteInstance(old_render_frame_host.get());
618 return; 618 return;
619 } 619 }
620 620
621 // Otherwise there are active views and we need a proxy for the old RFH. 621 // Otherwise there are active views and we need a proxy for the old RFH.
622 // (There should not be one yet.) 622 // (There should not be one yet.)
623 CHECK(!GetRenderFrameProxyHost(old_render_frame_host->GetSiteInstance())); 623 CHECK(!GetRenderFrameProxyHost(old_render_frame_host->GetSiteInstance()));
624 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( 624 RenderFrameProxyHost* proxy = new RenderFrameProxyHost(
625 old_render_frame_host->GetSiteInstance(), frame_tree_node_); 625 old_render_frame_host->GetSiteInstance(), frame_tree_node_);
626 CHECK(proxy_hosts_.insert(std::make_pair(old_site_instance_id, proxy)).second) 626 CHECK(proxy_hosts_.insert(std::make_pair(old_site_instance_id, proxy)).second)
627 << "Inserting a duplicate item."; 627 << "Inserting a duplicate item.";
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after
2085 void RenderFrameHostManager::DeleteRenderFrameProxyHost( 2085 void RenderFrameHostManager::DeleteRenderFrameProxyHost(
2086 SiteInstance* instance) { 2086 SiteInstance* instance) {
2087 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); 2087 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId());
2088 if (iter != proxy_hosts_.end()) { 2088 if (iter != proxy_hosts_.end()) {
2089 delete iter->second; 2089 delete iter->second;
2090 proxy_hosts_.erase(iter); 2090 proxy_hosts_.erase(iter);
2091 } 2091 }
2092 } 2092 }
2093 2093
2094 } // namespace content 2094 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.h ('k') | content/browser/site_per_process_browsertest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698