ladybird/Userland/Libraries/LibWeb/FileAPI/File.h
Andreas Kling bfd354492e LibWeb: Put most LibWeb GC objects in type-specific heap blocks
With this change, we now have ~1200 CellAllocators across both LibJS and
LibWeb in a normal WebContent instance.

This gives us a minimum heap size of 4.7 MiB in the scenario where we
only have one cell allocated per type. Of course, in practice there will
be many more of each type, so the effective overhead is quite a bit
smaller than that in practice.

I left a few types unconverted to this mechanism because I got tired of
doing this. :^)
2023-11-19 22:00:48 +01:00

41 lines
1.2 KiB
C++

/*
* Copyright (c) 2022-2023, Kenneth Myhra <kennethmyhra@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/FileAPI/Blob.h>
namespace Web::FileAPI {
struct FilePropertyBag : BlobPropertyBag {
Optional<i64> last_modified;
};
class File : public Blob {
WEB_PLATFORM_OBJECT(File, Blob);
JS_DECLARE_ALLOCATOR(File);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> create(JS::Realm&, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> construct_impl(JS::Realm&, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options = {});
virtual ~File() override;
// https://w3c.github.io/FileAPI/#dfn-name
String const& name() const { return m_name; }
// https://w3c.github.io/FileAPI/#dfn-lastModified
i64 last_modified() const { return m_last_modified; }
private:
File(JS::Realm&, ByteBuffer, String file_name, String type, i64 last_modified);
virtual void initialize(JS::Realm&) override;
String m_name;
i64 m_last_modified { 0 };
};
}