| 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 |
| 11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/trace_event/trace_event_synthetic_delay.h" | 14 #include "base/trace_event/trace_event_synthetic_delay.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "cc/trees/swap_promise_monitor.h" | 16 #include "cc/trees/swap_promise_monitor.h" |
| 17 #include "content/common/input/input_event_ack.h" | 17 #include "content/common/input/input_event_ack.h" |
| 18 #include "content/common/input/input_event_ack_state.h" | 18 #include "content/common/input/input_event_ack_state.h" |
| 19 #include "content/common/input/web_input_event_traits.h" | |
| 20 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
| 21 #include "content/renderer/gpu/render_widget_compositor.h" | 20 #include "content/renderer/gpu/render_widget_compositor.h" |
| 22 #include "content/renderer/ime_event_guard.h" | 21 #include "content/renderer/ime_event_guard.h" |
| 23 #include "content/renderer/input/render_widget_input_handler_delegate.h" | 22 #include "content/renderer/input/render_widget_input_handler_delegate.h" |
| 24 #include "content/renderer/render_thread_impl.h" | 23 #include "content/renderer/render_thread_impl.h" |
| 25 #include "content/renderer/render_widget.h" | 24 #include "content/renderer/render_widget.h" |
| 26 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 25 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
| 27 #include "third_party/WebKit/public/platform/WebFloatSize.h" | 26 #include "third_party/WebKit/public/platform/WebFloatSize.h" |
| 28 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul
er.h" | 27 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul
er.h" |
| 28 #include "ui/events/blink/web_input_event_traits.h" |
| 29 #include "ui/events/latency_info.h" | 29 #include "ui/events/latency_info.h" |
| 30 #include "ui/gfx/geometry/point_conversions.h" | 30 #include "ui/gfx/geometry/point_conversions.h" |
| 31 | 31 |
| 32 #if defined(OS_ANDROID) | 32 #if defined(OS_ANDROID) |
| 33 #include <android/keycodes.h> | 33 #include <android/keycodes.h> |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 using blink::WebFloatPoint; | 36 using blink::WebFloatPoint; |
| 37 using blink::WebFloatSize; | 37 using blink::WebFloatSize; |
| 38 using blink::WebGestureEvent; | 38 using blink::WebGestureEvent; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 ImeEventGuard guard(widget_); | 239 ImeEventGuard guard(widget_); |
| 240 guard.set_from_ime(from_ime); | 240 guard.set_from_ime(from_ime); |
| 241 #endif | 241 #endif |
| 242 | 242 |
| 243 base::TimeTicks start_time; | 243 base::TimeTicks start_time; |
| 244 if (base::TimeTicks::IsHighResolution()) | 244 if (base::TimeTicks::IsHighResolution()) |
| 245 start_time = base::TimeTicks::Now(); | 245 start_time = base::TimeTicks::Now(); |
| 246 | 246 |
| 247 TRACE_EVENT1("renderer,benchmark,rail", | 247 TRACE_EVENT1("renderer,benchmark,rail", |
| 248 "RenderWidgetInputHandler::OnHandleInputEvent", "event", | 248 "RenderWidgetInputHandler::OnHandleInputEvent", "event", |
| 249 WebInputEventTraits::GetName(input_event.type)); | 249 ui::WebInputEventTraits::GetName(input_event.type)); |
| 250 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent"); | 250 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent"); |
| 251 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow", | 251 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow", |
| 252 TRACE_ID_DONT_MANGLE(latency_info.trace_id()), | 252 TRACE_ID_DONT_MANGLE(latency_info.trace_id()), |
| 253 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, | 253 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, |
| 254 "step", "HandleInputEventMain"); | 254 "step", "HandleInputEventMain"); |
| 255 | 255 |
| 256 // If we don't have a high res timer, these metrics won't be accurate enough | 256 // If we don't have a high res timer, these metrics won't be accurate enough |
| 257 // to be worth collecting. Note that this does introduce some sampling bias. | 257 // to be worth collecting. Note that this does introduce some sampling bias. |
| 258 if (!start_time.is_null()) | 258 if (!start_time.is_null()) |
| 259 LogInputEventLatencyUma(input_event, start_time); | 259 LogInputEventLatencyUma(input_event, start_time); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 // so let the delegate know the event has been handled. | 430 // so let the delegate know the event has been handled. |
| 431 delegate_->NotifyInputEventHandled(input_event.type, ack_result); | 431 delegate_->NotifyInputEventHandled(input_event.type, ack_result); |
| 432 } | 432 } |
| 433 | 433 |
| 434 if ((dispatch_type == DISPATCH_TYPE_BLOCKING || | 434 if ((dispatch_type == DISPATCH_TYPE_BLOCKING || |
| 435 dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN) && | 435 dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN) && |
| 436 can_send_ack) { | 436 can_send_ack) { |
| 437 std::unique_ptr<InputEventAck> response(new InputEventAck( | 437 std::unique_ptr<InputEventAck> response(new InputEventAck( |
| 438 input_event.type, ack_result, swap_latency_info, | 438 input_event.type, ack_result, swap_latency_info, |
| 439 std::move(event_overscroll), | 439 std::move(event_overscroll), |
| 440 WebInputEventTraits::GetUniqueTouchEventId(input_event))); | 440 ui::WebInputEventTraits::GetUniqueTouchEventId(input_event))); |
| 441 if (rate_limiting_wanted && frame_pending && !widget_->is_hidden()) { | 441 if (rate_limiting_wanted && frame_pending && !widget_->is_hidden()) { |
| 442 // We want to rate limit the input events in this case, so we'll wait for | 442 // We want to rate limit the input events in this case, so we'll wait for |
| 443 // painting to finish before ACKing this message. | 443 // painting to finish before ACKing this message. |
| 444 TRACE_EVENT_INSTANT0( | 444 TRACE_EVENT_INSTANT0( |
| 445 "renderer", | 445 "renderer", |
| 446 "RenderWidgetInputHandler::OnHandleInputEvent ack throttled", | 446 "RenderWidgetInputHandler::OnHandleInputEvent ack throttled", |
| 447 TRACE_EVENT_SCOPE_THREAD); | 447 TRACE_EVENT_SCOPE_THREAD); |
| 448 if (pending_input_event_ack_) { | 448 if (pending_input_event_ack_) { |
| 449 TRACE_EVENT_ASYNC_END0( | 449 TRACE_EVENT_ASYNC_END0( |
| 450 "input", "RenderWidgetInputHandler::ThrottledInputEventAck", | 450 "input", "RenderWidgetInputHandler::ThrottledInputEventAck", |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 if (pending_input_event_ack_) { | 555 if (pending_input_event_ack_) { |
| 556 TRACE_EVENT_ASYNC_END0("input", | 556 TRACE_EVENT_ASYNC_END0("input", |
| 557 "RenderWidgetInputHandler::ThrottledInputEventAck", | 557 "RenderWidgetInputHandler::ThrottledInputEventAck", |
| 558 pending_input_event_ack_.get()); | 558 pending_input_event_ack_.get()); |
| 559 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); | 559 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); |
| 560 } | 560 } |
| 561 total_input_handling_time_this_frame_ = base::TimeDelta(); | 561 total_input_handling_time_this_frame_ = base::TimeDelta(); |
| 562 } | 562 } |
| 563 | 563 |
| 564 } // namespace content | 564 } // namespace content |
| OLD | NEW |