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

Side by Side 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: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) 355 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++)
356 g_created_callbacks.Get().at(i).Run(this); 356 g_created_callbacks.Get().at(i).Run(this);
357 frame_tree_.SetFrameRemoveListener( 357 frame_tree_.SetFrameRemoveListener(
358 base::Bind(&WebContentsImpl::OnFrameRemoved, 358 base::Bind(&WebContentsImpl::OnFrameRemoved,
359 base::Unretained(this))); 359 base::Unretained(this)));
360 } 360 }
361 361
362 WebContentsImpl::~WebContentsImpl() { 362 WebContentsImpl::~WebContentsImpl() {
363 is_being_destroyed_ = true; 363 is_being_destroyed_ = true;
364 364
365 // Update SiteInstance reference counts.
366 if (GetSiteInstance()) {
davidben 2014/04/29 21:31:40 Dropped the conditional here. RVHI::GetSiteInstanc
367 static_cast<SiteInstanceImpl*>(GetSiteInstance())->
368 DecrementRelatedActiveContentsCount();
369 }
370
365 // Delete all RFH pending shutdown, which will lead the corresponding RVH to 371 // Delete all RFH pending shutdown, which will lead the corresponding RVH to
366 // shutdown and be deleted as well. 372 // shutdown and be deleted as well.
367 frame_tree_.ForEach( 373 frame_tree_.ForEach(
368 base::Bind(&RenderFrameHostManager::ClearRFHsPendingShutdown)); 374 base::Bind(&RenderFrameHostManager::ClearRFHsPendingShutdown));
369 375
370 ClearAllPowerSaveBlockers(); 376 ClearAllPowerSaveBlockers();
371 377
372 for (std::set<RenderWidgetHostImpl*>::iterator iter = 378 for (std::set<RenderWidgetHostImpl*>::iterator iter =
373 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { 379 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) {
374 (*iter)->DetachDelegate(); 380 (*iter)->DetachDelegate();
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 void WebContentsImpl::Init(const WebContents::CreateParams& params) { 1068 void WebContentsImpl::Init(const WebContents::CreateParams& params) {
1063 // This is set before initializing the render manager since 1069 // This is set before initializing the render manager since
1064 // RenderFrameHostManager::Init calls back into us via its delegate to ask if 1070 // RenderFrameHostManager::Init calls back into us via its delegate to ask if
1065 // it should be hidden. 1071 // it should be hidden.
1066 should_normally_be_visible_ = !params.initially_hidden; 1072 should_normally_be_visible_ = !params.initially_hidden;
1067 1073
1068 GetRenderManager()->Init( 1074 GetRenderManager()->Init(
1069 params.browser_context, params.site_instance, params.routing_id, 1075 params.browser_context, params.site_instance, params.routing_id,
1070 params.main_frame_routing_id); 1076 params.main_frame_routing_id);
1071 1077
1078 // Update SiteInstance reference counts.
1079 static_cast<SiteInstanceImpl*>(GetSiteInstance())->
1080 IncrementRelatedActiveContentsCount();
Charlie Reis 2014/04/29 17:31:08 nit: Wrong indent.
davidben 2014/04/29 21:31:40 Done.
1081
1072 view_.reset(GetContentClient()->browser()-> 1082 view_.reset(GetContentClient()->browser()->
1073 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); 1083 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_));
1074 if (view_) { 1084 if (view_) {
1075 CHECK(render_view_host_delegate_view_); 1085 CHECK(render_view_host_delegate_view_);
1076 } else { 1086 } else {
1077 WebContentsViewDelegate* delegate = 1087 WebContentsViewDelegate* delegate =
1078 GetContentClient()->browser()->GetWebContentsViewDelegate(this); 1088 GetContentClient()->browser()->GetWebContentsViewDelegate(this);
1079 1089
1080 if (browser_plugin_guest_) { 1090 if (browser_plugin_guest_) {
1081 scoped_ptr<WebContentsViewPort> platform_view(CreateWebContentsView( 1091 scoped_ptr<WebContentsViewPort> platform_view(CreateWebContentsView(
(...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after
2965 NotificationService::current()->Notify( 2975 NotificationService::current()->Notify(
2966 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, 2976 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
2967 Source<WebContents>(this), 2977 Source<WebContents>(this),
2968 Details<std::pair<NavigationEntry*, bool> >(&details)); 2978 Details<std::pair<NavigationEntry*, bool> >(&details));
2969 2979
2970 return true; 2980 return true;
2971 } 2981 }
2972 2982
2973 void WebContentsImpl::NotifySwapped(RenderViewHost* old_host, 2983 void WebContentsImpl::NotifySwapped(RenderViewHost* old_host,
2974 RenderViewHost* new_host) { 2984 RenderViewHost* new_host) {
2985 if (old_host) {
2986 // Update BrowsingInstance active contents counts. If |old_host| is NULL,
2987 // this is a "swap" for a crashed RVH and shouldn't be counted. This should
2988 // be a no-op unless this contents swapped browsing instances due to WebUI
2989 // or so.
2990 static_cast<SiteInstanceImpl*>(new_host->GetSiteInstance())->
2991 IncrementRelatedActiveContentsCount();
2992 static_cast<SiteInstanceImpl*>(old_host->GetSiteInstance())->
2993 DecrementRelatedActiveContentsCount();
2994 }
2995
2975 // After sending out a swap notification, we need to send a disconnect 2996 // After sending out a swap notification, we need to send a disconnect
2976 // notification so that clients that pick up a pointer to |this| can NULL the 2997 // notification so that clients that pick up a pointer to |this| can NULL the
2977 // pointer. See Bug 1230284. 2998 // pointer. See Bug 1230284.
2978 notify_disconnection_ = true; 2999 notify_disconnection_ = true;
2979 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3000 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
2980 RenderViewHostChanged(old_host, new_host)); 3001 RenderViewHostChanged(old_host, new_host));
2981 3002
2982 // TODO(avi): Remove. http://crbug.com/170921 3003 // TODO(avi): Remove. http://crbug.com/170921
2983 std::pair<RenderViewHost*, RenderViewHost*> details = 3004 std::pair<RenderViewHost*, RenderViewHost*> details =
2984 std::make_pair(old_host, new_host); 3005 std::make_pair(old_host, new_host);
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
3893 3914
3894 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { 3915 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) {
3895 if (!delegate_) 3916 if (!delegate_)
3896 return; 3917 return;
3897 const gfx::Size new_size = GetPreferredSize(); 3918 const gfx::Size new_size = GetPreferredSize();
3898 if (new_size != old_size) 3919 if (new_size != old_size)
3899 delegate_->UpdatePreferredSize(this, new_size); 3920 delegate_->UpdatePreferredSize(this, new_size);
3900 } 3921 }
3901 3922
3902 } // namespace content 3923 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698