Skip to content

Truly independent web browser

1.7 KB
Raw Blame
/*
 * Copyright (c) 2025, Shannon Booth <[email protected]>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Optional.h>
#include <LibWeb/WebIDL/DOMException.h>

namespace Web::Bindings {

struct QuotaExceededErrorOptions;

}

namespace Web::WebIDL {

using QuotaExceededErrorOptions = Bindings::QuotaExceededErrorOptions;

// https://webidl.spec.whatwg.org/#quotaexceedederror
class WEB_API QuotaExceededError final : public DOMException {
    WEB_WRAPPABLE(QuotaExceededError, DOMException);
    GC_DECLARE_ALLOCATOR(QuotaExceededError);

public:
    static GC::Ref<QuotaExceededError> create(Utf16String const& message);

    static ExceptionOr<GC::Ref<QuotaExceededError>> create(JS::VM&, Utf16String const& message, QuotaExceededErrorOptions const&);

    // A QuotaExceededError with the fields that its deserialization steps read.
    static GC::Ref<QuotaExceededError> create(Utf16FlyString name, Utf16String const& message, Optional<double> quota, Optional<double> requested);

    // https://webidl.spec.whatwg.org/#dom-quotaexceedederror-quota
    Optional<double> const& quota() const { return m_quota; }

    // https://webidl.spec.whatwg.org/#dom-quotaexceedederror-quota
    Optional<double> const& requested() const { return m_requested; }

protected:
    explicit QuotaExceededError(Utf16String const& message);
    QuotaExceededError(Utf16FlyString name, Utf16String const& message, Optional<double> quota, Optional<double> requested);

private:
    // https://webidl.spec.whatwg.org/#quotaexceedederror-quota
    Optional<double> m_quota;

    // https://webidl.spec.whatwg.org/#quotaexceedederror-requested
    Optional<double> m_requested;
};

}