AbstractOperations.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. using AbortAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>>(JS::Value)>;
  18. using CloseAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>>()>;
  19. using WriteAlgorithm = JS::SafeFunction<WebIDL::ExceptionOr<JS::GCPtr<WebIDL::Promise>>(JS::Value)>;
  20. WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStreamDefaultReader>> acquire_readable_stream_default_reader(ReadableStream&);
  21. bool is_readable_stream_locked(ReadableStream const&);
  22. void readable_stream_close(ReadableStream&);
  23. void readable_stream_error(ReadableStream&, JS::Value error);
  24. void readable_stream_add_read_request(ReadableStream&, ReadRequest const&);
  25. WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> readable_stream_cancel(ReadableStream&, JS::Value reason);
  26. void readable_stream_fulfill_read_request(ReadableStream&, JS::Value chunk, bool done);
  27. size_t readable_stream_get_num_read_requests(ReadableStream&);
  28. bool readable_stream_has_default_reader(ReadableStream&);
  29. JS::NonnullGCPtr<WebIDL::Promise> readable_stream_reader_generic_cancel(ReadableStreamGenericReaderMixin&, JS::Value reason);
  30. void readable_stream_reader_generic_initialize(ReadableStreamGenericReaderMixin&, ReadableStream&);
  31. WebIDL::ExceptionOr<void> readable_stream_reader_generic_release(ReadableStreamGenericReaderMixin&);
  32. void readable_stream_default_reader_error_read_requests(ReadableStreamDefaultReader&, JS::Value error);
  33. void readable_stream_default_reader_read(ReadableStreamDefaultReader&, ReadRequest&);
  34. WebIDL::ExceptionOr<void> readable_stream_default_reader_release(ReadableStreamDefaultReader&);
  35. WebIDL::ExceptionOr<void> set_up_readable_stream_default_reader(ReadableStreamDefaultReader&, ReadableStream&);
  36. void readable_stream_default_controller_close(ReadableStreamDefaultController&);
  37. WebIDL::ExceptionOr<void> readable_stream_default_controller_enqueue(ReadableStreamDefaultController&, JS::Value chunk);
  38. WebIDL::ExceptionOr<void> readable_stream_default_controller_can_pull_if_needed(ReadableStreamDefaultController&);
  39. bool readable_stream_default_controller_should_call_pull(ReadableStreamDefaultController&);
  40. void readable_stream_default_controller_clear_algorithms(ReadableStreamDefaultController&);
  41. void readable_stream_default_controller_error(ReadableStreamDefaultController&, JS::Value error);
  42. Optional<float> readable_stream_default_controller_get_desired_size(ReadableStreamDefaultController&);
  43. bool readable_stream_default_controller_can_close_or_enqueue(ReadableStreamDefaultController&);
  44. WebIDL::ExceptionOr<void> set_up_readable_stream_default_controller(ReadableStream&, ReadableStreamDefaultController&, StartAlgorithm&&, PullAlgorithm&&, CancelAlgorithm&&, double high_water_mark, SizeAlgorithm&&);
  45. WebIDL::ExceptionOr<void> set_up_readable_stream_default_controller_from_underlying_source(ReadableStream&, JS::Value underlying_source_value, UnderlyingSource, double high_water_mark, SizeAlgorithm&&);
  46. bool is_writable_stream_locked(WritableStream const&);
  47. WebIDL::ExceptionOr<void> set_up_writable_stream_default_writer(WritableStreamDefaultWriter&, WritableStream&);
  48. bool writable_stream_close_queued_or_in_flight(WritableStream const&);
  49. WebIDL::ExceptionOr<void> writable_stream_finish_erroring(WritableStream&);
  50. bool writable_stream_has_operation_marked_in_flight(WritableStream const&);
  51. void writable_stream_reject_close_and_closed_promise_if_needed(WritableStream&);
  52. WebIDL::ExceptionOr<void> writable_stream_start_erroring(WritableStream&, JS::Value reason);
  53. Optional<double> writable_stream_default_writer_get_desired_size(WritableStreamDefaultWriter const&);
  54. void writable_stream_default_writer_ensure_ready_promise_rejected(WritableStreamDefaultWriter&, JS::Value error);
  55. Optional<double> writable_stream_default_writer_get_desired_size(WritableStreamDefaultWriter const&);
  56. void writable_stream_default_controller_clear_algorithms(WritableStreamDefaultController&);
  57. WebIDL::ExceptionOr<void> writable_stream_default_controller_error(WritableStreamDefaultController&, JS::Value error);
  58. double writable_stream_default_controller_get_desired_size(WritableStreamDefaultController const&);
  59. JS::ThrowCompletionOr<JS::Handle<WebIDL::CallbackType>> property_to_callback(JS::VM& vm, JS::Value value, JS::PropertyKey const& property_key);
  60. }