| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/renderer/input/render_widget_input_handler.h" | 5 #include "content/renderer/input/render_widget_input_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 void LogPassiveEventListenersUma(WebInputEventResult result, | 121 void LogPassiveEventListenersUma(WebInputEventResult result, |
| 122 WebInputEvent::DispatchType dispatch_type, | 122 WebInputEvent::DispatchType dispatch_type, |
| 123 double event_timestamp, | 123 double event_timestamp, |
| 124 const ui::LatencyInfo& latency_info) { | 124 const ui::LatencyInfo& latency_info) { |
| 125 enum { | 125 enum { |
| 126 PASSIVE_LISTENER_UMA_ENUM_PASSIVE, | 126 PASSIVE_LISTENER_UMA_ENUM_PASSIVE, |
| 127 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE, | 127 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE, |
| 128 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, | 128 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, |
| 129 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, | 129 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, |
| 130 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED, | 130 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED, |
| 131 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING, | 131 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING, |
| 132 PASSIVE_LISTENER_UMA_ENUM_COUNT | 132 PASSIVE_LISTENER_UMA_ENUM_COUNT |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 int enum_value; | 135 int enum_value; |
| 136 switch (dispatch_type) { | 136 switch (dispatch_type) { |
| 137 case WebInputEvent::ListenersForcedNonBlockingPassive: | 137 case WebInputEvent::ListenersForcedNonBlockingDueToFling: |
| 138 enum_value = PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING; | 138 enum_value = PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING; |
| 139 break; | 139 break; |
| 140 case WebInputEvent::ListenersNonBlockingPassive: | 140 case WebInputEvent::ListenersNonBlockingPassive: |
| 141 enum_value = PASSIVE_LISTENER_UMA_ENUM_PASSIVE; | 141 enum_value = PASSIVE_LISTENER_UMA_ENUM_PASSIVE; |
| 142 break; | 142 break; |
| 143 case WebInputEvent::EventNonBlocking: | 143 case WebInputEvent::EventNonBlocking: |
| 144 enum_value = PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE; | 144 enum_value = PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE; |
| 145 break; | 145 break; |
| 146 case WebInputEvent::Blocking: | 146 case WebInputEvent::Blocking: |
| 147 if (result == WebInputEventResult::HandledApplication) | 147 if (result == WebInputEventResult::HandledApplication) |
| 148 enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED; | 148 enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED; |
| 149 else if (result == WebInputEventResult::HandledSuppressed) | 149 else if (result == WebInputEventResult::HandledSuppressed) |
| 150 enum_value = PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED; | 150 enum_value = PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED; |
| 151 else | 151 else |
| 152 enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE; | 152 enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE; |
| 153 break; | 153 break; |
| 154 default: | 154 default: |
| 155 NOTREACHED(); | 155 NOTREACHED(); |
| 156 return; | 156 return; |
| 157 } | 157 } |
| 158 | 158 |
| 159 UMA_HISTOGRAM_ENUMERATION("Event.PassiveListeners", enum_value, | 159 UMA_HISTOGRAM_ENUMERATION("Event.PassiveListeners", enum_value, |
| 160 PASSIVE_LISTENER_UMA_ENUM_COUNT); | 160 PASSIVE_LISTENER_UMA_ENUM_COUNT); |
| 161 | 161 |
| 162 if (base::TimeTicks::IsHighResolution()) { | 162 if (base::TimeTicks::IsHighResolution()) { |
| 163 if (enum_value == PASSIVE_LISTENER_UMA_ENUM_CANCELABLE) { | 163 if (enum_value == PASSIVE_LISTENER_UMA_ENUM_CANCELABLE) { |
| 164 base::TimeTicks now = base::TimeTicks::Now(); | 164 base::TimeTicks now = base::TimeTicks::Now(); |
| 165 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.PassiveListeners.Latency", | 165 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.PassiveListeners.Latency", |
| 166 GetEventLatencyMicros(event_timestamp, now), | 166 GetEventLatencyMicros(event_timestamp, now), |
| 167 1, 10000000, 100); | 167 1, 10000000, 100); |
| 168 } else if (enum_value == PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING) { | 168 } else if (enum_value == |
| 169 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING) { |
| 169 base::TimeTicks now = base::TimeTicks::Now(); | 170 base::TimeTicks now = base::TimeTicks::Now(); |
| 170 UMA_HISTOGRAM_CUSTOM_COUNTS( | 171 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 171 "Event.PassiveListeners.ForcedNonBlockingLatency", | 172 "Event.PassiveListeners.ForcedNonBlockingLatencyDueToFling", |
| 172 GetEventLatencyMicros(event_timestamp, now), 1, 10000000, 100); | 173 GetEventLatencyMicros(event_timestamp, now), 1, 10000000, 100); |
| 173 } | 174 } |
| 174 } | 175 } |
| 175 } | 176 } |
| 176 | 177 |
| 177 } // namespace | 178 } // namespace |
| 178 | 179 |
| 179 RenderWidgetInputHandler::RenderWidgetInputHandler( | 180 RenderWidgetInputHandler::RenderWidgetInputHandler( |
| 180 RenderWidgetInputHandlerDelegate* delegate, | 181 RenderWidgetInputHandlerDelegate* delegate, |
| 181 RenderWidget* widget) | 182 RenderWidget* widget) |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 // ideally this should be when the event was sent by the compositor to the | 329 // ideally this should be when the event was sent by the compositor to the |
| 329 // renderer. crbug.com/565348 | 330 // renderer. crbug.com/565348 |
| 330 if (input_event.type == WebInputEvent::TouchStart || | 331 if (input_event.type == WebInputEvent::TouchStart || |
| 331 input_event.type == WebInputEvent::TouchMove || | 332 input_event.type == WebInputEvent::TouchMove || |
| 332 input_event.type == WebInputEvent::TouchEnd) { | 333 input_event.type == WebInputEvent::TouchEnd) { |
| 333 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); | 334 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); |
| 334 | 335 |
| 335 LogPassiveEventListenersUma(processed, touch.dispatchType, | 336 LogPassiveEventListenersUma(processed, touch.dispatchType, |
| 336 input_event.timeStampSeconds, latency_info); | 337 input_event.timeStampSeconds, latency_info); |
| 337 | 338 |
| 338 if (input_event.type == WebInputEvent::TouchStart && | 339 // TODO(lanwei): Remove this metric for event latency outside fling in M56, |
| 339 touch.dispatchType == WebInputEvent::Blocking && | 340 // once we've gathered enough data to decide if we want to ship the passive |
| 341 // event listener for fling, see https://crbug.com/638661. |
| 342 if (touch.dispatchType == WebInputEvent::Blocking && |
| 343 touch.touchStartOrFirstTouchMove && |
| 340 base::TimeTicks::IsHighResolution()) { | 344 base::TimeTicks::IsHighResolution()) { |
| 341 base::TimeTicks now = base::TimeTicks::Now(); | 345 base::TimeTicks now = base::TimeTicks::Now(); |
| 342 if (touch.dispatchedDuringFling) { | 346 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 343 UMA_HISTOGRAM_CUSTOM_COUNTS( | 347 "Event.Touch.TouchLatencyOutsideFling", |
| 344 "Event.Touch.TouchStartLatencyDuringFling", | 348 GetEventLatencyMicros(input_event.timeStampSeconds, now), 1, |
| 345 GetEventLatencyMicros(input_event.timeStampSeconds, now), 1, | 349 100000000, 50); |
| 346 100000000, 50); | |
| 347 } else { | |
| 348 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
| 349 "Event.Touch.TouchStartLatencyOutsideFling", | |
| 350 GetEventLatencyMicros(input_event.timeStampSeconds, now), 1, | |
| 351 100000000, 50); | |
| 352 } | |
| 353 } | 350 } |
| 354 } else if (input_event.type == WebInputEvent::MouseWheel) { | 351 } else if (input_event.type == WebInputEvent::MouseWheel) { |
| 355 LogPassiveEventListenersUma( | 352 LogPassiveEventListenersUma( |
| 356 processed, | 353 processed, |
| 357 static_cast<const WebMouseWheelEvent&>(input_event).dispatchType, | 354 static_cast<const WebMouseWheelEvent&>(input_event).dispatchType, |
| 358 input_event.timeStampSeconds, latency_info); | 355 input_event.timeStampSeconds, latency_info); |
| 359 } | 356 } |
| 360 | 357 |
| 361 // If this RawKeyDown event corresponds to a browser keyboard shortcut and | 358 // If this RawKeyDown event corresponds to a browser keyboard shortcut and |
| 362 // it's not processed by webkit, then we need to suppress the upcoming Char | 359 // it's not processed by webkit, then we need to suppress the upcoming Char |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 if (pending_input_event_ack_) { | 552 if (pending_input_event_ack_) { |
| 556 TRACE_EVENT_ASYNC_END0("input", | 553 TRACE_EVENT_ASYNC_END0("input", |
| 557 "RenderWidgetInputHandler::ThrottledInputEventAck", | 554 "RenderWidgetInputHandler::ThrottledInputEventAck", |
| 558 pending_input_event_ack_.get()); | 555 pending_input_event_ack_.get()); |
| 559 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); | 556 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); |
| 560 } | 557 } |
| 561 total_input_handling_time_this_frame_ = base::TimeDelta(); | 558 total_input_handling_time_this_frame_ = base::TimeDelta(); |
| 562 } | 559 } |
| 563 | 560 |
| 564 } // namespace content | 561 } // namespace content |
| OLD | NEW |