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

Unified Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 536063002: Clean up RenderWidgetHostView destruction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Safer scheme Created 6 years, 3 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/renderer_host/render_widget_host_impl.cc
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index 0de4c1ccee5673c27c9c669932b0a384c714e02b..fc220083e99e1df85ec4f66be423fb181f433704 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -235,7 +235,10 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
}
RenderWidgetHostImpl::~RenderWidgetHostImpl() {
- SetView(NULL);
+ if (view_) {
+ view_->Destroy();
+ DCHECK(!view_);
+ }
GpuSurfaceTracker::Get()->RemoveSurface(surface_id_);
surface_id_ = 0;
@@ -310,6 +313,7 @@ RenderWidgetHostImpl* RenderWidgetHostImpl::From(RenderWidgetHost* rwh) {
}
void RenderWidgetHostImpl::SetView(RenderWidgetHostViewBase* view) {
+ DCHECK(view);
view_ = view;
GpuSurfaceTracker::Get()->SetSurfaceHandle(
@@ -653,12 +657,13 @@ void RenderWidgetHostImpl::LostMouseLock() {
Send(new ViewMsg_MouseLockLost(routing_id_));
}
-void RenderWidgetHostImpl::ViewDestroyed() {
+void RenderWidgetHostImpl::ViewDestroyed(RenderWidgetHostViewBase* view) {
+ // If the view has been changed, then do not re-set the view pointer when the
+ // old view is destroyed.
+ if (view != view_)
+ return;
RejectMouseLockOrUnlockIfNecessary();
-
- // TODO(evanm): tracking this may no longer be necessary;
- // eliminate this function if so.
- SetView(NULL);
+ view_ = NULL;
}
void RenderWidgetHostImpl::CopyFromBackingStore(
@@ -1218,8 +1223,8 @@ void RenderWidgetHostImpl::RendererExited(base::TerminationStatus status,
if (view_) {
GpuSurfaceTracker::Get()->SetSurfaceHandle(surface_id_,
gfx::GLSurfaceHandle());
- view_->RenderProcessGone(status, exit_code);
- view_ = NULL; // The View should be deleted by RenderProcessGone.
+ view_->Destroy();
+ DCHECK(!view_);
}
// Reconstruct the input router to ensure that it has fresh state for a new
@@ -1333,8 +1338,10 @@ void RenderWidgetHostImpl::Destroy() {
// Note that in the process of the view shutting down, it can call a ton
// of other messages on us. So if you do any other deinitialization here,
// do it after this call to view_->Destroy().
- if (view_)
+ if (view_) {
view_->Destroy();
+ DCHECK(!view_);
+ }
delete this;
}
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698