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> |
| 8 #include <stdint.h> |
| 9 |
7 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
8 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
9 #include "base/trace_event/trace_event_synthetic_delay.h" | 12 #include "base/trace_event/trace_event_synthetic_delay.h" |
| 13 #include "build/build_config.h" |
10 #include "cc/trees/swap_promise_monitor.h" | 14 #include "cc/trees/swap_promise_monitor.h" |
11 #include "components/scheduler/renderer/renderer_scheduler.h" | 15 #include "components/scheduler/renderer/renderer_scheduler.h" |
12 #include "content/common/input/input_event_ack.h" | 16 #include "content/common/input/input_event_ack.h" |
13 #include "content/common/input/input_event_ack_state.h" | 17 #include "content/common/input/input_event_ack_state.h" |
14 #include "content/common/input/web_input_event_traits.h" | 18 #include "content/common/input/web_input_event_traits.h" |
15 #include "content/renderer/gpu/render_widget_compositor.h" | 19 #include "content/renderer/gpu/render_widget_compositor.h" |
16 #include "content/renderer/ime_event_guard.h" | 20 #include "content/renderer/ime_event_guard.h" |
17 #include "content/renderer/input/render_widget_input_handler_delegate.h" | 21 #include "content/renderer/input/render_widget_input_handler_delegate.h" |
18 #include "content/renderer/render_thread_impl.h" | 22 #include "content/renderer/render_thread_impl.h" |
19 #include "content/renderer/render_widget.h" | 23 #include "content/renderer/render_widget.h" |
(...skipping 20 matching lines...) Expand all Loading... |
40 namespace content { | 44 namespace content { |
41 | 45 |
42 namespace { | 46 namespace { |
43 | 47 |
44 // TODO(brianderson): Replace the hard-coded threshold with a fraction of | 48 // TODO(brianderson): Replace the hard-coded threshold with a fraction of |
45 // the BeginMainFrame interval. | 49 // the BeginMainFrame interval. |
46 // 4166us will allow 1/4 of a 60Hz interval or 1/2 of a 120Hz interval to | 50 // 4166us will allow 1/4 of a 60Hz interval or 1/2 of a 120Hz interval to |
47 // be spent in input hanlders before input starts getting throttled. | 51 // be spent in input hanlders before input starts getting throttled. |
48 const int kInputHandlingTimeThrottlingThresholdMicroseconds = 4166; | 52 const int kInputHandlingTimeThrottlingThresholdMicroseconds = 4166; |
49 | 53 |
50 int64 GetEventLatencyMicros(double event_timestamp, base::TimeTicks now) { | 54 int64_t GetEventLatencyMicros(double event_timestamp, base::TimeTicks now) { |
51 return (now - base::TimeDelta::FromSecondsD(event_timestamp)) | 55 return (now - base::TimeDelta::FromSecondsD(event_timestamp)) |
52 .ToInternalValue(); | 56 .ToInternalValue(); |
53 } | 57 } |
54 | 58 |
55 void LogInputEventLatencyUmaImpl(WebInputEvent::Type event_type, | 59 void LogInputEventLatencyUmaImpl(WebInputEvent::Type event_type, |
56 double event_timestamp, | 60 double event_timestamp, |
57 base::TimeTicks now) { | 61 base::TimeTicks now) { |
58 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.AggregatedLatency.Renderer2", | 62 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.AggregatedLatency.Renderer2", |
59 GetEventLatencyMicros(event_timestamp, now), 1, | 63 GetEventLatencyMicros(event_timestamp, now), 1, |
60 10000000, 100); | 64 10000000, 100); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 void LogInputEventLatencyUma(const WebInputEvent& event, | 117 void LogInputEventLatencyUma(const WebInputEvent& event, |
114 base::TimeTicks now, | 118 base::TimeTicks now, |
115 const ui::LatencyInfo& latency_info) { | 119 const ui::LatencyInfo& latency_info) { |
116 LogInputEventLatencyUmaImpl(event.type, event.timeStampSeconds, now); | 120 LogInputEventLatencyUmaImpl(event.type, event.timeStampSeconds, now); |
117 for (size_t i = 0; i < latency_info.coalesced_events_size(); i++) { | 121 for (size_t i = 0; i < latency_info.coalesced_events_size(); i++) { |
118 LogInputEventLatencyUmaImpl( | 122 LogInputEventLatencyUmaImpl( |
119 event.type, latency_info.timestamps_of_coalesced_events()[i], now); | 123 event.type, latency_info.timestamps_of_coalesced_events()[i], now); |
120 } | 124 } |
121 } | 125 } |
122 | 126 |
123 void LogPassiveLatency(int64 latency) { | 127 void LogPassiveLatency(int64_t latency) { |
124 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.PassiveListeners.Latency", latency, 1, | 128 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.PassiveListeners.Latency", latency, 1, |
125 10000000, 100); | 129 10000000, 100); |
126 } | 130 } |
127 | 131 |
128 void LogPassiveEventListenersUma(WebInputEventResult result, | 132 void LogPassiveEventListenersUma(WebInputEventResult result, |
129 bool passive, | 133 bool passive, |
130 bool cancelable, | 134 bool cancelable, |
131 double event_timestamp, | 135 double event_timestamp, |
132 const ui::LatencyInfo& latency_info) { | 136 const ui::LatencyInfo& latency_info) { |
133 enum { | 137 enum { |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 if (pending_input_event_ack_) { | 485 if (pending_input_event_ack_) { |
482 TRACE_EVENT_ASYNC_END0("input", | 486 TRACE_EVENT_ASYNC_END0("input", |
483 "RenderWidgetInputHandler::ThrottledInputEventAck", | 487 "RenderWidgetInputHandler::ThrottledInputEventAck", |
484 pending_input_event_ack_.get()); | 488 pending_input_event_ack_.get()); |
485 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); | 489 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); |
486 } | 490 } |
487 total_input_handling_time_this_frame_ = base::TimeDelta(); | 491 total_input_handling_time_this_frame_ = base::TimeDelta(); |
488 } | 492 } |
489 | 493 |
490 } // namespace content | 494 } // namespace content |
OLD | NEW |