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

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

Issue 2888153002: Add TimeToScrollUpdateSwapBegin2 to UKM (Closed)
Patch Set: Rebase and use new constructs Created 3 years, 6 months 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_functions.h" 10 #include "base/metrics/histogram_functions.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "components/rappor/public/rappor_utils.h" 13 #include "components/rappor/public/rappor_utils.h"
14 #include "components/ukm/public/ukm_entry_builder.h"
15 #include "components/ukm/public/ukm_recorder.h"
14 #include "content/browser/renderer_host/render_widget_host_delegate.h" 16 #include "content/browser/renderer_host/render_widget_host_delegate.h"
15 #include "content/public/browser/content_browser_client.h" 17 #include "content/public/browser/content_browser_client.h"
16 #include "content/public/common/content_client.h" 18 #include "content/public/common/content_client.h"
17 #include "ui/events/blink/web_input_event_traits.h" 19 #include "ui/events/blink/web_input_event_traits.h"
18 #include "ui/latency/latency_histogram_macros.h" 20 #include "ui/latency/latency_histogram_macros.h"
19 21
20 using blink::WebGestureEvent; 22 using blink::WebGestureEvent;
21 using blink::WebInputEvent; 23 using blink::WebInputEvent;
22 using blink::WebMouseEvent; 24 using blink::WebMouseEvent;
23 using blink::WebMouseWheelEvent; 25 using blink::WebMouseWheelEvent;
24 using blink::WebTouchEvent; 26 using blink::WebTouchEvent;
25 using ui::LatencyInfo; 27 using ui::LatencyInfo;
26 28
27 namespace content { 29 namespace content {
28 namespace { 30 namespace {
29 31
32 const char kLatency[] = "Latency";
33
30 std::string WebInputEventTypeToInputModalityString(WebInputEvent::Type type) { 34 std::string WebInputEventTypeToInputModalityString(WebInputEvent::Type type) {
31 if (type == blink::WebInputEvent::kMouseWheel) { 35 if (type == blink::WebInputEvent::kMouseWheel) {
32 return "Wheel"; 36 return "Wheel";
33 } else if (WebInputEvent::IsKeyboardEventType(type)) { 37 } else if (WebInputEvent::IsKeyboardEventType(type)) {
34 // We should only be reporting latency for key presses. 38 // We should only be reporting latency for key presses.
35 DCHECK(type == WebInputEvent::kRawKeyDown || type == WebInputEvent::kChar); 39 DCHECK(type == WebInputEvent::kRawKeyDown || type == WebInputEvent::kChar);
36 return "KeyPress"; 40 return "KeyPress";
37 } else if (WebInputEvent::IsMouseEventType(type)) { 41 } else if (WebInputEvent::IsMouseEventType(type)) {
38 return "Mouse"; 42 return "Mouse";
39 } else if (WebInputEvent::IsTouchEventType(type)) { 43 } else if (WebInputEvent::IsTouchEventType(type)) {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 render_widget_host_delegate_->AddDomainInfoToRapporSample(sample.get()); 322 render_widget_host_delegate_->AddDomainInfoToRapporSample(sample.get());
319 sample->SetUInt64Field( 323 sample->SetUInt64Field(
320 "Latency", 324 "Latency",
321 (end_component.last_event_time - start_component.first_event_time) 325 (end_component.last_event_time - start_component.first_event_time)
322 .InMicroseconds(), 326 .InMicroseconds(),
323 rappor::NO_NOISE); 327 rappor::NO_NOISE);
324 rappor_service->RecordSample(name, std::move(sample)); 328 rappor_service->RecordSample(name, std::move(sample));
325 } 329 }
326 } 330 }
327 331
332 int32_t RenderWidgetHostLatencyTracker::GetUkmSourceId() {
tdresser 2017/05/30 16:52:07 The name of this implies to me that it always gets
Navid Zolghadr 2017/05/31 20:37:15 I wasn't sure if I had to reuse the id. But now th
333 ukm::UkmRecorder* ukm_recorder =
334 GetContentClient()->browser()->GetUkmRecorder();
Navid Zolghadr 2017/05/26 15:15:43 I recently added this plumbing in this CL: https:/
rkaplow 2017/05/30 20:03:32 +oystein - can you answer
Navid Zolghadr 2017/05/31 20:37:15 I started using ukm::UkmRecorder::Get() and remove
335 int32_t ukm_source_id = -1;
336 if (ukm_recorder) {
337 ukm_source_id = ukm_recorder->GetNewSourceID();
338 render_widget_host_delegate_->UpdateUrlForUkmSource(ukm_recorder,
339 ukm_source_id);
340 }
341 return ukm_source_id;
342 }
343
344 void RenderWidgetHostLatencyTracker::ReportUkmScrollLatency(
345 const std::string& name,
346 const LatencyInfo::LatencyComponent& start_component,
347 const LatencyInfo::LatencyComponent& end_component) {
348 CONFIRM_VALID_TIMING(start_component, end_component)
349
350 int32_t ukm_source_id = GetUkmSourceId();
351 if (ukm_source_id == -1)
352 return;
353
354 ukm::UkmRecorder* ukm_recorder =
355 GetContentClient()->browser()->GetUkmRecorder();
356
357 std::unique_ptr<ukm::UkmEntryBuilder> builder =
tdresser 2017/05/30 16:52:07 Does this need to be a unique_ptr, or can it be st
Navid Zolghadr 2017/05/31 20:37:15 You mean the normal object with no pointer? But th
tdresser 2017/06/01 12:44:44 Acknowledged.
358 ukm_recorder->GetEntryBuilder(ukm_source_id, name.c_str());
359 builder->AddMetric(kLatency, (end_component.last_event_time -
360 start_component.first_event_time)
361 .InMicroseconds());
362 }
328 } // namespace content 363 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698