mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:07:44 +00:00
LibWeb: Introduce Performance Timeline and its Performance functions
This commit is contained in:
parent
4c3f1481ea
commit
31b507afbf
16 changed files with 381 additions and 1 deletions
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/HighResolutionTime/DOMHighResTimeStamp.h>
|
||||
|
||||
namespace Web::PerformanceTimeline {
|
||||
|
||||
enum class AvailableFromTimeline {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
|
||||
enum class ShouldAddEntry {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
|
||||
// https://www.w3.org/TR/performance-timeline/#dom-performanceentry
|
||||
class PerformanceEntry : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(PerformanceEntry, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
virtual ~PerformanceEntry();
|
||||
|
||||
// https://www.w3.org/TR/performance-timeline/#dom-performanceentry-entrytype
|
||||
virtual FlyString const& entry_type() const = 0;
|
||||
|
||||
String const& name() const { return m_name; }
|
||||
HighResolutionTime::DOMHighResTimeStamp start_time() const { return m_start_time; }
|
||||
HighResolutionTime::DOMHighResTimeStamp duration() const { return m_duration; }
|
||||
|
||||
// https://w3c.github.io/timing-entrytypes-registry/#dfn-should-add-entry
|
||||
virtual PerformanceTimeline::ShouldAddEntry should_add_entry() const = 0;
|
||||
|
||||
protected:
|
||||
PerformanceEntry(JS::Realm&, String const& name, HighResolutionTime::DOMHighResTimeStamp start_time, HighResolutionTime::DOMHighResTimeStamp duration);
|
||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||
|
||||
private:
|
||||
// https://www.w3.org/TR/performance-timeline/#dom-performanceentry-name
|
||||
String m_name;
|
||||
|
||||
// https://www.w3.org/TR/performance-timeline/#dom-performanceentry-starttime
|
||||
HighResolutionTime::DOMHighResTimeStamp m_start_time { 0.0 };
|
||||
|
||||
// https://www.w3.org/TR/performance-timeline/#dom-performanceentry-duration
|
||||
HighResolutionTime::DOMHighResTimeStamp m_duration { 0.0 };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue