ladybird/Userland/Libraries/LibWeb/UserTiming/PerformanceMeasure.cpp
Andreas Kling 72c9f56c66 LibJS: Make Heap::allocate<T>() infallible
Stop worrying about tiny OOMs. Work towards #20449.

While going through these, I also changed the function signature in many
places where returning ThrowCompletionOr<T> is no longer necessary.
2023-08-13 15:38:42 +02:00

49 lines
1.7 KiB
C++

/*
* Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/PerformanceMeasurePrototype.h>
#include <LibWeb/HTML/StructuredSerialize.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
#include <LibWeb/NavigationTiming/EntryNames.h>
#include <LibWeb/PerformanceTimeline/EntryTypes.h>
#include <LibWeb/UserTiming/PerformanceMeasure.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::UserTiming {
PerformanceMeasure::PerformanceMeasure(JS::Realm& realm, String const& name, HighResolutionTime::DOMHighResTimeStamp start_time, HighResolutionTime::DOMHighResTimeStamp duration, JS::Value detail)
: PerformanceTimeline::PerformanceEntry(realm, name, start_time, duration)
, m_detail(detail)
{
}
PerformanceMeasure::~PerformanceMeasure() = default;
JS::NonnullGCPtr<PerformanceMeasure> PerformanceMeasure::create(JS::Realm& realm, String const& measure_name, HighResolutionTime::DOMHighResTimeStamp start_time, HighResolutionTime::DOMHighResTimeStamp duration, JS::Value detail)
{
return realm.heap().allocate<PerformanceMeasure>(realm, realm, measure_name, start_time, duration, detail);
}
FlyString const& PerformanceMeasure::entry_type() const
{
return PerformanceTimeline::EntryTypes::measure;
}
void PerformanceMeasure::initialize(JS::Realm& realm)
{
Base::initialize(realm);
set_prototype(&Bindings::ensure_web_prototype<Bindings::PerformanceMeasurePrototype>(realm, "PerformanceMeasure"));
}
void PerformanceMeasure::visit_edges(JS::Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_detail);
}
}