Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: content/browser/renderer_host/input/render_widget_host_latency_tracker.cc

Issue 2804693002: Remove coordinates from LatencyInfo objects. (Closed)
Patch Set: Fix fuzzer test Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/browser/renderer_host/render_widget_host_delegate.h" 14 #include "content/browser/renderer_host/render_widget_host_delegate.h"
15 #include "content/public/browser/content_browser_client.h" 15 #include "content/public/browser/content_browser_client.h"
16 #include "content/public/common/content_client.h" 16 #include "content/public/common/content_client.h"
17 #include "ui/events/blink/web_input_event_traits.h" 17 #include "ui/events/blink/web_input_event_traits.h"
18 18
19 using blink::WebGestureEvent; 19 using blink::WebGestureEvent;
20 using blink::WebInputEvent; 20 using blink::WebInputEvent;
21 using blink::WebMouseEvent; 21 using blink::WebMouseEvent;
22 using blink::WebMouseWheelEvent; 22 using blink::WebMouseWheelEvent;
23 using blink::WebTouchEvent; 23 using blink::WebTouchEvent;
24 using ui::LatencyInfo; 24 using ui::LatencyInfo;
25 25
26 namespace content { 26 namespace content {
27 namespace { 27 namespace {
28 28
29 void UpdateLatencyCoordinatesImpl(const blink::WebTouchEvent& touch,
30 LatencyInfo* latency,
31 float device_scale_factor) {
32 for (uint32_t i = 0; i < touch.touchesLength; ++i) {
33 gfx::PointF coordinate(touch.touches[i].position.x * device_scale_factor,
34 touch.touches[i].position.y * device_scale_factor);
35 if (!latency->AddInputCoordinate(coordinate))
36 break;
37 }
38 }
39
40 void UpdateLatencyCoordinatesImpl(const WebGestureEvent& gesture,
41 LatencyInfo* latency,
42 float device_scale_factor) {
43 latency->AddInputCoordinate(gfx::PointF(gesture.x * device_scale_factor,
44 gesture.y * device_scale_factor));
45 }
46
47 void UpdateLatencyCoordinatesImpl(const WebMouseEvent& mouse,
48 LatencyInfo* latency,
49 float device_scale_factor) {
50 latency->AddInputCoordinate(
51 gfx::PointF(mouse.positionInWidget().x * device_scale_factor,
52 mouse.positionInWidget().y * device_scale_factor));
53 }
54
55 void UpdateLatencyCoordinatesImpl(const WebMouseWheelEvent& wheel,
56 LatencyInfo* latency,
57 float device_scale_factor) {
58 latency->AddInputCoordinate(
59 gfx::PointF(wheel.positionInWidget().x * device_scale_factor,
60 wheel.positionInWidget().y * device_scale_factor));
61 }
62
63 void UpdateLatencyCoordinates(const WebInputEvent& event,
64 float device_scale_factor,
65 LatencyInfo* latency) {
66 if (WebInputEvent::isMouseEventType(event.type())) {
67 UpdateLatencyCoordinatesImpl(static_cast<const WebMouseEvent&>(event),
68 latency, device_scale_factor);
69 } else if (WebInputEvent::isGestureEventType(event.type())) {
70 UpdateLatencyCoordinatesImpl(static_cast<const WebGestureEvent&>(event),
71 latency, device_scale_factor);
72 } else if (WebInputEvent::isTouchEventType(event.type())) {
73 UpdateLatencyCoordinatesImpl(static_cast<const WebTouchEvent&>(event),
74 latency, device_scale_factor);
75 } else if (event.type() == WebInputEvent::MouseWheel) {
76 UpdateLatencyCoordinatesImpl(static_cast<const WebMouseWheelEvent&>(event),
77 latency, device_scale_factor);
78 }
79 }
80
81 // Check valid timing for start and end latency components. 29 // Check valid timing for start and end latency components.
82 #define CONFIRM_VALID_TIMING(start, end) \ 30 #define CONFIRM_VALID_TIMING(start, end) \
83 DCHECK(!start.first_event_time.is_null()); \ 31 DCHECK(!start.first_event_time.is_null()); \
84 DCHECK(!end.last_event_time.is_null()); \ 32 DCHECK(!end.last_event_time.is_null()); \
85 DCHECK_GE(end.last_event_time, start.first_event_time); 33 DCHECK_GE(end.last_event_time, start.first_event_time);
86 34
87 // Event latency that is mostly under 1 second. We should only use 100 buckets 35 // Event latency that is mostly under 1 second. We should only use 100 buckets
88 // when needed. 36 // when needed.
89 #define UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS(name, start, \ 37 #define UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS(name, start, \
90 end) \ 38 end) \
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 0, 411 0,
464 0, 412 0,
465 timestamp_original, 413 timestamp_original,
466 1); 414 1);
467 } 415 }
468 416
469 latency->AddLatencyNumberWithTraceName( 417 latency->AddLatencyNumberWithTraceName(
470 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, latency_component_id_, 418 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, latency_component_id_,
471 ++last_event_id_, WebInputEvent::GetName(event.type())); 419 ++last_event_id_, WebInputEvent::GetName(event.type()));
472 420
473 UpdateLatencyCoordinates(event, device_scale_factor_, latency);
474
475 if (event.type() == blink::WebInputEvent::GestureScrollBegin) { 421 if (event.type() == blink::WebInputEvent::GestureScrollBegin) {
476 has_seen_first_gesture_scroll_update_ = false; 422 has_seen_first_gesture_scroll_update_ = false;
477 } else if (event.type() == blink::WebInputEvent::GestureScrollUpdate) { 423 } else if (event.type() == blink::WebInputEvent::GestureScrollUpdate) {
478 // Make a copy of the INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT with a 424 // Make a copy of the INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT with a
479 // different name INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT. 425 // different name INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT.
480 // So we can track the latency specifically for scroll update events. 426 // So we can track the latency specifically for scroll update events.
481 LatencyInfo::LatencyComponent original_component; 427 LatencyInfo::LatencyComponent original_component;
482 if (latency->FindLatency(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 428 if (latency->FindLatency(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0,
483 &original_component)) { 429 &original_component)) {
484 latency->AddLatencyNumberWithTimestamp( 430 latency->AddLatencyNumberWithTimestamp(
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 latency_component_id_, latency); 533 latency_component_id_, latency);
588 } 534 }
589 } 535 }
590 536
591 void RenderWidgetHostLatencyTracker::SetDelegate( 537 void RenderWidgetHostLatencyTracker::SetDelegate(
592 RenderWidgetHostDelegate* delegate) { 538 RenderWidgetHostDelegate* delegate) {
593 render_widget_host_delegate_ = delegate; 539 render_widget_host_delegate_ = delegate;
594 } 540 }
595 541
596 } // namespace content 542 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698