2020-09-29 18:19:18 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-09-29 18:19:18 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-11-03 18:21:56 +03:30
|
|
|
#include <AK/StdLibExtras.h>
|
2020-09-29 18:19:18 +02:00
|
|
|
#include <LibCore/ElapsedTimer.h>
|
|
|
|
|
#include <LibWeb/Bindings/Wrappable.h>
|
|
|
|
|
#include <LibWeb/DOM/EventTarget.h>
|
2021-01-18 15:06:13 +01:00
|
|
|
#include <LibWeb/NavigationTiming/PerformanceTiming.h>
|
2020-09-29 18:19:18 +02:00
|
|
|
|
|
|
|
|
namespace Web::HighResolutionTime {
|
|
|
|
|
|
|
|
|
|
class Performance final
|
|
|
|
|
: public DOM::EventTarget
|
|
|
|
|
, public Bindings::Wrappable {
|
|
|
|
|
public:
|
|
|
|
|
using WrapperType = Bindings::PerformanceWrapper;
|
2021-04-10 18:29:06 +04:30
|
|
|
using AllowOwnPtr = TrueType;
|
2020-09-29 18:19:18 +02:00
|
|
|
|
2022-03-07 23:08:26 +01:00
|
|
|
explicit Performance(HTML::Window&);
|
2020-09-29 18:19:18 +02:00
|
|
|
~Performance();
|
|
|
|
|
|
|
|
|
|
double now() const { return m_timer.elapsed(); }
|
2020-09-29 18:31:07 +02:00
|
|
|
double time_origin() const;
|
2020-09-29 18:19:18 +02:00
|
|
|
|
2021-01-18 15:06:13 +01:00
|
|
|
RefPtr<NavigationTiming::PerformanceTiming> timing() { return *m_timing; }
|
|
|
|
|
|
2020-09-29 18:19:18 +02:00
|
|
|
virtual void ref_event_target() override;
|
|
|
|
|
virtual void unref_event_target() override;
|
|
|
|
|
|
2022-08-22 18:31:08 +01:00
|
|
|
virtual JS::Object* create_wrapper(JS::Realm&) override;
|
2020-09-29 18:19:18 +02:00
|
|
|
|
|
|
|
|
private:
|
2022-03-07 23:08:26 +01:00
|
|
|
HTML::Window& m_window;
|
2020-09-29 18:19:18 +02:00
|
|
|
Core::ElapsedTimer m_timer;
|
2021-01-18 15:06:13 +01:00
|
|
|
|
|
|
|
|
OwnPtr<NavigationTiming::PerformanceTiming> m_timing;
|
2020-09-29 18:19:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|