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 c02b51aeef383a7dec78d64262fea8961339d576..540fc07f55c270ea6b4fa574f63f47fede6c465b 100644 |
--- a/content/browser/renderer_host/render_widget_host_impl.cc |
+++ b/content/browser/renderer_host/render_widget_host_impl.cc |
@@ -184,6 +184,7 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
allow_privileged_mouse_lock_(false), |
has_touch_handler_(false), |
next_browser_snapshot_id_(1), |
+ owned_by_render_frame_host_(false), |
weak_factory_(this) { |
CHECK(delegate_); |
if (routing_id_ == MSG_ROUTING_NONE) { |
@@ -414,6 +415,11 @@ void RenderWidgetHostImpl::Init() { |
WasResized(); |
} |
+void RenderWidgetHostImpl::InitForFrame() { |
+ DCHECK(process_->HasConnection()); |
+ renderer_initialized_ = true; |
+} |
+ |
void RenderWidgetHostImpl::Shutdown() { |
RejectMouseLockOrUnlockIfNecessary(); |
@@ -1318,6 +1324,13 @@ void RenderWidgetHostImpl::SetAutoResize(bool enable, |
max_size_for_auto_resize_ = max_size; |
} |
+void RenderWidgetHostImpl::Cleanup() { |
+ if (view_) { |
+ view_->Destroy(); |
+ view_ = nullptr; |
+ } |
+} |
+ |
void RenderWidgetHostImpl::Destroy() { |
NotificationService::current()->Notify( |
NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
@@ -1328,10 +1341,15 @@ 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(); |
+ view_ = nullptr; |
+ } |
- delete this; |
+ // RenderFrameHost owns a RenderWidgetHost when it needs one, in which case |
+ // it handles destruction. |
+ if (!owned_by_render_frame_host_) |
+ delete this; |
} |
void RenderWidgetHostImpl::RendererIsUnresponsive() { |