Stop reviving crashed RenderFrameHost. Get a new one instead.

On same-site navigations, the browser reuses the current
RenderFrameHost, even if the current RenderFrameHost is crashed.

Instead of reviving the crashed one, we should get a new RenderFrameHost.

This can be seen as a small step in the direction of RenderDocument, which
intend to get a new RenderFrameHost every time, even if the previous
RenderFrameHost is not crashed.
https://docs.google.com/document/d/1C2VKkFRSc0kdmqjKan1G4NlNlxWZqE4Wam41FNMgnmA/edit

Bug: 981339
Change-Id: I17b11abe759906a7f360abeaa45f0bfc77e08768
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1688957
Commit-Queue: Arthur Sonzogni <[email protected]>
Reviewed-by: Charlie Reis <[email protected]>
Reviewed-by: Alex Moshchuk <[email protected]>
Cr-Commit-Position: refs/heads/master@{#685282}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 7ce96d6..9cc3c1e1 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -5198,6 +5198,7 @@
 
 void WebContentsImpl::NotifyViewSwapped(RenderViewHost* old_host,
                                         RenderViewHost* new_host) {
+  DCHECK_NE(old_host, new_host);
   // After sending out a swap notification, we need to send a disconnect
   // notification so that clients that pick up a pointer to |this| can NULL the
   // pointer.  See Bug 1230284.
@@ -6471,8 +6472,14 @@
                                                      RenderFrameHost* new_host,
                                                      bool is_main_frame) {
   if (is_main_frame) {
-    NotifyViewSwapped(old_host ? old_host->GetRenderViewHost() : nullptr,
-                      new_host->GetRenderViewHost());
+    RenderViewHost* old_rvh =
+        old_host ? old_host->GetRenderViewHost() : nullptr;
+    RenderViewHost* new_rvh = new_host->GetRenderViewHost();
+    // |old_rvh| and |new_rvh| might be equal when navigating from a crashed
+    // RenderFrameHost to a new same-site one. With RenderDocument, this will
+    // happen for every same-site navigation.
+    if (old_rvh != new_rvh)
+      NotifyViewSwapped(old_rvh, new_rvh);
 
     // Make sure the visible RVH reflects the new delegate's preferences.
     if (delegate_)