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

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 257083002: Check BrowsingInstance before swapping prerenders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: creis comments Created 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 8aea87eae6df3c70b7b21a7f1ec03a1e53a1b19d..26cf46323125033dc81f2055146575796f7ab019 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -363,6 +363,10 @@ WebContentsImpl::WebContentsImpl(
WebContentsImpl::~WebContentsImpl() {
is_being_destroyed_ = true;
+ // Update SiteInstance reference counts.
+ static_cast<SiteInstanceImpl*>(GetSiteInstance())->
+ DecrementRelatedActiveContentsCount();
+
// Delete all RFH pending shutdown, which will lead the corresponding RVH to
// shutdown and be deleted as well.
frame_tree_.ForEach(
@@ -1070,6 +1074,10 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
params.browser_context, params.site_instance, params.routing_id,
params.main_frame_routing_id);
+ // Update SiteInstance reference counts.
Charlie Reis 2014/04/29 22:13:51 It feels strange to do this in WebContents rather
davidben 2014/04/29 23:02:26 Moved it to RFHM. It's much much cleaner this way.
+ static_cast<SiteInstanceImpl*>(GetSiteInstance())->
+ IncrementRelatedActiveContentsCount();
+
view_.reset(GetContentClient()->browser()->
OverrideCreateWebContentsView(this, &render_view_host_delegate_view_));
if (view_) {
@@ -2981,6 +2989,17 @@ bool WebContentsImpl::UpdateTitleForEntry(NavigationEntryImpl* entry,
void WebContentsImpl::NotifySwapped(RenderViewHost* old_host,
RenderViewHost* new_host) {
+ if (old_host) {
+ // Update BrowsingInstance active contents counts. If |old_host| is NULL,
+ // this is a "swap" for a crashed RVH and shouldn't be counted. This should
+ // be a no-op unless this contents swapped browsing instances due to WebUI
+ // or so.
+ static_cast<SiteInstanceImpl*>(new_host->GetSiteInstance())->
+ IncrementRelatedActiveContentsCount();
+ static_cast<SiteInstanceImpl*>(old_host->GetSiteInstance())->
+ DecrementRelatedActiveContentsCount();
+ }
+
// After sending out a swap notification, we need to send a disconnect
// notification so that clients that pick up a pointer to |this| can NULL the
// pointer. See Bug 1230284.

Powered by Google App Engine
This is Rietveld 408576698