IdleDeadline.h 744 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (c) 2021-2022, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, the SerenityOS developers.
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <AK/StdLibExtras.h>
  9. #include <LibWeb/Bindings/PlatformObject.h>
  10. namespace Web::RequestIdleCallback {
  11. class IdleDeadline final : public Bindings::PlatformObject {
  12. WEB_PLATFORM_OBJECT(IdleDeadline, Bindings::PlatformObject);
  13. public:
  14. static JS::NonnullGCPtr<IdleDeadline> create(JS::Realm&, bool did_timeout = false);
  15. virtual ~IdleDeadline() override;
  16. double time_remaining() const;
  17. bool did_timeout() const { return m_did_timeout; }
  18. private:
  19. IdleDeadline(JS::Realm&, bool did_timeout);
  20. bool m_did_timeout { false };
  21. };
  22. }