Make WebContentsImpl::UpdateState navigation enties DCHECK conditional
When swapped out state is not used, a RenderViewHost is not guaranteed
to have a valid RenderFrameHost for the main frame. It is useful to
keep the DCHECK, but this CL makes it conditional on the presence of
a main RenderFrameHost.
BUG=357747
Review URL: https://codereview.chromium.org/1523163006
Cr-Commit-Position: refs/heads/master@{#365642}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 8e05fde..1bfc249 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -3953,10 +3953,15 @@
if (!entry)
return;
- NavigationEntryImpl* new_entry = controller_.GetEntryWithUniqueID(
- static_cast<RenderFrameHostImpl*>(rvhi->GetMainFrame())->nav_entry_id());
+ // Sanity check that ensures nav_entry_id and page_id point to the same
+ // navigation entry.
+ if (rvhi->GetMainFrame()) {
+ NavigationEntryImpl* new_entry = controller_.GetEntryWithUniqueID(
+ static_cast<RenderFrameHostImpl*>(rvhi->GetMainFrame())
+ ->nav_entry_id());
- DCHECK_EQ(entry, new_entry);
+ DCHECK_EQ(entry, new_entry);
+ }
if (page_state == entry->GetPageState())
return; // Nothing to update.