IdleDeadline.h 810 B

1234567891011121314151617181920212223242526272829303132
  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 <LibWeb/Bindings/PlatformObject.h>
  9. namespace Web::RequestIdleCallback {
  10. class IdleDeadline final : public Bindings::PlatformObject {
  11. WEB_PLATFORM_OBJECT(IdleDeadline, Bindings::PlatformObject);
  12. public:
  13. static WebIDL::ExceptionOr<JS::NonnullGCPtr<IdleDeadline>> create(JS::Realm&, bool did_timeout = false);
  14. virtual ~IdleDeadline() override;
  15. double time_remaining() const;
  16. bool did_timeout() const { return m_did_timeout; }
  17. private:
  18. IdleDeadline(JS::Realm&, bool did_timeout);
  19. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  20. bool m_did_timeout { false };
  21. };
  22. }