AbstractOperations.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
  3. * Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <LibJS/Heap/GCPtr.h>
  9. #include <LibWeb/Forward.h>
  10. #include <LibWeb/Streams/QueueOperations.h>
  11. #include <LibWeb/WebIDL/Promise.h>
  12. namespace Web::Streams {
  13. using SizeAlgorithm = JS::SafeFunction<JS::Completion(JS::Value)>;
  14. using PullAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>>()>;
  15. using CancelAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>>(JS::Value)>;
  16. using StartAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>>()>;
  17. WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStreamDefaultReader>> acquire_readable_stream_default_reader(ReadableStream&);
  18. bool is_readable_stream_locked(ReadableStream const&);
  19. void readable_stream_close(ReadableStream&);
  20. void readable_stream_error(ReadableStream&, JS::Value error);
  21. void readable_stream_add_read_request(ReadableStream&, ReadRequest const&);
  22. WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> readable_stream_cancel(ReadableStream&, JS::Value reason);
  23. void readable_stream_fulfill_read_request(ReadableStream&, JS::Value chunk, bool done);
  24. size_t readable_stream_get_num_read_requests(ReadableStream&);
  25. bool readable_stream_has_default_reader(ReadableStream&);
  26. JS::NonnullGCPtr<WebIDL::Promise> readable_stream_reader_generic_cancel(ReadableStreamGenericReaderMixin&, JS::Value reason);
  27. void readable_stream_reader_generic_initialize(ReadableStreamGenericReaderMixin&, ReadableStream&);
  28. WebIDL::ExceptionOr<void> readable_stream_reader_generic_release(ReadableStreamGenericReaderMixin&);
  29. void readable_stream_default_reader_error_read_requests(ReadableStreamDefaultReader&, JS::Value error);
  30. void readable_stream_default_reader_read(ReadableStreamDefaultReader&, ReadRequest&);
  31. WebIDL::ExceptionOr<void> readable_stream_default_reader_release(ReadableStreamDefaultReader&);
  32. WebIDL::ExceptionOr<void> set_up_readable_stream_default_reader(ReadableStreamDefaultReader&, ReadableStream&);
  33. void readable_stream_default_controller_close(ReadableStreamDefaultController&);
  34. WebIDL::ExceptionOr<void> readable_stream_default_controller_enqueue(ReadableStreamDefaultController&, JS::Value chunk);
  35. WebIDL::ExceptionOr<void> readable_stream_default_controller_can_pull_if_needed(ReadableStreamDefaultController&);
  36. bool readable_stream_default_controller_should_call_pull(ReadableStreamDefaultController&);
  37. void readable_stream_default_controller_clear_algorithms(ReadableStreamDefaultController&);
  38. void readable_stream_default_controller_error(ReadableStreamDefaultController&, JS::Value error);
  39. Optional<float> readable_stream_default_controller_get_desired_size(ReadableStreamDefaultController&);
  40. bool readable_stream_default_controller_can_close_or_enqueue(ReadableStreamDefaultController&);
  41. WebIDL::ExceptionOr<void> set_up_readable_stream_default_controller(ReadableStream&, ReadableStreamDefaultController&, StartAlgorithm&&, PullAlgorithm&&, CancelAlgorithm&&, double high_water_mark, SizeAlgorithm&&);
  42. WebIDL::ExceptionOr<void> set_up_readable_stream_default_controller_from_underlying_source(ReadableStream&, JS::Value underlying_source_value, UnderlyingSource, double high_water_mark, SizeAlgorithm&&);
  43. }