Deprecate the renderer and extension renderer crash counts.

These Local State prefs have been replaced by Stability.Counts2.

Bug: 1337565
Change-Id: Ifac657b895fe53bcfbae8885ce86337eac7b60fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3714521
Reviewed-by: Yuchen Liu <[email protected]>
Auto-Submit: Caitlin Fischer <[email protected]>
Reviewed-by: Robert Kaplow <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Reviewed-by: Olivier Robin <[email protected]>
Commit-Queue: Caitlin Fischer <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1018830}
diff --git a/chrome/browser/metrics/metrics_service_browsertest.cc b/chrome/browser/metrics/metrics_service_browsertest.cc
index b830ee0a..b1b4279 100644
--- a/chrome/browser/metrics/metrics_service_browsertest.cc
+++ b/chrome/browser/metrics/metrics_service_browsertest.cc
@@ -117,16 +117,10 @@
     ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), GURL(crashy_url)));
     observer.Wait();
 
-    // The MetricsService listens for the same notification, so the |observer|
-    // might finish waiting before the MetricsService has a chance to process
-    // the notification.  To avoid racing here, we repeatedly run the message
-    // loop until the MetricsService catches up.  This should happen "real soon
-    // now", since the notification is posted to all observers essentially
-    // simultaneously... so busy waiting here shouldn't be too bad.
-    const PrefService* prefs = g_browser_process->local_state();
-    while (!prefs->GetInteger(metrics::prefs::kStabilityRendererCrashCount)) {
-      content::RunAllPendingInMessageLoop();
-    }
+    // The MetricsService listens for the same notification, so the observer
+    // might finish waiting before the MetricsService has processed the
+    // notification. To avoid racing here, we repeatedly run the message loop.
+    content::RunAllPendingInMessageLoop();
   }
 
   // Open a couple of tabs of random content.
@@ -165,8 +159,8 @@
   // Verify that the expected stability metrics were recorded.
   histogram_tester.ExpectBucketCount("Stability.Counts2",
                                      metrics::StabilityEventType::kPageLoad, 2);
-  EXPECT_EQ(0, g_browser_process->local_state()->GetInteger(
-                   metrics::prefs::kStabilityRendererCrashCount));
+  histogram_tester.ExpectBucketCount(
+      "Stability.Counts2", metrics::StabilityEventType::kRendererCrash, 0);
 }
 
 // Flaky on Linux. See http://crbug.com/131094
@@ -189,8 +183,8 @@
   // The three tabs from OpenTabs() and the one tab to open chrome://crash/.
   histogram_tester.ExpectBucketCount("Stability.Counts2",
                                      metrics::StabilityEventType::kPageLoad, 3);
-  EXPECT_EQ(1, g_browser_process->local_state()->GetInteger(
-                   metrics::prefs::kStabilityRendererCrashCount));
+  histogram_tester.ExpectBucketCount(
+      "Stability.Counts2", metrics::StabilityEventType::kRendererCrash, 1);
 
 #if BUILDFLAG(IS_WIN)
   // Consult Stability Team before changing this test as it's recorded to
@@ -220,8 +214,8 @@
   // The three tabs from OpenTabs() and the one tab to open chrome://crash/.
   histogram_tester.ExpectBucketCount("Stability.Counts2",
                                      metrics::StabilityEventType::kPageLoad, 3);
-  EXPECT_EQ(1, g_browser_process->local_state()->GetInteger(
-                   metrics::prefs::kStabilityRendererCrashCount));
+  histogram_tester.ExpectBucketCount(
+      "Stability.Counts2", metrics::StabilityEventType::kRendererCrash, 1);
 
   histogram_tester.ExpectUniqueSample(
       "CrashExitCodes.Renderer",
@@ -240,8 +234,8 @@
   // chrome://checkcrash/.
   histogram_tester.ExpectBucketCount("Stability.Counts2",
                                      metrics::StabilityEventType::kPageLoad, 3);
-  EXPECT_EQ(1, g_browser_process->local_state()->GetInteger(
-                   metrics::prefs::kStabilityRendererCrashCount));
+  histogram_tester.ExpectBucketCount(
+      "Stability.Counts2", metrics::StabilityEventType::kRendererCrash, 1);
 
 #if BUILDFLAG(IS_WIN)
   // Consult Stability Team before changing this test as it's recorded to
@@ -271,8 +265,8 @@
   // chrome://memory-exhaust/.
   histogram_tester.ExpectBucketCount("Stability.Counts2",
                                      metrics::StabilityEventType::kPageLoad, 3);
-  EXPECT_EQ(1, g_browser_process->local_state()->GetInteger(
-                   metrics::prefs::kStabilityRendererCrashCount));
+  histogram_tester.ExpectBucketCount(
+      "Stability.Counts2", metrics::StabilityEventType::kRendererCrash, 1);
 
 // On 64-bit, the Job object should terminate the renderer on an OOM. However,
 // if the system is low on memory already, then the allocator might just return
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 8bf0ef79..1b759a6 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -743,6 +743,10 @@
 const char kBackgroundTracingLastUpload[] = "background_tracing.last_upload";
 const char kStabilityGpuCrashCount[] =
     "user_experience_metrics.stability.gpu_crash_count";
+const char kStabilityRendererCrashCount[] =
+    "user_experience_metrics.stability.renderer_crash_count";
+const char kStabilityExtensionRendererCrashCount[] =
+    "user_experience_metrics.stability.extension_renderer_crash_count";
 #if BUILDFLAG(ENABLE_DICE_SUPPORT)
 const char kTokenServiceDiceCompatible[] = "token_service.dice_compatible";
 #endif
@@ -818,6 +822,8 @@
   // Deprecated 06/2022.
   registry->RegisterInt64Pref(kBackgroundTracingLastUpload, 0);
   registry->RegisterIntegerPref(kStabilityGpuCrashCount, 0);
+  registry->RegisterIntegerPref(kStabilityRendererCrashCount, 0);
+  registry->RegisterIntegerPref(kStabilityExtensionRendererCrashCount, 0);
 #if !BUILDFLAG(IS_ANDROID)
   registry->RegisterIntegerPref(kStabilityPageLoadCount, 0);
 #endif
@@ -1676,6 +1682,8 @@
   // Added 06/2022.
   local_state->ClearPref(kBackgroundTracingLastUpload);
   local_state->ClearPref(kStabilityGpuCrashCount);
+  local_state->ClearPref(kStabilityRendererCrashCount);
+  local_state->ClearPref(kStabilityExtensionRendererCrashCount);
 #if !BUILDFLAG(IS_ANDROID)
   local_state->ClearPref(kStabilityPageLoadCount);
 #endif