FetchedDataReceiver.h 987 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/ByteBuffer.h>
  8. #include <LibJS/Heap/Cell.h>
  9. #include <LibJS/Heap/CellAllocator.h>
  10. #include <LibWeb/Forward.h>
  11. namespace Web::Fetch::Fetching {
  12. class FetchedDataReceiver final : public JS::Cell {
  13. JS_CELL(FetchedDataReceiver, JS::Cell);
  14. JS_DECLARE_ALLOCATOR(FetchedDataReceiver);
  15. public:
  16. virtual ~FetchedDataReceiver() override;
  17. void set_pending_promise(JS::NonnullGCPtr<WebIDL::Promise>);
  18. void on_data_received(ReadonlyBytes);
  19. private:
  20. FetchedDataReceiver(JS::NonnullGCPtr<Infrastructure::FetchParams const>, JS::NonnullGCPtr<Streams::ReadableStream>);
  21. virtual void visit_edges(Visitor& visitor) override;
  22. JS::NonnullGCPtr<Infrastructure::FetchParams const> m_fetch_params;
  23. JS::NonnullGCPtr<Streams::ReadableStream> m_stream;
  24. JS::GCPtr<WebIDL::Promise> m_pending_promise;
  25. ByteBuffer m_buffer;
  26. };
  27. }