2021-01-18 15:06:13 +01:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2021, Andreas Kling <andreas@ladybird.org>
|
2025-01-06 10:26:55 +00:00
|
|
|
* Copyright (c) 2025, Tim Ledbetter <tim.ledbetter@ladybird.org>
|
2021-01-18 15:06:13 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-01-18 15:06:13 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-03-07 23:08:26 +01:00
|
|
|
#include <LibWeb/HTML/Window.h>
|
2021-01-18 15:06:13 +01:00
|
|
|
|
|
|
|
namespace Web::NavigationTiming {
|
|
|
|
|
2022-08-31 19:12:11 +02:00
|
|
|
class PerformanceTiming final : public Bindings::PlatformObject {
|
|
|
|
WEB_PLATFORM_OBJECT(PerformanceTiming, Bindings::PlatformObject);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(PerformanceTiming);
|
2022-08-31 19:12:11 +02:00
|
|
|
|
2021-01-18 15:06:13 +01:00
|
|
|
public:
|
2021-04-10 18:29:06 +04:30
|
|
|
using AllowOwnPtr = TrueType;
|
2021-01-18 15:06:13 +01:00
|
|
|
|
|
|
|
~PerformanceTiming();
|
|
|
|
|
2025-01-27 09:00:02 +00:00
|
|
|
u64 navigation_start()
|
|
|
|
{
|
|
|
|
return monotonic_timestamp_to_wall_time_milliseconds([](auto& load_info) { return load_info.navigation_start_time; });
|
|
|
|
}
|
2022-05-10 11:08:02 +02:00
|
|
|
u64 unload_event_start() { return 0; }
|
|
|
|
u64 unload_event_end() { return 0; }
|
|
|
|
u64 redirect_start() { return 0; }
|
|
|
|
u64 redirect_end() { return 0; }
|
|
|
|
u64 fetch_start() { return 0; }
|
|
|
|
u64 domain_lookup_start() { return 0; }
|
|
|
|
u64 domain_lookup_end() { return 0; }
|
|
|
|
u64 connect_start() { return 0; }
|
|
|
|
u64 connect_end() { return 0; }
|
|
|
|
u64 secure_connection_start() { return 0; }
|
|
|
|
u64 request_start() { return 0; }
|
|
|
|
u64 response_start() { return 0; }
|
|
|
|
u64 response_end() { return 0; }
|
|
|
|
u64 dom_loading() { return 0; }
|
2025-01-27 09:00:02 +00:00
|
|
|
u64 dom_interactive()
|
|
|
|
{
|
|
|
|
return monotonic_timestamp_to_wall_time_milliseconds([](auto& load_info) { return load_info.dom_interactive_time; });
|
|
|
|
}
|
|
|
|
u64 dom_content_loaded_event_start()
|
|
|
|
{
|
|
|
|
return monotonic_timestamp_to_wall_time_milliseconds([](auto& load_info) { return load_info.dom_content_loaded_event_start_time; });
|
|
|
|
}
|
|
|
|
u64 dom_content_loaded_event_end()
|
|
|
|
{
|
|
|
|
return monotonic_timestamp_to_wall_time_milliseconds([](auto& load_info) { return load_info.dom_content_loaded_event_end_time; });
|
|
|
|
}
|
|
|
|
u64 dom_complete()
|
|
|
|
{
|
|
|
|
return monotonic_timestamp_to_wall_time_milliseconds([](auto& load_info) { return load_info.dom_complete_time; });
|
|
|
|
}
|
|
|
|
u64 load_event_start()
|
|
|
|
{
|
|
|
|
return monotonic_timestamp_to_wall_time_milliseconds([](auto& load_info) { return load_info.load_event_start_time; });
|
|
|
|
}
|
|
|
|
u64 load_event_end()
|
|
|
|
{
|
|
|
|
return monotonic_timestamp_to_wall_time_milliseconds([](auto& load_info) { return load_info.load_event_end_time; });
|
|
|
|
}
|
2022-08-28 13:42:07 +02:00
|
|
|
|
|
|
|
private:
|
2024-04-05 18:04:01 -07:00
|
|
|
explicit PerformanceTiming(JS::Realm&);
|
2022-08-31 19:12:11 +02:00
|
|
|
|
2025-01-27 09:00:02 +00:00
|
|
|
DOM::DocumentLoadTimingInfo const& document_load_timing_info(JS::Object const& global_object) const;
|
|
|
|
u64 monotonic_timestamp_to_wall_time_milliseconds(Function<HighResolutionTime::DOMHighResTimeStamp(DOM::DocumentLoadTimingInfo const&)> selector) const;
|
2025-01-06 10:26:55 +00:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2021-01-18 15:06:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|