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

Side by Side Diff: content/browser/renderer_host/input/render_widget_host_latency_tracker.cc

Issue 2492793004: Add TimeToScrollUpdateSwapBegin2 in RAPPOR (Closed)
Patch Set: Rebase on top of plumbing Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/renderer_host/input/render_widget_host_latency_tracker .h" 5 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker .h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "components/rappor/public/rappor_utils.h"
12 #include "content/browser/renderer_host/render_widget_host_impl.h" 13 #include "content/browser/renderer_host/render_widget_host_impl.h"
14 #include "content/public/browser/content_browser_client.h"
15 #include "content/public/common/content_client.h"
13 #include "ui/events/blink/web_input_event_traits.h" 16 #include "ui/events/blink/web_input_event_traits.h"
14 17
15 using blink::WebGestureEvent; 18 using blink::WebGestureEvent;
16 using blink::WebInputEvent; 19 using blink::WebInputEvent;
17 using blink::WebMouseEvent; 20 using blink::WebMouseEvent;
18 using blink::WebMouseWheelEvent; 21 using blink::WebMouseWheelEvent;
19 using blink::WebTouchEvent; 22 using blink::WebTouchEvent;
20 using ui::LatencyInfo; 23 using ui::LatencyInfo;
21 24
22 namespace content { 25 namespace content {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 UMA_HISTOGRAM_SCROLL_LATENCY_LONG( 234 UMA_HISTOGRAM_SCROLL_LATENCY_LONG(
232 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", 235 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap",
233 browser_received_swap_component, gpu_swap_begin_component); 236 browser_received_swap_component, gpu_swap_begin_component);
234 237
235 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", 238 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap",
236 gpu_swap_begin_component, 239 gpu_swap_begin_component,
237 gpu_swap_end_component); 240 gpu_swap_end_component);
238 } 241 }
239 242
240 void ComputeTouchAndWheelScrollLatencyHistograms( 243 void ComputeTouchAndWheelScrollLatencyHistograms(
244 RenderWidgetHostImpl* render_widget_host_impl,
241 const ui::LatencyInfo::LatencyComponent& gpu_swap_begin_component, 245 const ui::LatencyInfo::LatencyComponent& gpu_swap_begin_component,
242 const ui::LatencyInfo::LatencyComponent& gpu_swap_end_component, 246 const ui::LatencyInfo::LatencyComponent& gpu_swap_end_component,
243 int64_t latency_component_id, 247 int64_t latency_component_id,
244 const ui::LatencyInfo& latency, 248 const ui::LatencyInfo& latency,
245 const std::string event_type_name) { 249 const std::string event_type_name) {
246 DCHECK(!latency.coalesced()); 250 DCHECK(!latency.coalesced());
247 if (latency.coalesced()) 251 if (latency.coalesced())
248 return; 252 return;
249 253
250 LatencyInfo::LatencyComponent original_component; 254 LatencyInfo::LatencyComponent original_component;
(...skipping 21 matching lines...) Expand all
272 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 276 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
273 latency_component_id, &original_component)) { 277 latency_component_id, &original_component)) {
274 // This UMA metric tracks the time from when the original touch event is 278 // This UMA metric tracks the time from when the original touch event is
275 // created to when the scroll gesture results in final frame swap. 279 // created to when the scroll gesture results in final frame swap.
276 // First scroll events are excluded from this metric. 280 // First scroll events are excluded from this metric.
277 if (event_type_name == "Touch") { 281 if (event_type_name == "Touch") {
278 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY( 282 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY(
279 "Event.Latency.ScrollUpdate." + event_type_name + 283 "Event.Latency.ScrollUpdate." + event_type_name +
280 ".TimeToScrollUpdateSwapBegin2", 284 ".TimeToScrollUpdateSwapBegin2",
281 original_component, gpu_swap_begin_component); 285 original_component, gpu_swap_begin_component);
286
287 rappor::RapporService* rappor_service =
288 GetContentClient()->browser()->GetRapporService();
289 if (!rappor_service || !render_widget_host_impl->delegate())
290 return;
291 std::unique_ptr<rappor::Sample> sample =
292 rappor_service->CreateSample(rappor::UMA_RAPPOR_TYPE);
293 render_widget_host_impl->delegate()->AddDomainInfoToRapporSample(
294 sample.get());
295 sample->SetUInt64Field("Latency",
296 (gpu_swap_begin_component.last_event_time -
297 original_component.first_event_time)
298 .InMicroseconds(),
299 rappor::NO_NOISE);
ncarter (slow) 2016/12/08 17:57:27 Regarding testing, the simplest thing to do would
300 rappor_service->RecordSample(
301 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2",
tdresser 2016/12/08 18:00:17 Should we add Event.Latency.ScrollBegin.Touch.Time
Navid Zolghadr 2016/12/09 19:13:28 Let me work on adding that and some refactoring be
302 std::move(sample));
282 } 303 }
283 } else { 304 } else {
284 // No original component found. 305 // No original component found.
285 return; 306 return;
286 } 307 }
287 308
288 LatencyInfo::LatencyComponent rendering_scheduled_component; 309 LatencyInfo::LatencyComponent rendering_scheduled_component;
289 bool rendering_scheduled_on_main = latency.FindLatency( 310 bool rendering_scheduled_on_main = latency.FindLatency(
290 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, 311 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0,
291 &rendering_scheduled_component); 312 &rendering_scheduled_component);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 new_components_key[i].first, 380 new_components_key[i].first,
360 new_components_key[i].second, 381 new_components_key[i].second,
361 new_components_value[i].sequence_number, 382 new_components_value[i].sequence_number,
362 new_components_value[i].event_time, 383 new_components_value[i].event_time,
363 new_components_value[i].event_count); 384 new_components_value[i].event_count);
364 } 385 }
365 } 386 }
366 387
367 } // namespace 388 } // namespace
368 389
369 RenderWidgetHostLatencyTracker::RenderWidgetHostLatencyTracker() 390 RenderWidgetHostLatencyTracker::RenderWidgetHostLatencyTracker(
391 RenderWidgetHostImpl* render_widget_host_impl)
370 : last_event_id_(0), 392 : last_event_id_(0),
371 latency_component_id_(0), 393 latency_component_id_(0),
372 device_scale_factor_(1), 394 device_scale_factor_(1),
373 has_seen_first_gesture_scroll_update_(false), 395 has_seen_first_gesture_scroll_update_(false),
374 multi_finger_gesture_(false), 396 multi_finger_gesture_(false),
375 touch_start_default_prevented_(false) {} 397 touch_start_default_prevented_(false),
398 render_widget_host_impl(render_widget_host_impl) {}
376 399
377 RenderWidgetHostLatencyTracker::~RenderWidgetHostLatencyTracker() {} 400 RenderWidgetHostLatencyTracker::~RenderWidgetHostLatencyTracker() {}
378 401
379 void RenderWidgetHostLatencyTracker::Initialize(int routing_id, 402 void RenderWidgetHostLatencyTracker::Initialize(int routing_id,
380 int process_id) { 403 int process_id) {
381 DCHECK_EQ(0, last_event_id_); 404 DCHECK_EQ(0, last_event_id_);
382 DCHECK_EQ(0, latency_component_id_); 405 DCHECK_EQ(0, latency_component_id_);
383 last_event_id_ = static_cast<int64_t>(process_id) << 32; 406 last_event_id_ = static_cast<int64_t>(process_id) << 32;
384 latency_component_id_ = routing_id | last_event_id_; 407 latency_component_id_ = routing_id | last_event_id_;
385 } 408 }
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 727
705 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 728 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
706 latency_component_id_, nullptr)) { 729 latency_component_id_, nullptr)) {
707 return; 730 return;
708 } 731 }
709 732
710 ui::SourceEventType source_event_type = latency.source_event_type(); 733 ui::SourceEventType source_event_type = latency.source_event_type();
711 if (source_event_type == ui::SourceEventType::WHEEL || 734 if (source_event_type == ui::SourceEventType::WHEEL ||
712 source_event_type == ui::SourceEventType::TOUCH) { 735 source_event_type == ui::SourceEventType::TOUCH) {
713 ComputeTouchAndWheelScrollLatencyHistograms( 736 ComputeTouchAndWheelScrollLatencyHistograms(
714 gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_, 737 render_widget_host_impl, gpu_swap_begin_component,
715 latency, 738 gpu_swap_end_component, latency_component_id_, latency,
716 source_event_type == ui::SourceEventType::WHEEL ? "Wheel" : "Touch"); 739 source_event_type == ui::SourceEventType::WHEEL ? "Wheel" : "Touch");
717 } 740 }
718 741
719 // Compute the old scroll update latency metrics. They are exclusively 742 // Compute the old scroll update latency metrics. They are exclusively
720 // calculated for touch scrolls, and will be deprecated on M56. 743 // calculated for touch scrolls, and will be deprecated on M56.
721 // (https://crbug.com/649754) 744 // (https://crbug.com/649754)
722 LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component; 745 LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component;
723 if (!latency.FindLatency( 746 if (!latency.FindLatency(
724 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, 747 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0,
725 &mouse_wheel_scroll_update_component)) { 748 &mouse_wheel_scroll_update_component)) {
726 ComputeScrollLatencyHistograms( 749 ComputeScrollLatencyHistograms(
727 gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_, 750 gpu_swap_begin_component, gpu_swap_end_component, latency_component_id_,
728 latency, is_running_navigation_hint_task); 751 latency, is_running_navigation_hint_task);
729 } 752 }
730 } 753 }
731 754
732 } // namespace content 755 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698