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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/render_widget_host_latency_tracker.cc
diff --git a/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc b/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc
index 26f0c1e5e751e92686dbf821056e85c8df926dc2..9b1e1db6c2d12a34d745cb393d52c34b176b9daa 100644
--- a/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc
+++ b/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc
@@ -11,6 +11,8 @@
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#include "components/rappor/public/rappor_utils.h"
+#include "components/ukm/public/ukm_entry_builder.h"
+#include "components/ukm/public/ukm_recorder.h"
#include "content/browser/renderer_host/render_widget_host_delegate.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/content_client.h"
@@ -27,6 +29,8 @@ using ui::LatencyInfo;
namespace content {
namespace {
+const char kLatency[] = "Latency";
+
std::string WebInputEventTypeToInputModalityString(WebInputEvent::Type type) {
if (type == blink::WebInputEvent::kMouseWheel) {
return "Wheel";
@@ -325,4 +329,35 @@ void RenderWidgetHostLatencyTracker::ReportRapporScrollLatency(
}
}
+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
+ ukm::UkmRecorder* ukm_recorder =
+ 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
+ int32_t ukm_source_id = -1;
+ if (ukm_recorder) {
+ ukm_source_id = ukm_recorder->GetNewSourceID();
+ render_widget_host_delegate_->UpdateUrlForUkmSource(ukm_recorder,
+ ukm_source_id);
+ }
+ return ukm_source_id;
+}
+
+void RenderWidgetHostLatencyTracker::ReportUkmScrollLatency(
+ const std::string& name,
+ const LatencyInfo::LatencyComponent& start_component,
+ const LatencyInfo::LatencyComponent& end_component) {
+ CONFIRM_VALID_TIMING(start_component, end_component)
+
+ int32_t ukm_source_id = GetUkmSourceId();
+ if (ukm_source_id == -1)
+ return;
+
+ ukm::UkmRecorder* ukm_recorder =
+ GetContentClient()->browser()->GetUkmRecorder();
+
+ 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.
+ ukm_recorder->GetEntryBuilder(ukm_source_id, name.c_str());
+ builder->AddMetric(kLatency, (end_component.last_event_time -
+ start_component.first_event_time)
+ .InMicroseconds());
+}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698