presentation_time_recorder.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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_PUBLIC_CPP_PRESENTATION_TIME_RECORDER_H_
  5. #define ASH_PUBLIC_CPP_PRESENTATION_TIME_RECORDER_H_
  6. #include <memory>
  7. #include "ash/public/cpp/ash_public_export.h"
  8. #include "third_party/abseil-cpp/absl/types/optional.h"
  9. namespace aura {
  10. class Window;
  11. }
  12. namespace ash {
  13. // A general interface for presentation time recording.
  14. class ASH_PUBLIC_EXPORT PresentationTimeRecorder {
  15. public:
  16. // Creates a recorder tracking ui::Compositor.
  17. static std::unique_ptr<PresentationTimeRecorder> CreateCompositorRecorder(
  18. aura::Window* window,
  19. const char* latency_histogram_name,
  20. absl::optional<const char*> max_latency_histogram_name = absl::nullopt);
  21. virtual ~PresentationTimeRecorder() = default;
  22. // Prepare to record timin for UI changes. Invoked before making UI changes
  23. // so that the recorder could start to watch for UI changes if needed.
  24. virtual void PrepareToRecord() {}
  25. // Request to record timing for the next frame. Returns true if the request
  26. // is accepted. Otherwise, returns false.
  27. virtual bool RequestNext() = 0;
  28. };
  29. } // namespace ash
  30. #endif // ASH_PUBLIC_CPP_PRESENTATION_TIME_RECORDER_H_