| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker
.h" | 5 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker
.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram_functions.h" | 10 #include "base/metrics/histogram_functions.h" |
| 11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "components/rappor/public/rappor_utils.h" | 13 #include "components/rappor/public/rappor_utils.h" |
| 14 #include "components/ukm/public/ukm_entry_builder.h" | 14 #include "components/ukm/public/ukm_entry_builder.h" |
| 15 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 15 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 16 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/content_browser_client.h" | 17 #include "content/public/browser/content_browser_client.h" |
| 17 #include "content/public/common/content_client.h" | 18 #include "content/public/common/content_client.h" |
| 18 #include "ui/events/blink/web_input_event_traits.h" | 19 #include "ui/events/blink/web_input_event_traits.h" |
| 19 #include "ui/latency/latency_histogram_macros.h" | 20 #include "ui/latency/latency_histogram_macros.h" |
| 20 | 21 |
| 21 using blink::WebGestureEvent; | 22 using blink::WebGestureEvent; |
| 22 using blink::WebInputEvent; | 23 using blink::WebInputEvent; |
| 23 using blink::WebMouseEvent; | 24 using blink::WebMouseEvent; |
| 24 using blink::WebMouseWheelEvent; | 25 using blink::WebMouseWheelEvent; |
| 25 using blink::WebTouchEvent; | 26 using blink::WebTouchEvent; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 "Event.Latency.Browser." + input_modality + "Acked", rwh_component, | 187 "Event.Latency.Browser." + input_modality + "Acked", rwh_component, |
| 187 acked_component); | 188 acked_component); |
| 188 } | 189 } |
| 189 } | 190 } |
| 190 } | 191 } |
| 191 | 192 |
| 192 void RenderWidgetHostLatencyTracker::OnInputEvent( | 193 void RenderWidgetHostLatencyTracker::OnInputEvent( |
| 193 const blink::WebInputEvent& event, | 194 const blink::WebInputEvent& event, |
| 194 LatencyInfo* latency) { | 195 LatencyInfo* latency) { |
| 195 DCHECK(latency); | 196 DCHECK(latency); |
| 197 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 198 |
| 199 static uint64_t global_trace_id = 0; |
| 200 latency->set_trace_id(++global_trace_id); |
| 196 | 201 |
| 197 if (event.GetType() == WebInputEvent::kTouchStart) { | 202 if (event.GetType() == WebInputEvent::kTouchStart) { |
| 198 const WebTouchEvent& touch_event = | 203 const WebTouchEvent& touch_event = |
| 199 *static_cast<const WebTouchEvent*>(&event); | 204 *static_cast<const WebTouchEvent*>(&event); |
| 200 DCHECK(touch_event.touches_length >= 1); | 205 DCHECK(touch_event.touches_length >= 1); |
| 201 active_multi_finger_gesture_ = touch_event.touches_length != 1; | 206 active_multi_finger_gesture_ = touch_event.touches_length != 1; |
| 202 } | 207 } |
| 203 | 208 |
| 204 if (latency->source_event_type() == ui::KEY_PRESS) { | 209 if (latency->source_event_type() == ui::KEY_PRESS) { |
| 205 DCHECK(event.GetType() == WebInputEvent::kChar || | 210 DCHECK(event.GetType() == WebInputEvent::kChar || |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 if (ukm_source_id == -1 || !ukm_recorder) | 355 if (ukm_source_id == -1 || !ukm_recorder) |
| 351 return; | 356 return; |
| 352 | 357 |
| 353 std::unique_ptr<ukm::UkmEntryBuilder> builder = | 358 std::unique_ptr<ukm::UkmEntryBuilder> builder = |
| 354 ukm_recorder->GetEntryBuilder(ukm_source_id, event_name.c_str()); | 359 ukm_recorder->GetEntryBuilder(ukm_source_id, event_name.c_str()); |
| 355 builder->AddMetric(metric_name.c_str(), (end_component.last_event_time - | 360 builder->AddMetric(metric_name.c_str(), (end_component.last_event_time - |
| 356 start_component.first_event_time) | 361 start_component.first_event_time) |
| 357 .InMicroseconds()); | 362 .InMicroseconds()); |
| 358 } | 363 } |
| 359 } // namespace content | 364 } // namespace content |
| OLD | NEW |