Reland "Stop reviving crashed RenderFrameHost. Get a new one instead."

This relands https://crrev.com/c/1688957

It also updates it make it controlled by a feature-flag and parameterizes
all render frame hosts tests to try with the flag on and off.

- https://crrev.com/c/2006996 lands some CHECKs to help debug
  https://crbug.com/1006814
- https://crrev.com/c/2010511 lands some CHECKs to help debug
  https://crbug.com/1014212
- https://crrev.com/c/2011585 adds a test for the bug in
  https://crbug.com/993701 however this bug is no longer triggered.


> 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: I0d89d65d2c12acaccd84454ecb4a1d00901f750b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006890
Commit-Queue: Fergal Daly <[email protected]>
Reviewed-by: Alexander Timin <[email protected]>
Reviewed-by: Kentaro Hara <[email protected]>
Reviewed-by: Alex Moshchuk <[email protected]>
Reviewed-by: Arthur Sonzogni <[email protected]>
Cr-Commit-Position: refs/heads/master@{#738052}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index ea2e52b..565fc36 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -5302,6 +5302,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.
@@ -6542,8 +6543,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_)