Remove obsolete Event.Latency.OS histograms.

They are replaced by Event.Latency.OS2.

R=sky

Bug: 1189656
Change-Id: I1baeff0d434169c564b8df09d5dd48dca588bb7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3526353
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Jonathan Ross <jonross@chromium.org>
Auto-Submit: Joe Mason <joenotcharles@google.com>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Commit-Queue: Camille Lamy <clamy@chromium.org>
Cr-Commit-Position: refs/heads/main@{#981575}
diff --git a/content/browser/android/content_ui_event_handler.cc b/content/browser/android/content_ui_event_handler.cc
index 9bcc368..9f522337 100644
--- a/content/browser/android/content_ui_event_handler.cc
+++ b/content/browser/android/content_ui_event_handler.cc
@@ -96,7 +96,7 @@
   if (!event_handler)
     return;
 
-  // Compute Event.Latency.OS.MOUSE_WHEEL histogram.
+  // Compute Event.Latency.OS2.MOUSE_WHEEL histogram.
   base::TimeTicks current_time = ui::EventTimeForNow();
   base::TimeTicks event_time = base::TimeTicks() + base::Milliseconds(time_ms);
   ComputeEventLatencyOS(ui::ET_MOUSEWHEEL, event_time, current_time);
diff --git a/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm b/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm
index 7ccc3c7..2ade2677 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm
@@ -1637,7 +1637,6 @@
   events[0]->ToEvent()->CallCallback(
       blink::mojom::InputEventResultState::kConsumed);
 
-  histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1);
   histogram_tester.ExpectTotalCount("Event.Latency.OS2.MOUSE_WHEEL", 1);
 }
 
diff --git a/tools/metrics/histograms/metadata/event/histograms.xml b/tools/metrics/histograms/metadata/event/histograms.xml
index abbe001..e356427e 100644
--- a/tools/metrics/histograms/metadata/event/histograms.xml
+++ b/tools/metrics/histograms/metadata/event/histograms.xml
@@ -364,29 +364,14 @@
   </summary>
 </histogram>
 
-<histogram name="Event.Latency.OS" units="microseconds" expires_after="M92">
-  <owner>flackr@chromium.org</owner>
-  <owner>input-dev@chromium.org</owner>
-  <summary>
-    Time between input event received by OS and sent to Chrome, recorded for
-    each event when it is received by Chrome. This is obsoleted by
-    Event.Latency.OS2 and should be removed after they've been run side-by-side
-    for M92.
-
-    Warning: This metric may include reports from clients with low-resolution
-    clocks (i.e. on Windows, ref. |TimeTicks::IsHighResolution()|). Such reports
-    will cause this metric to have an abnormal distribution. When considering
-    revising this histogram, see UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES for the
-    solution.
-  </summary>
-</histogram>
-
 <histogram name="Event.Latency.OS2" units="ms" expires_after="2022-08-14">
   <owner>flackr@chromium.org</owner>
+  <owner>joenotcharles@google.com</owner>
   <owner>input-dev@chromium.org</owner>
   <summary>
     Time between input event received by OS and sent to Chrome, recorded for
-    each event when it is received by Chrome.
+    each event when it is received by Chrome. Replaced Event.Latency.OS which
+    was calculated incorrectly on Windows.
 
     Warning: On Windows, the timestamps of most events come from a clock with a
     several msec resolution so will have an abnormal distribution even when
diff --git a/tools/metrics/histograms/metadata/histogram_suffixes_list.xml b/tools/metrics/histograms/metadata/histogram_suffixes_list.xml
index 2a9057f2..bc2b53f 100644
--- a/tools/metrics/histograms/metadata/histogram_suffixes_list.xml
+++ b/tools/metrics/histograms/metadata/histogram_suffixes_list.xml
@@ -2738,7 +2738,6 @@
   <suffix name="TOUCH_MOVED" label=""/>
   <suffix name="TOUCH_PRESSED" label=""/>
   <suffix name="TOUCH_RELEASED" label=""/>
-  <affected-histogram name="Event.Latency.OS"/>
   <affected-histogram name="Event.Latency.OS2"/>
 </histogram_suffixes>
 
diff --git a/ui/events/event_unittest.cc b/ui/events/event_unittest.cc
index 363db7b..7f68a73 100644
--- a/ui/events/event_unittest.cc
+++ b/ui/events/event_unittest.cc
@@ -696,7 +696,6 @@
   base::HistogramTester histogram_tester;
   CHROME_MSG event = {nullptr, WM_MOUSEWHEEL, 0, 0};
   MouseWheelEvent mouseWheelEvent(event);
-  histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1);
   histogram_tester.ExpectTotalCount("Event.Latency.OS2.MOUSE_WHEEL", 1);
 #endif
 }
@@ -990,9 +989,6 @@
                                         base::TimeTicks::Now());
     ComputeEventLatencyOSFromPOINTER_INFO(ET_TOUCH_PRESSED, pointer_info,
                                           base::TimeTicks::Now());
-    histogram_tester.ExpectUniqueSample("Event.Latency.OS.TOUCH_PRESSED",
-                                        base::Milliseconds(5).InMicroseconds(),
-                                        2);
     histogram_tester.ExpectUniqueTimeSample("Event.Latency.OS2.TOUCH_PRESSED",
                                             base::Milliseconds(5), 2);
   }
@@ -1008,9 +1004,6 @@
                                         base::TimeTicks::Now());
     ComputeEventLatencyOSFromPOINTER_INFO(ET_TOUCH_PRESSED, pointer_info,
                                           base::TimeTicks::Now());
-    histogram_tester.ExpectUniqueSample("Event.Latency.OS.TOUCH_PRESSED",
-                                        base::Milliseconds(15).InMicroseconds(),
-                                        2);
     histogram_tester.ExpectUniqueTimeSample("Event.Latency.OS2.TOUCH_PRESSED",
                                             base::Milliseconds(15), 2);
   }
@@ -1024,7 +1017,6 @@
                                         base::TimeTicks::Now());
     ComputeEventLatencyOSFromPOINTER_INFO(ET_TOUCH_PRESSED, pointer_info,
                                           base::TimeTicks::Now());
-    histogram_tester.ExpectUniqueSample("Event.Latency.OS.TOUCH_PRESSED", 0, 2);
     histogram_tester.ExpectUniqueTimeSample("Event.Latency.OS2.TOUCH_PRESSED",
                                             base::TimeDelta(), 2);
   }
@@ -1059,8 +1051,6 @@
     base::HistogramTester histogram_tester;
     ComputeEventLatencyOSFromPOINTER_INFO(ET_TOUCH_PRESSED, pointer_info,
                                           base::TimeTicks::Now());
-    histogram_tester.ExpectUniqueSample("Event.Latency.OS.TOUCH_PRESSED",
-                                        base::Seconds(1).InMicroseconds(), 1);
     histogram_tester.ExpectUniqueTimeSample("Event.Latency.OS2.TOUCH_PRESSED",
                                             base::Seconds(1), 1);
   }
@@ -1075,7 +1065,6 @@
     base::HistogramTester histogram_tester;
     ComputeEventLatencyOSFromPOINTER_INFO(ET_TOUCH_PRESSED, pointer_info,
                                           base::TimeTicks::Now());
-    histogram_tester.ExpectUniqueSample("Event.Latency.OS.TOUCH_PRESSED", 0, 1);
     histogram_tester.ExpectUniqueTimeSample("Event.Latency.OS2.TOUCH_PRESSED",
                                             base::TimeDelta(), 1);
   }
@@ -1090,7 +1079,6 @@
     base::HistogramTester histogram_tester;
     ComputeEventLatencyOSFromPOINTER_INFO(ET_TOUCH_PRESSED, pointer_info,
                                           base::TimeTicks::Now());
-    histogram_tester.ExpectUniqueSample("Event.Latency.OS.TOUCH_PRESSED", 0, 1);
     histogram_tester.ExpectUniqueTimeSample("Event.Latency.OS2.TOUCH_PRESSED",
                                             base::TimeDelta(), 1);
   }
@@ -1104,7 +1092,6 @@
     base::HistogramTester histogram_tester;
     ComputeEventLatencyOSFromPOINTER_INFO(ET_TOUCH_PRESSED, pointer_info,
                                           base::TimeTicks::Now());
-    histogram_tester.ExpectTotalCount("Event.Latency.OS.TOUCH_PRESSED", 0);
     histogram_tester.ExpectTotalCount("Event.Latency.OS2.TOUCH_PRESSED", 0);
   }
 
@@ -1122,8 +1109,6 @@
     base::HistogramTester histogram_tester;
     ComputeEventLatencyOSFromPOINTER_INFO(ET_TOUCH_PRESSED, pointer_info,
                                           base::TimeTicks::Now());
-    histogram_tester.ExpectUniqueSample("Event.Latency.OS.TOUCH_PRESSED",
-                                        base::Seconds(1).InMicroseconds(), 1);
     histogram_tester.ExpectUniqueTimeSample("Event.Latency.OS2.TOUCH_PRESSED",
                                             base::Seconds(1), 1);
   }
diff --git a/ui/events/event_utils.cc b/ui/events/event_utils.cc
index 05eb141..727760a2 100644
--- a/ui/events/event_utils.cc
+++ b/ui/events/event_utils.cc
@@ -133,67 +133,43 @@
                            base::TimeTicks current_time) {
   base::TimeDelta delta = current_time - time_stamp;
 
-  // TODO(crbug.com/1189656): Remove the legacy Event.Latency.OS.* histograms
-  // after M92 (which introduced Event.Latency.OS2.*) has been replaced in the
-  // stable channel.
   switch (type) {
 #if BUILDFLAG(IS_APPLE)
     // On Mac, ET_SCROLL and ET_MOUSEWHEEL represent the same class of events.
     case ET_SCROLL:
 #endif
     case ET_MOUSEWHEEL:
-      UMA_HISTOGRAM_CUSTOM_COUNTS(
-          "Event.Latency.OS.MOUSE_WHEEL",
-          base::saturated_cast<int>(delta.InMicroseconds()), 1, 1000000, 50);
       UMA_HISTOGRAM_EVENT_LATENCY_TIMES("Event.Latency.OS2.MOUSE_WHEEL", delta);
       // Do not record traces for wheel events to avoid spam.
       return;
     case ET_TOUCH_MOVED:
-      UMA_HISTOGRAM_CUSTOM_COUNTS(
-          "Event.Latency.OS.TOUCH_MOVED",
-          base::saturated_cast<int>(delta.InMicroseconds()), 1, 1000000, 50);
       UMA_HISTOGRAM_EVENT_LATENCY_TIMES("Event.Latency.OS2.TOUCH_MOVED", delta);
       // Do not record traces for move events to avoid spam.
       return;
     case ET_TOUCH_PRESSED:
-      UMA_HISTOGRAM_CUSTOM_COUNTS(
-          "Event.Latency.OS.TOUCH_PRESSED",
-          base::saturated_cast<int>(delta.InMicroseconds()), 1, 1000000, 50);
       UMA_HISTOGRAM_EVENT_LATENCY_TIMES("Event.Latency.OS2.TOUCH_PRESSED",
                                         delta);
       RecordEventLatencyTrace("InputEventLatency.TOUCH_PRESSED", time_stamp,
                               current_time);
       return;
     case ET_TOUCH_RELEASED:
-      UMA_HISTOGRAM_CUSTOM_COUNTS(
-          "Event.Latency.OS.TOUCH_RELEASED",
-          base::saturated_cast<int>(delta.InMicroseconds()), 1, 1000000, 50);
       UMA_HISTOGRAM_EVENT_LATENCY_TIMES("Event.Latency.OS2.TOUCH_RELEASED",
                                         delta);
       RecordEventLatencyTrace("InputEventLatency.TOUCH_RELEASED", time_stamp,
                               current_time);
       return;
     case ET_TOUCH_CANCELLED:
-      UMA_HISTOGRAM_CUSTOM_COUNTS(
-          "Event.Latency.OS.TOUCH_CANCELLED",
-          base::saturated_cast<int>(delta.InMicroseconds()), 1, 1000000, 50);
       UMA_HISTOGRAM_EVENT_LATENCY_TIMES("Event.Latency.OS2.TOUCH_CANCELLED",
                                         delta);
       RecordEventLatencyTrace("InputEventLatency.TOUCH_CANCELLED", time_stamp,
                               current_time);
       return;
     case ET_KEY_PRESSED:
-      UMA_HISTOGRAM_CUSTOM_COUNTS(
-          "Event.Latency.OS.KEY_PRESSED",
-          base::saturated_cast<int>(delta.InMicroseconds()), 1, 1000000, 50);
       UMA_HISTOGRAM_EVENT_LATENCY_TIMES("Event.Latency.OS2.KEY_PRESSED", delta);
       RecordEventLatencyTrace("InputEventLatency.KEY_PRESSED", time_stamp,
                               current_time);
       return;
     case ET_MOUSE_PRESSED:
-      UMA_HISTOGRAM_CUSTOM_COUNTS(
-          "Event.Latency.OS.MOUSE_PRESSED",
-          base::saturated_cast<int>(delta.InMicroseconds()), 1, 1000000, 50);
       UMA_HISTOGRAM_EVENT_LATENCY_TIMES("Event.Latency.OS2.MOUSE_PRESSED",
                                         delta);
       RecordEventLatencyTrace("InputEventLatency.MOUSE_PRESSED", time_stamp,
diff --git a/ui/ozone/platform/x11/test/events_x_unittest.cc b/ui/ozone/platform/x11/test/events_x_unittest.cc
index 8696420..125ecac 100644
--- a/ui/ozone/platform/x11/test/events_x_unittest.cc
+++ b/ui/ozone/platform/x11/test/events_x_unittest.cc
@@ -783,17 +783,14 @@
   scoped_xevent.InitTouchEvent(0, x11::Input::DeviceEvent::TouchBegin, 5,
                                gfx::Point(10, 10), {});
   auto touch_begin = ui::BuildTouchEventFromXEvent(*scoped_xevent);
-  histogram_tester.ExpectTotalCount("Event.Latency.OS.TOUCH_PRESSED", 1);
   histogram_tester.ExpectTotalCount("Event.Latency.OS2.TOUCH_PRESSED", 1);
   scoped_xevent.InitTouchEvent(0, x11::Input::DeviceEvent::TouchUpdate, 5,
                                gfx::Point(20, 20), {});
   auto touch_update = ui::BuildTouchEventFromXEvent(*scoped_xevent);
-  histogram_tester.ExpectTotalCount("Event.Latency.OS.TOUCH_MOVED", 1);
   histogram_tester.ExpectTotalCount("Event.Latency.OS2.TOUCH_MOVED", 1);
   scoped_xevent.InitTouchEvent(0, x11::Input::DeviceEvent::TouchEnd, 5,
                                gfx::Point(30, 30), {});
   auto touch_end = ui::BuildTouchEventFromXEvent(*scoped_xevent);
-  histogram_tester.ExpectTotalCount("Event.Latency.OS.TOUCH_RELEASED", 1);
   histogram_tester.ExpectTotalCount("Event.Latency.OS2.TOUCH_RELEASED", 1);
 }
 
@@ -809,7 +806,6 @@
                  .detail = static_cast<x11::Button>(4),
              });
   auto mouse_ev = ui::BuildMouseWheelEventFromXEvent(native_event);
-  histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1);
   histogram_tester.ExpectTotalCount("Event.Latency.OS2.MOUSE_WHEEL", 1);
 }