| 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" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 WebInputEvent::Type type, | 96 WebInputEvent::Type type, |
| 97 int64_t latency_component_id, | 97 int64_t latency_component_id, |
| 98 const LatencyInfo& latency, | 98 const LatencyInfo& latency, |
| 99 InputEventAckState ack_result) { | 99 InputEventAckState ack_result) { |
| 100 // If this event was coalesced into another event, ignore it, as the event it | 100 // If this event was coalesced into another event, ignore it, as the event it |
| 101 // was coalesced into will reflect the full latency. | 101 // was coalesced into will reflect the full latency. |
| 102 if (latency.coalesced()) | 102 if (latency.coalesced()) |
| 103 return; | 103 return; |
| 104 | 104 |
| 105 if (type != blink::WebInputEvent::kMouseWheel && | 105 if (type != blink::WebInputEvent::kMouseWheel && |
| 106 !WebInputEvent::IsTouchEventType(type)) { | 106 !WebInputEvent::IsTouchEventType(type) && |
| 107 !WebInputEvent::IsKeyboardEventType(type)) { |
| 107 return; | 108 return; |
| 108 } | 109 } |
| 109 | 110 |
| 110 LatencyInfo::LatencyComponent rwh_component; | 111 LatencyInfo::LatencyComponent rwh_component; |
| 111 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 112 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| 112 latency_component_id, &rwh_component)) { | 113 latency_component_id, &rwh_component)) { |
| 113 return; | 114 return; |
| 114 } | 115 } |
| 115 DCHECK_EQ(rwh_component.event_count, 1u); | 116 DCHECK_EQ(rwh_component.event_count, 1u); |
| 116 | 117 |
| 117 bool multi_finger_touch_gesture = | 118 bool multi_finger_touch_gesture = |
| 118 WebInputEvent::IsTouchEventType(type) && active_multi_finger_gesture_; | 119 WebInputEvent::IsTouchEventType(type) && active_multi_finger_gesture_; |
| 119 | 120 |
| 120 LatencyInfo::LatencyComponent ui_component; | 121 LatencyInfo::LatencyComponent ui_component; |
| 121 if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, | 122 if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, |
| 122 &ui_component)) { | 123 &ui_component)) { |
| 123 DCHECK_EQ(ui_component.event_count, 1u); | 124 DCHECK_EQ(ui_component.event_count, 1u); |
| 124 base::TimeDelta ui_delta = | 125 base::TimeDelta ui_delta = |
| 125 rwh_component.last_event_time - ui_component.first_event_time; | 126 rwh_component.last_event_time - ui_component.first_event_time; |
| 126 | 127 |
| 127 if (type == blink::WebInputEvent::kMouseWheel) { | 128 if (type == blink::WebInputEvent::kMouseWheel) { |
| 128 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser.WheelUI", | 129 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser.WheelUI", |
| 129 ui_delta.InMicroseconds(), 1, 20000, 100); | 130 ui_delta.InMicroseconds(), 1, 20000, 100); |
| 130 } else { | 131 } else if (WebInputEvent::IsTouchEventType(type)) { |
| 131 DCHECK(WebInputEvent::IsTouchEventType(type)); | |
| 132 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser.TouchUI", | 132 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser.TouchUI", |
| 133 ui_delta.InMicroseconds(), 1, 20000, 100); | 133 ui_delta.InMicroseconds(), 1, 20000, 100); |
| 134 } else if (WebInputEvent::IsKeyboardEventType(type)) { |
| 135 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser.KeyUI", |
| 136 ui_delta.InMicroseconds(), 1, 20000, 50); |
| 137 } else { |
| 138 // We should only report these histograms for wheel, touch and keyboard. |
| 139 NOTREACHED(); |
| 134 } | 140 } |
| 135 } | 141 } |
| 136 | 142 |
| 137 // Both tap and scroll gestures depend on the disposition of the touch start | 143 // Touchscreen tap and scroll gestures depend on the disposition of the touch |
| 138 // and the current touch. For touch start, touch_start_default_prevented_ == | 144 // start and the current touch. For touch start, |
| 139 // (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED). | 145 // touch_start_default_prevented_ == (ack_result == |
| 146 // INPUT_EVENT_ACK_STATE_CONSUMED). |
| 140 bool action_prevented = touch_start_default_prevented_ || | 147 bool action_prevented = touch_start_default_prevented_ || |
| 141 ack_result == INPUT_EVENT_ACK_STATE_CONSUMED; | 148 ack_result == INPUT_EVENT_ACK_STATE_CONSUMED; |
| 142 | 149 |
| 143 std::string event_name = WebInputEvent::GetName(type); | 150 std::string event_name = WebInputEvent::GetName(type); |
| 151 if (WebInputEvent::IsKeyboardEventType(type)) |
| 152 event_name = "KeyEvent"; |
| 144 | 153 |
| 145 std::string default_action_status = | 154 std::string default_action_status = |
| 146 action_prevented ? "DefaultPrevented" : "DefaultAllowed"; | 155 action_prevented ? "DefaultPrevented" : "DefaultAllowed"; |
| 147 | 156 |
| 148 LatencyInfo::LatencyComponent main_component; | 157 LatencyInfo::LatencyComponent main_component; |
| 149 if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, | 158 if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, |
| 150 &main_component)) { | 159 &main_component)) { |
| 151 DCHECK_EQ(main_component.event_count, 1u); | 160 DCHECK_EQ(main_component.event_count, 1u); |
| 152 if (!multi_finger_touch_gesture) { | 161 if (!multi_finger_touch_gesture) { |
| 153 UMA_HISTOGRAM_INPUT_LATENCY_MILLISECONDS( | 162 UMA_HISTOGRAM_INPUT_LATENCY_MILLISECONDS( |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 sample->SetUInt64Field( | 314 sample->SetUInt64Field( |
| 306 "Latency", | 315 "Latency", |
| 307 (end_component.last_event_time - start_component.first_event_time) | 316 (end_component.last_event_time - start_component.first_event_time) |
| 308 .InMicroseconds(), | 317 .InMicroseconds(), |
| 309 rappor::NO_NOISE); | 318 rappor::NO_NOISE); |
| 310 rappor_service->RecordSample(name, std::move(sample)); | 319 rappor_service->RecordSample(name, std::move(sample)); |
| 311 } | 320 } |
| 312 } | 321 } |
| 313 | 322 |
| 314 } // namespace content | 323 } // namespace content |
| OLD | NEW |