2024-05-26 08:03:29 -04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/ByteBuffer.h>
|
2024-11-15 04:01:23 +13:00
|
|
|
#include <LibGC/CellAllocator.h>
|
2024-05-26 08:03:29 -04:00
|
|
|
#include <LibJS/Heap/Cell.h>
|
|
|
|
#include <LibWeb/Forward.h>
|
|
|
|
|
|
|
|
namespace Web::Fetch::Fetching {
|
|
|
|
|
|
|
|
class FetchedDataReceiver final : public JS::Cell {
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_CELL(FetchedDataReceiver, JS::Cell);
|
|
|
|
GC_DECLARE_ALLOCATOR(FetchedDataReceiver);
|
2024-05-26 08:03:29 -04:00
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~FetchedDataReceiver() override;
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
void set_pending_promise(GC::Ref<WebIDL::Promise>);
|
2024-05-26 08:03:29 -04:00
|
|
|
void on_data_received(ReadonlyBytes);
|
|
|
|
|
|
|
|
private:
|
2024-11-15 04:01:23 +13:00
|
|
|
FetchedDataReceiver(GC::Ref<Infrastructure::FetchParams const>, GC::Ref<Streams::ReadableStream>);
|
2024-05-26 08:03:29 -04:00
|
|
|
|
|
|
|
virtual void visit_edges(Visitor& visitor) override;
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ref<Infrastructure::FetchParams const> m_fetch_params;
|
|
|
|
GC::Ref<Streams::ReadableStream> m_stream;
|
|
|
|
GC::Ptr<WebIDL::Promise> m_pending_promise;
|
2024-05-26 08:03:29 -04:00
|
|
|
ByteBuffer m_buffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|