PerformanceObserverEntryList.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/Bindings/PlatformObject.h>
  8. namespace Web::PerformanceTimeline {
  9. // https://w3c.github.io/performance-timeline/#performanceobserverentrylist-interface
  10. class PerformanceObserverEntryList final : public Bindings::PlatformObject {
  11. WEB_PLATFORM_OBJECT(PerformanceObserverEntryList, Bindings::PlatformObject);
  12. JS_DECLARE_ALLOCATOR(PerformanceObserverEntryList);
  13. public:
  14. virtual ~PerformanceObserverEntryList() override;
  15. WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> get_entries() const;
  16. WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> get_entries_by_type(String const& type) const;
  17. WebIDL::ExceptionOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> get_entries_by_name(String const& name, Optional<String> type) const;
  18. private:
  19. PerformanceObserverEntryList(JS::Realm&, Vector<JS::NonnullGCPtr<PerformanceTimeline::PerformanceEntry>>&&);
  20. virtual void initialize(JS::Realm&) override;
  21. virtual void visit_edges(Cell::Visitor&) override;
  22. // https://w3c.github.io/performance-timeline/#dfn-entry-list
  23. // Returns a PerformanceEntryList object returned by filter buffer by name and type algorithm with this's entry list,
  24. // name and type set to null.
  25. Vector<JS::NonnullGCPtr<PerformanceTimeline::PerformanceEntry>> m_entry_list;
  26. };
  27. ErrorOr<Vector<JS::Handle<PerformanceTimeline::PerformanceEntry>>> filter_buffer_by_name_and_type(Vector<JS::NonnullGCPtr<PerformanceTimeline::PerformanceEntry>> const& buffer, Optional<String> name, Optional<String> type);
  28. }