Commit 5f8c1ef3 authored by dgozman's avatar dgozman Committed by Commit bot

Clear navigation_handle early in RenderFrameHostImpl destructor.

This is to avoid inconsistent (half-destructed) RenderFrameHostImpl instance
in WebContentsObserver::DidFinishNavigation, acessible through NavigationHandle
instance.

This happens in DevToolsManagerTest.ReattachOnCancelPendingNavigation, added
DCHECK to RenderFrameDevToolsAgentHost.

See crrev.com/2544893002 and crrev.com/2387353004 for more context.

BUG=none
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation

Review-Url: https://codereview.chromium.org/2563863002
Cr-Commit-Position: refs/heads/master@{#437658}
parent 02efb805
......@@ -912,6 +912,12 @@ void RenderFrameDevToolsAgentHost::
void RenderFrameDevToolsAgentHost::UpdateProtocolHandlers(
RenderFrameHostImpl* host) {
#if DCHECK_IS_ON()
// Check that we don't have stale host object here by accessing some random
// properties inside.
if (handlers_frame_host_ && handlers_frame_host_->GetRenderWidgetHost())
handlers_frame_host_->GetRenderWidgetHost()->GetRoutingID();
#endif
handlers_frame_host_ = host;
dom_handler_->SetRenderFrameHost(host);
if (emulation_handler_)
......
......@@ -383,6 +383,10 @@ RenderFrameHostImpl::RenderFrameHostImpl(SiteInstance* site_instance,
}
RenderFrameHostImpl::~RenderFrameHostImpl() {
// Destroying navigation handle may call into delegates/observers,
// so we do it early while |this| object is still in a sane state.
navigation_handle_.reset();
// Release the WebUI instances before all else as the WebUI may accesses the
// RenderFrameHost during cleanup.
ClearAllWebUI();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment