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

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

Issue 1984173002: Log First User Interaction in Page Load Metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Plumbing RWH latency tracker instead of DidGetUserInteraction API Created 4 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 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.h" 10 #include "base/metrics/histogram.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 DCHECK_EQ(0, last_event_id_); 298 DCHECK_EQ(0, last_event_id_);
299 DCHECK_EQ(0, latency_component_id_); 299 DCHECK_EQ(0, latency_component_id_);
300 last_event_id_ = static_cast<int64_t>(process_id) << 32; 300 last_event_id_ = static_cast<int64_t>(process_id) << 32;
301 latency_component_id_ = routing_id | last_event_id_; 301 latency_component_id_ = routing_id | last_event_id_;
302 } 302 }
303 303
304 void RenderWidgetHostLatencyTracker::OnInputEvent( 304 void RenderWidgetHostLatencyTracker::OnInputEvent(
305 const blink::WebInputEvent& event, 305 const blink::WebInputEvent& event,
306 LatencyInfo* latency) { 306 LatencyInfo* latency) {
307 DCHECK(latency); 307 DCHECK(latency);
308
309 for (size_t i = 0; i < input_event_callbacks_.size(); ++i) {
310 input_event_callbacks_[i].Run(event);
311 }
312
308 if (latency->FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 313 if (latency->FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
309 latency_component_id_, NULL)) { 314 latency_component_id_, NULL)) {
310 return; 315 return;
311 } 316 }
312 317
313 if (event.timeStampSeconds && 318 if (event.timeStampSeconds &&
314 !latency->FindLatency(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 319 !latency->FindLatency(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
315 0, NULL)) { 320 0, NULL)) {
316 base::TimeTicks timestamp_now = base::TimeTicks::Now(); 321 base::TimeTicks timestamp_now = base::TimeTicks::Now();
317 base::TimeTicks timestamp_original = base::TimeTicks() + 322 base::TimeTicks timestamp_original = base::TimeTicks() +
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 468 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
464 latency_component_id_, nullptr)) { 469 latency_component_id_, nullptr)) {
465 return; 470 return;
466 } 471 }
467 472
468 ComputeScrollLatencyHistograms(gpu_swap_begin_component, 473 ComputeScrollLatencyHistograms(gpu_swap_begin_component,
469 gpu_swap_end_component, latency_component_id_, 474 gpu_swap_end_component, latency_component_id_,
470 latency); 475 latency);
471 } 476 }
472 477
478 void RenderWidgetHostLatencyTracker::AddInputEventCallback(
479 const InputEventCallback& callback) {
480 input_event_callbacks_.push_back(callback);
481 }
482
483 void RenderWidgetHostLatencyTracker::RemoveInputEventCallback(
484 const InputEventCallback& callback) {
485 for (size_t i = 0; i < input_event_callbacks_.size(); ++i) {
486 if (input_event_callbacks_[i].Equals(callback)) {
487 input_event_callbacks_.erase(input_event_callbacks_.begin() + i);
488 return;
489 }
490 }
491 }
492
473 } // namespace content 493 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698