2023-03-28 17:43:34 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/Forward.h>
|
|
|
|
|
#include <LibJS/Forward.h>
|
|
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
|
|
|
#include <LibWeb/Forward.h>
|
|
|
|
|
#include <LibWeb/WebIDL/Promise.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::Streams {
|
|
|
|
|
|
|
|
|
|
// https://streams.spec.whatwg.org/#readablestreamgenericreader
|
|
|
|
|
class ReadableStreamGenericReaderMixin {
|
|
|
|
|
public:
|
2023-03-28 18:30:22 -07:00
|
|
|
virtual ~ReadableStreamGenericReaderMixin() = default;
|
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<WebIDL::Promise> closed();
|
2023-03-28 17:43:34 -07:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ref<WebIDL::Promise> cancel(JS::Value reason);
|
2023-03-28 17:43:34 -07:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<ReadableStream> stream() const { return m_stream; }
|
|
|
|
|
void set_stream(GC::Ptr<ReadableStream> stream) { m_stream = stream; }
|
2023-03-28 17:43:34 -07:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<WebIDL::Promise> closed_promise_capability() { return m_closed_promise; }
|
|
|
|
|
void set_closed_promise_capability(GC::Ptr<WebIDL::Promise> promise) { m_closed_promise = promise; }
|
2023-03-28 17:43:34 -07:00
|
|
|
|
|
|
|
|
protected:
|
2023-04-25 18:29:13 -07:00
|
|
|
explicit ReadableStreamGenericReaderMixin(JS::Realm&);
|
|
|
|
|
|
2023-03-28 17:43:34 -07:00
|
|
|
void visit_edges(JS::Cell::Visitor&);
|
|
|
|
|
|
|
|
|
|
// https://streams.spec.whatwg.org/#readablestreamgenericreader-closedpromise
|
|
|
|
|
// A promise returned by the reader's closed getter
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<WebIDL::Promise> m_closed_promise;
|
2023-03-28 17:43:34 -07:00
|
|
|
|
|
|
|
|
// https://streams.spec.whatwg.org/#readablestreamgenericreader-stream
|
|
|
|
|
// A ReadableStream instance that owns this reader
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<ReadableStream> m_stream;
|
2023-04-25 18:29:13 -07:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ref<JS::Realm> m_realm;
|
2023-03-28 17:43:34 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|