#ifndef ASH_METRICS_UI_METRICS_RECORDER_H_
#define ASH_METRICS_UI_METRICS_RECORDER_H_
#include <optional>
#include <string_view>
#include <vector>
#include "ash/ash_export.h"
#include "base/containers/span.h"
#include "base/sequence_checker.h"
#include "base/time/time.h"
#include "cc/metrics/custom_metrics_recorder.h"
#include "cc/metrics/event_latency_tracker.h"
namespace ash {
class ASH_EXPORT UiMetricsRecorder : public cc::CustomMetricRecorder {
public:
enum class FpsBucket {
k30Fps,
k60Fps,
k120Fps,
kOtherFps,
kUnset,
kMaxValue = kUnset,
};
static constexpr int kMaxFpsBucketIndex =
static_cast<int>(FpsBucket::kMaxValue) + 1;
enum class CoreEventType {
kKeyPressed,
kKeyReleased,
kMousePressed,
kMouseReleased,
kMouseDragged,
kMaxValue = kMouseDragged,
};
static constexpr int kMaxCoreEventTypeIndex =
static_cast<int>(CoreEventType::kMaxValue) + 1;
UiMetricsRecorder();
~UiMetricsRecorder() override;
void OnUserLoggedIn();
void OnPostLoginAnimationFinish();
void ReportPercentDroppedFramesInOneSecondWindow2(double percent) override;
void ReportEventLatency(
const viz::BeginFrameArgs& args,
std::vector<cc::EventLatencyTracker::LatencyData> latencies) override;
static base::span<const std::string_view>
GetEventLatencyHistogramNamesForTest();
static base::span<const std::string_view>
GetCoreEventLatencyHistogramNamesForTest();
private:
enum class State {
kBeforeLogin,
kDuringLogin,
kInSession,
};
State state_ = State::kBeforeLogin;
SEQUENCE_CHECKER(sequence_checker_);
std::optional<base::TimeTicks> user_logged_in_time_;
std::optional<base::TimeTicks> user_session_start_time_;
std::optional<base::TimeTicks> last_good_dropped_frame_time_;
};
}
#endif