ladybird/Userland/Libraries/LibWeb/HTML/Storage.h
Timothy Flynn 2692db8699 LibJS+Everywhere: Allow Cell::initialize overrides to throw OOM errors
Note that as of this commit, there aren't any such throwers, and the
call site in Heap::allocate will drop exceptions on the floor. This
commit only serves to change the declaration of the overrides, make sure
they return an empty value, and to propagate OOM errors frm their base
initialize invocations.
2023-01-29 00:02:45 +00:00

46 lines
1.2 KiB
C++

/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/HashMap.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::HTML {
class Storage : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(Storage, Bindings::PlatformObject);
public:
static JS::NonnullGCPtr<Storage> create(JS::Realm&);
~Storage();
size_t length() const;
DeprecatedString key(size_t index);
DeprecatedString get_item(DeprecatedString const& key) const;
WebIDL::ExceptionOr<void> set_item(DeprecatedString const& key, DeprecatedString const& value);
void remove_item(DeprecatedString const& key);
void clear();
Vector<DeprecatedString> supported_property_names() const;
auto const& map() const { return m_map; }
void dump() const;
private:
explicit Storage(JS::Realm&);
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
void reorder();
void broadcast(DeprecatedString const& key, DeprecatedString const& old_value, DeprecatedString const& new_value);
OrderedHashMap<DeprecatedString, DeprecatedString> m_map;
};
}