mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-26 04:07:51 +00:00
LibWeb: Implement ReadableStreamPipeTo according to spec
Our existing implementation of stream piping was extremely ad-hoc. It did nothing to handle closed/errored streams, and did not read from or write to streams in a way required by the spec. This new implementation uses a custom JS::Cell to drive the read/write loop.
This commit is contained in:
parent
4010c4643a
commit
eb0a51faf0
Notes:
github-actions[bot]
2025-04-11 16:11:49 +00:00
Author: https://github.com/trflynn89
Commit: eb0a51faf0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4311
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/shannonbooth ✅
33 changed files with 3926 additions and 85 deletions
|
@ -20,6 +20,8 @@ struct ReadableStreamReadResult {
|
|||
bool done;
|
||||
};
|
||||
|
||||
class ReadableStreamPipeTo;
|
||||
|
||||
class ReadRequest : public JS::Cell {
|
||||
GC_CELL(ReadRequest, JS::Cell);
|
||||
|
||||
|
@ -91,13 +93,14 @@ public:
|
|||
|
||||
void read_a_chunk(Fetch::Infrastructure::IncrementalReadLoopReadRequest& read_request);
|
||||
void read_all_bytes(GC::Ref<ReadLoopReadRequest::SuccessSteps>, GC::Ref<ReadLoopReadRequest::FailureSteps>);
|
||||
void read_all_chunks(GC::Ref<ReadAllOnChunkSteps>, GC::Ref<ReadAllOnSuccessSteps>, GC::Ref<ReadAllOnFailureSteps>);
|
||||
GC::Ref<WebIDL::Promise> read_all_bytes_deprecated();
|
||||
|
||||
void release_lock();
|
||||
|
||||
SinglyLinkedList<GC::Ref<ReadRequest>>& read_requests() { return m_read_requests; }
|
||||
|
||||
void set_readable_stream_pipe_to_operation(Badge<ReadableStreamPipeTo>, GC::Ptr<JS::Cell> readable_stream_pipe_to_operation) { m_readable_stream_pipe_to_operation = readable_stream_pipe_to_operation; }
|
||||
|
||||
private:
|
||||
explicit ReadableStreamDefaultReader(JS::Realm&);
|
||||
|
||||
|
@ -106,6 +109,8 @@ private:
|
|||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
SinglyLinkedList<GC::Ref<ReadRequest>> m_read_requests;
|
||||
|
||||
GC::Ptr<JS::Cell> m_readable_stream_pipe_to_operation;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue