Add Stability.ChildFrameCrash.Visibility for tracking sad *sub*frames.

This CL adds Stability.ChildFrameCrash.Visibility which is logged after
detecting that a sad subframe is shown.  The logged enum describes the
timing of a renderer crash in relation to whether the subframe is
visible or not.

Bug: 841493
Change-Id: Ic893764817bd1a9aa31684d53f858a398a31dfc8
Reviewed-on: https://chromium-review.googlesource.com/1054099
Reviewed-by: Alex Moshchuk <[email protected]>
Reviewed-by: Steven Holte <[email protected]>
Reviewed-by: Lucas Gadani <[email protected]>
Commit-Queue: Alex Moshchuk <[email protected]>
Cr-Commit-Position: refs/heads/master@{#559356}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index d0d68b4..76feed1 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1520,6 +1520,19 @@
 
   last_active_time_ = base::TimeTicks::Now();
   SetVisibility(Visibility::VISIBLE);
+
+  for (FrameTreeNode* node : frame_tree_.Nodes()) {
+    RenderFrameProxyHost* parent = node->render_manager()->GetProxyToParent();
+    if (!parent)
+      continue;
+
+    if (parent->cross_process_frame_connector()->IsVisible()) {
+      // MaybeLogCrash will check 1) if there was a crash or not and 2) if the
+      // crash might have been already logged earlier as kCrashedWhileVisible.
+      parent->cross_process_frame_connector()->MaybeLogCrash(
+          CrossProcessFrameConnector::CrashVisibility::kShownAfterCrashing);
+    }
+  }
 }
 
 void WebContentsImpl::WasHidden() {