2023-04-08 12:01:49 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
|
2023-08-27 12:55:25 +12:00
|
|
|
* Copyright (c) 2023, Shannon Booth <shannon@serenityos.org>
|
2023-04-08 12:01:49 -07:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibJS/Runtime/PromiseCapability.h>
|
2023-08-27 12:55:25 +12:00
|
|
|
#include <LibWeb/Streams/AbstractOperations.h>
|
2023-04-08 12:01:49 -07:00
|
|
|
#include <LibWeb/Streams/ReadableStream.h>
|
|
|
|
|
#include <LibWeb/Streams/ReadableStreamBYOBReader.h>
|
2023-08-27 12:55:25 +12:00
|
|
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
2023-04-08 12:01:49 -07:00
|
|
|
|
|
|
|
|
namespace Web::Streams {
|
|
|
|
|
|
|
|
|
|
ReadableStreamBYOBReader::ReadableStreamBYOBReader(JS::Realm& realm)
|
|
|
|
|
: Bindings::PlatformObject(realm)
|
|
|
|
|
, ReadableStreamGenericReaderMixin(realm)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-27 12:55:25 +12:00
|
|
|
// https://streams.spec.whatwg.org/#byob-reader-constructor
|
|
|
|
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStreamBYOBReader>> ReadableStreamBYOBReader::construct_impl(JS::Realm& realm, JS::NonnullGCPtr<ReadableStream> stream)
|
|
|
|
|
{
|
|
|
|
|
auto reader = realm.heap().allocate<ReadableStreamBYOBReader>(realm, realm);
|
|
|
|
|
|
|
|
|
|
// 1. Perform ? SetUpReadableStreamBYOBReader(this, stream).
|
|
|
|
|
TRY(set_up_readable_stream_byob_reader(reader, *stream));
|
|
|
|
|
|
|
|
|
|
return reader;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-08 12:01:49 -07:00
|
|
|
void ReadableStreamBYOBReader::visit_edges(Cell::Visitor& visitor)
|
|
|
|
|
{
|
|
|
|
|
Base::visit_edges(visitor);
|
|
|
|
|
ReadableStreamGenericReaderMixin::visit_edges(visitor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|