| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 void LogPassiveEventListenersUma(WebInputEventResult result, | 120 void LogPassiveEventListenersUma(WebInputEventResult result, |
| 121 WebInputEvent::DispatchType dispatch_type, | 121 WebInputEvent::DispatchType dispatch_type, |
| 122 double event_timestamp, | 122 double event_timestamp, |
| 123 const ui::LatencyInfo& latency_info) { | 123 const ui::LatencyInfo& latency_info) { |
| 124 enum { | 124 enum { |
| 125 PASSIVE_LISTENER_UMA_ENUM_PASSIVE, | 125 PASSIVE_LISTENER_UMA_ENUM_PASSIVE, |
| 126 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE, | 126 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE, |
| 127 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, | 127 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, |
| 128 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, | 128 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, |
| 129 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED, | 129 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED, |
| 130 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING, | 130 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING, |
| 131 PASSIVE_LISTENER_UMA_ENUM_COUNT | 131 PASSIVE_LISTENER_UMA_ENUM_COUNT |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 int enum_value; | 134 int enum_value; |
| 135 switch (dispatch_type) { | 135 switch (dispatch_type) { |
| 136 case WebInputEvent::ListenersForcedNonBlockingPassive: | 136 case WebInputEvent::ListenersForcedNonBlockingPassiveDueToFling: |
| 137 enum_value = PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING; | 137 enum_value = PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING; |
| 138 break; | 138 break; |
| 139 case WebInputEvent::ListenersNonBlockingPassive: | 139 case WebInputEvent::ListenersNonBlockingPassive: |
| 140 enum_value = PASSIVE_LISTENER_UMA_ENUM_PASSIVE; | 140 enum_value = PASSIVE_LISTENER_UMA_ENUM_PASSIVE; |
| 141 break; | 141 break; |
| 142 case WebInputEvent::EventNonBlocking: | 142 case WebInputEvent::EventNonBlocking: |
| 143 enum_value = PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE; | 143 enum_value = PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE; |
| 144 break; | 144 break; |
| 145 case WebInputEvent::Blocking: | 145 case WebInputEvent::Blocking: |
| 146 if (result == WebInputEventResult::HandledApplication) | 146 if (result == WebInputEventResult::HandledApplication) |
| 147 enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED; | 147 enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED; |
| 148 else if (result == WebInputEventResult::HandledSuppressed) | 148 else if (result == WebInputEventResult::HandledSuppressed) |
| 149 enum_value = PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED; | 149 enum_value = PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED; |
| 150 else | 150 else |
| 151 enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE; | 151 enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE; |
| 152 break; | 152 break; |
| 153 default: | 153 default: |
| 154 NOTREACHED(); | 154 NOTREACHED(); |
| 155 return; | 155 return; |
| 156 } | 156 } |
| 157 | 157 |
| 158 UMA_HISTOGRAM_ENUMERATION("Event.PassiveListeners", enum_value, | 158 UMA_HISTOGRAM_ENUMERATION("Event.PassiveListeners", enum_value, |
| 159 PASSIVE_LISTENER_UMA_ENUM_COUNT); | 159 PASSIVE_LISTENER_UMA_ENUM_COUNT); |
| 160 | 160 |
| 161 if (base::TimeTicks::IsHighResolution()) { | 161 if (base::TimeTicks::IsHighResolution()) { |
| 162 if (enum_value == PASSIVE_LISTENER_UMA_ENUM_CANCELABLE) { | 162 if (enum_value == PASSIVE_LISTENER_UMA_ENUM_CANCELABLE) { |
| 163 base::TimeTicks now = base::TimeTicks::Now(); | 163 base::TimeTicks now = base::TimeTicks::Now(); |
| 164 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.PassiveListeners.Latency", | 164 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.PassiveListeners.Latency", |
| 165 GetEventLatencyMicros(event_timestamp, now), | 165 GetEventLatencyMicros(event_timestamp, now), |
| 166 1, 10000000, 100); | 166 1, 10000000, 100); |
| 167 } else if (enum_value == PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING) { | 167 } else if (enum_value == |
| 168 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING) { |
| 168 base::TimeTicks now = base::TimeTicks::Now(); | 169 base::TimeTicks now = base::TimeTicks::Now(); |
| 169 UMA_HISTOGRAM_CUSTOM_COUNTS( | 170 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 170 "Event.PassiveListeners.ForcedNonBlockingLatency", | 171 "Event.PassiveListeners.ForcedNonBlockingLatencyDueToFling", |
| 171 GetEventLatencyMicros(event_timestamp, now), 1, 10000000, 100); | 172 GetEventLatencyMicros(event_timestamp, now), 1, 10000000, 100); |
| 172 } | 173 } |
| 173 } | 174 } |
| 174 } | 175 } |
| 175 | 176 |
| 176 } // namespace | 177 } // namespace |
| 177 | 178 |
| 178 RenderWidgetInputHandler::RenderWidgetInputHandler( | 179 RenderWidgetInputHandler::RenderWidgetInputHandler( |
| 179 RenderWidgetInputHandlerDelegate* delegate, | 180 RenderWidgetInputHandlerDelegate* delegate, |
| 180 RenderWidget* widget) | 181 RenderWidget* widget) |
| 181 : delegate_(delegate), | 182 : delegate_(delegate), |
| 182 widget_(widget), | 183 widget_(widget), |
| 183 handling_input_event_(false), | 184 handling_input_event_(false), |
| 184 handling_event_overscroll_(nullptr), | 185 handling_event_overscroll_(nullptr), |
| 185 handling_event_type_(WebInputEvent::Undefined), | 186 handling_event_type_(WebInputEvent::Undefined), |
| 186 context_menu_source_type_(ui::MENU_SOURCE_MOUSE), | 187 context_menu_source_type_(ui::MENU_SOURCE_MOUSE), |
| 187 suppress_next_char_events_(false), | 188 suppress_next_char_events_(false), |
| 188 ignore_ack_for_mouse_move_from_debugger_(false) { | 189 ignore_ack_for_mouse_move_from_debugger_(false), |
| 190 waiting_for_first_touch_move_(false) { |
| 189 DCHECK(delegate); | 191 DCHECK(delegate); |
| 190 DCHECK(widget); | 192 DCHECK(widget); |
| 191 delegate->SetInputHandler(this); | 193 delegate->SetInputHandler(this); |
| 192 } | 194 } |
| 193 | 195 |
| 194 RenderWidgetInputHandler::~RenderWidgetInputHandler() {} | 196 RenderWidgetInputHandler::~RenderWidgetInputHandler() {} |
| 195 | 197 |
| 196 void RenderWidgetInputHandler::HandleInputEvent( | 198 void RenderWidgetInputHandler::HandleInputEvent( |
| 197 const WebInputEvent& input_event, | 199 const WebInputEvent& input_event, |
| 198 const ui::LatencyInfo& latency_info, | 200 const ui::LatencyInfo& latency_info, |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 // 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 |
| 328 // renderer. crbug.com/565348 | 330 // renderer. crbug.com/565348 |
| 329 if (input_event.type == WebInputEvent::TouchStart || | 331 if (input_event.type == WebInputEvent::TouchStart || |
| 330 input_event.type == WebInputEvent::TouchMove || | 332 input_event.type == WebInputEvent::TouchMove || |
| 331 input_event.type == WebInputEvent::TouchEnd) { | 333 input_event.type == WebInputEvent::TouchEnd) { |
| 332 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); | 334 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); |
| 333 | 335 |
| 334 LogPassiveEventListenersUma(processed, touch.dispatchType, | 336 LogPassiveEventListenersUma(processed, touch.dispatchType, |
| 335 input_event.timeStampSeconds, latency_info); | 337 input_event.timeStampSeconds, latency_info); |
| 336 | 338 |
| 337 if (input_event.type == WebInputEvent::TouchStart && | 339 // TODO(lanwei): May remove it when we no longer need any metric for event |
| 338 touch.dispatchType == WebInputEvent::Blocking && | 340 // latency outside fling. |
| 341 if (touch.dispatchType == WebInputEvent::Blocking && |
| 339 base::TimeTicks::IsHighResolution()) { | 342 base::TimeTicks::IsHighResolution()) { |
| 340 base::TimeTicks now = base::TimeTicks::Now(); | 343 bool touch_start_or_first_touch_move = false; |
| 341 if (touch.dispatchedDuringFling) { | 344 if (touch.type == WebInputEvent::TouchStart) { |
| 345 waiting_for_first_touch_move_ = true; |
| 346 touch_start_or_first_touch_move = true; |
| 347 } else if (touch.type == WebInputEvent::TouchMove) { |
| 348 touch_start_or_first_touch_move = waiting_for_first_touch_move_; |
| 349 waiting_for_first_touch_move_ = false; |
| 350 } |
| 351 if (touch_start_or_first_touch_move) { |
| 352 base::TimeTicks now = base::TimeTicks::Now(); |
| 342 UMA_HISTOGRAM_CUSTOM_COUNTS( | 353 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 343 "Event.Touch.TouchStartLatencyDuringFling", | 354 "Event.Touch.TouchLatencyOutsideFling", |
| 344 GetEventLatencyMicros(input_event.timeStampSeconds, now), 1, | |
| 345 100000000, 50); | |
| 346 } else { | |
| 347 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
| 348 "Event.Touch.TouchStartLatencyOutsideFling", | |
| 349 GetEventLatencyMicros(input_event.timeStampSeconds, now), 1, | 355 GetEventLatencyMicros(input_event.timeStampSeconds, now), 1, |
| 350 100000000, 50); | 356 100000000, 50); |
| 351 } | 357 } |
| 352 } | 358 } |
| 353 } else if (input_event.type == WebInputEvent::MouseWheel) { | 359 } else if (input_event.type == WebInputEvent::MouseWheel) { |
| 354 LogPassiveEventListenersUma( | 360 LogPassiveEventListenersUma( |
| 355 processed, | 361 processed, |
| 356 static_cast<const WebMouseWheelEvent&>(input_event).dispatchType, | 362 static_cast<const WebMouseWheelEvent&>(input_event).dispatchType, |
| 357 input_event.timeStampSeconds, latency_info); | 363 input_event.timeStampSeconds, latency_info); |
| 358 } | 364 } |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 if (pending_input_event_ack_) { | 560 if (pending_input_event_ack_) { |
| 555 TRACE_EVENT_ASYNC_END0("input", | 561 TRACE_EVENT_ASYNC_END0("input", |
| 556 "RenderWidgetInputHandler::ThrottledInputEventAck", | 562 "RenderWidgetInputHandler::ThrottledInputEventAck", |
| 557 pending_input_event_ack_.get()); | 563 pending_input_event_ack_.get()); |
| 558 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); | 564 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); |
| 559 } | 565 } |
| 560 total_input_handling_time_this_frame_ = base::TimeDelta(); | 566 total_input_handling_time_this_frame_ = base::TimeDelta(); |
| 561 } | 567 } |
| 562 | 568 |
| 563 } // namespace content | 569 } // namespace content |
| OLD | NEW |