Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: content/renderer/input/input_handler_proxy.cc

Issue 764403002: Expand UMA coverage for compositor-handled events and fling FPS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/input/input_handler_proxy.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/input_handler_proxy.h" 5 #include "content/renderer/input/input_handler_proxy.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 109
110 WebGestureEvent ObtainGestureScrollBegin(const WebGestureEvent& event) { 110 WebGestureEvent ObtainGestureScrollBegin(const WebGestureEvent& event) {
111 WebGestureEvent scroll_begin_event = event; 111 WebGestureEvent scroll_begin_event = event;
112 scroll_begin_event.type = WebInputEvent::GestureScrollBegin; 112 scroll_begin_event.type = WebInputEvent::GestureScrollBegin;
113 scroll_begin_event.data.scrollBegin.deltaXHint = 0; 113 scroll_begin_event.data.scrollBegin.deltaXHint = 0;
114 scroll_begin_event.data.scrollBegin.deltaYHint = 0; 114 scroll_begin_event.data.scrollBegin.deltaYHint = 0;
115 return scroll_begin_event; 115 return scroll_begin_event;
116 } 116 }
117 117
118 void SendScrollLatencyUma(const WebInputEvent& event, 118 void ReportInputEventLatencyUma(const WebInputEvent& event,
119 const ui::LatencyInfo& latency_info) { 119 const ui::LatencyInfo& latency_info) {
no sievers 2014/12/05 21:27:00 DCHECK(uma_latency_reporting_enabled_);
jdduke (slow) 2014/12/05 21:31:53 Hmm, this isn't a member function, though I could
no sievers 2014/12/05 21:33:52 Oops nevermind, no big deal.
120 if (!(event.type == WebInputEvent::GestureScrollBegin || 120 if (!(event.type == WebInputEvent::GestureScrollBegin ||
121 event.type == WebInputEvent::GestureScrollUpdate)) 121 event.type == WebInputEvent::GestureScrollUpdate ||
122 event.type == WebInputEvent::GesturePinchBegin ||
123 event.type == WebInputEvent::GesturePinchUpdate ||
124 event.type == WebInputEvent::GestureFlingStart)) {
122 return; 125 return;
126 }
123 127
124 ui::LatencyInfo::LatencyMap::const_iterator it = 128 ui::LatencyInfo::LatencyMap::const_iterator it =
125 latency_info.latency_components.find(std::make_pair( 129 latency_info.latency_components.find(std::make_pair(
126 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0)); 130 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0));
127 131
128 if (it == latency_info.latency_components.end()) 132 if (it == latency_info.latency_components.end())
129 return; 133 return;
130 134
131 base::TimeDelta delta = base::TimeTicks::HighResNow() - it->second.event_time; 135 base::TimeDelta delta = base::TimeTicks::HighResNow() - it->second.event_time;
132 for (size_t i = 0; i < it->second.event_count; ++i) { 136 for (size_t i = 0; i < it->second.event_count; ++i) {
133 UMA_HISTOGRAM_CUSTOM_COUNTS( 137 switch (event.type) {
134 "Event.Latency.RendererImpl.GestureScroll2", 138 case blink::WebInputEvent::GestureScrollBegin:
135 delta.InMicroseconds(), 139 UMA_HISTOGRAM_CUSTOM_COUNTS(
136 1, 140 "Event.Latency.RendererImpl.GestureScrollBegin",
137 1000000, 141 delta.InMicroseconds(), 1, 1000000, 100);
138 100); 142 break;
143 case blink::WebInputEvent::GestureScrollUpdate:
144 UMA_HISTOGRAM_CUSTOM_COUNTS(
145 // So named for historical reasons.
146 "Event.Latency.RendererImpl.GestureScroll2",
147 delta.InMicroseconds(), 1, 1000000, 100);
148 break;
149 case blink::WebInputEvent::GesturePinchBegin:
150 UMA_HISTOGRAM_CUSTOM_COUNTS(
151 "Event.Latency.RendererImpl.GesturePinchBegin",
152 delta.InMicroseconds(), 1, 1000000, 100);
153 break;
154 case blink::WebInputEvent::GesturePinchUpdate:
155 UMA_HISTOGRAM_CUSTOM_COUNTS(
156 "Event.Latency.RendererImpl.GesturePinchUpdate",
157 delta.InMicroseconds(), 1, 1000000, 100);
158 break;
159 case blink::WebInputEvent::GestureFlingStart:
160 UMA_HISTOGRAM_CUSTOM_COUNTS(
161 "Event.Latency.RendererImpl.GestureFlingStart",
162 delta.InMicroseconds(), 1, 1000000, 100);
163 break;
164 default:
165 NOTREACHED();
166 break;
167 }
139 } 168 }
169 }
170
140 } // namespace 171 } // namespace
141 172
142 }
143
144 namespace content { 173 namespace content {
145 174
146 InputHandlerProxy::InputHandlerProxy(cc::InputHandler* input_handler, 175 InputHandlerProxy::InputHandlerProxy(cc::InputHandler* input_handler,
147 InputHandlerProxyClient* client) 176 InputHandlerProxyClient* client)
148 : client_(client), 177 : client_(client),
149 input_handler_(input_handler), 178 input_handler_(input_handler),
150 deferred_fling_cancel_time_seconds_(0), 179 deferred_fling_cancel_time_seconds_(0),
151 #ifndef NDEBUG 180 #ifndef NDEBUG
152 expect_scroll_update_end_(false), 181 expect_scroll_update_end_(false),
153 #endif 182 #endif
154 gesture_scroll_on_impl_thread_(false), 183 gesture_scroll_on_impl_thread_(false),
155 gesture_pinch_on_impl_thread_(false), 184 gesture_pinch_on_impl_thread_(false),
156 fling_may_be_active_on_main_thread_(false), 185 fling_may_be_active_on_main_thread_(false),
157 disallow_horizontal_fling_scroll_(false), 186 disallow_horizontal_fling_scroll_(false),
158 disallow_vertical_fling_scroll_(false), 187 disallow_vertical_fling_scroll_(false),
159 has_fling_animation_started_(false) { 188 has_fling_animation_started_(false),
189 uma_latency_reporting_enabled_(
190 base::TimeTicks::IsHighResNowFastAndReliable()) {
160 DCHECK(client); 191 DCHECK(client);
161 input_handler_->BindToClient(this); 192 input_handler_->BindToClient(this);
162 smooth_scroll_enabled_ = CommandLine::ForCurrentProcess()->HasSwitch( 193 smooth_scroll_enabled_ = CommandLine::ForCurrentProcess()->HasSwitch(
163 switches::kEnableSmoothScrolling); 194 switches::kEnableSmoothScrolling);
164 195
165 #if defined(OS_MACOSX) 196 #if defined(OS_MACOSX)
166 if (CommandLine::ForCurrentProcess()->HasSwitch( 197 if (CommandLine::ForCurrentProcess()->HasSwitch(
167 switches::kEnableThreadedEventHandlingMac)) { 198 switches::kEnableThreadedEventHandlingMac)) {
168 scroll_elasticity_controller_.reset(new InputScrollElasticityController( 199 scroll_elasticity_controller_.reset(new InputScrollElasticityController(
169 input_handler_->CreateScrollElasticityHelper())); 200 input_handler_->CreateScrollElasticityHelper()));
170 } 201 }
171 #endif 202 #endif
172 } 203 }
173 204
174 InputHandlerProxy::~InputHandlerProxy() {} 205 InputHandlerProxy::~InputHandlerProxy() {}
175 206
176 void InputHandlerProxy::WillShutdown() { 207 void InputHandlerProxy::WillShutdown() {
177 scroll_elasticity_controller_.reset(); 208 scroll_elasticity_controller_.reset();
178 input_handler_ = NULL; 209 input_handler_ = NULL;
179 client_->WillShutdown(); 210 client_->WillShutdown();
180 } 211 }
181 212
182 InputHandlerProxy::EventDisposition 213 InputHandlerProxy::EventDisposition
183 InputHandlerProxy::HandleInputEventWithLatencyInfo( 214 InputHandlerProxy::HandleInputEventWithLatencyInfo(
184 const WebInputEvent& event, 215 const WebInputEvent& event,
185 ui::LatencyInfo* latency_info) { 216 ui::LatencyInfo* latency_info) {
186 DCHECK(input_handler_); 217 DCHECK(input_handler_);
187 218
188 SendScrollLatencyUma(event, *latency_info); 219 if (uma_latency_reporting_enabled_)
220 ReportInputEventLatencyUma(event, *latency_info);
189 221
190 TRACE_EVENT_FLOW_STEP0("input", 222 TRACE_EVENT_FLOW_STEP0("input",
191 "LatencyInfo.Flow", 223 "LatencyInfo.Flow",
192 TRACE_ID_DONT_MANGLE(latency_info->trace_id), 224 TRACE_ID_DONT_MANGLE(latency_info->trace_id),
193 "HandleInputEventImpl"); 225 "HandleInputEventImpl");
194 226
195 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor = 227 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor =
196 input_handler_->CreateLatencyInfoSwapPromiseMonitor(latency_info); 228 input_handler_->CreateLatencyInfoSwapPromiseMonitor(latency_info);
197 InputHandlerProxy::EventDisposition disposition = HandleInputEvent(event); 229 InputHandlerProxy::EventDisposition disposition = HandleInputEvent(event);
198 return disposition; 230 return disposition;
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 // trigger a scroll, e.g., with a trivial time delta between fling updates. 918 // trigger a scroll, e.g., with a trivial time delta between fling updates.
887 // Return true in this case to prevent early fling termination. 919 // Return true in this case to prevent early fling termination.
888 if (std::abs(clipped_increment.width) < kScrollEpsilon && 920 if (std::abs(clipped_increment.width) < kScrollEpsilon &&
889 std::abs(clipped_increment.height) < kScrollEpsilon) 921 std::abs(clipped_increment.height) < kScrollEpsilon)
890 return true; 922 return true;
891 923
892 return did_scroll; 924 return did_scroll;
893 } 925 }
894 926
895 } // namespace content 927 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/input_handler_proxy.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698