ui_throughput_recorder.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_METRICS_UI_THROUGHPUT_RECORDER_H_
  5. #define ASH_METRICS_UI_THROUGHPUT_RECORDER_H_
  6. #include "ash/ash_export.h"
  7. #include "base/sequence_checker.h"
  8. #include "cc/metrics/custom_metrics_recorder.h"
  9. namespace ash {
  10. // Records throughput metrics for ash UI. Note this class is not thread-safe.
  11. class ASH_EXPORT UiThroughputRecorder : public cc::CustomMetricRecorder {
  12. public:
  13. UiThroughputRecorder();
  14. ~UiThroughputRecorder() override;
  15. // Invoked on a user login. This is expected to be called after cryptohome
  16. // mount but before user profile loading.
  17. void OnUserLoggedIn();
  18. // Invoked after post-login animation finishes.
  19. void OnPostLoginAnimationFinish();
  20. // cc::CustomMetricRecorder:
  21. void ReportPercentDroppedFramesInOneSecoundWindow(double percentage) override;
  22. private:
  23. // State to split "Ash.Smoothness.PercentDroppedFrames_1sWindow".
  24. enum class State {
  25. kBeforeLogin,
  26. kDuringLogin,
  27. kInSession,
  28. };
  29. State state_ = State::kBeforeLogin;
  30. SEQUENCE_CHECKER(sequence_checker_);
  31. };
  32. } // namespace ash
  33. #endif // ASH_METRICS_UI_THROUGHPUT_RECORDER_H_