blob: f301ef08e43c4dc90cd1aa57202315dd85acf242 [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/time/time.h"
namespace ui {
class EventWithCallback;
// Class which is used during a scroll event to detect, accumulate, and log
// jank metrics for the momentum phase.
class MomentumScrollJankTracker {
void OnDispatchedInputEvent(EventWithCallback* event_with_callback,
const base::TimeTicks& now);
// The number of expected momentum events which should be coalesced in a
// single frame.
// If we update momentum event generation to happen more than once per frame,
// |kExpectedMomentumEventsPerFrame| should be updated or this data plumbed
// in from a different source.
static constexpr uint32_t kExpectedMomentumEventsPerFrame = 1;
// The amount of time elapsed between coalescing an event and dispatching the
// event for which we consider the coalescing to be "recent" for the purposes
// of
static constexpr base::TimeDelta kRecentEventCutoff =
// |jank_count_| is the number of coalesced momentum input events above
// kExptectedMomentumEventsPerFrame.
uint32_t jank_count_ = 0;
// |ordering_jank_count_| specifically addresses
// Counts cases where we coalesce input very close to processing it,
// indicating an unstable ordering of begin frame wrt. input delivery.
uint32_t ordering_jank_count_ = 0;
// The number of events processed during a gesture.
uint32_t total_event_count_ = 0;
// Used to avoid tracking jank in the first momentum event, as this may be
// unreliable.
bool seen_first_momentum_input_ = false;
} // namespace ui