AbstractOperations.h 6.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> writable_stream_close(WritableStream&);
  49. bool writable_stream_close_queued_or_in_flight(WritableStream const&);
  50. WebIDL::ExceptionOr<void> writable_stream_deal_with_rejection(WritableStream&, JS::Value error);
  51. WebIDL::ExceptionOr<void> writable_stream_finish_erroring(WritableStream&);
  52. void writable_stream_finish_in_flight_close(WritableStream&);
  53. WebIDL::ExceptionOr<void> writable_stream_finish_in_flight_close_with_error(WritableStream&, JS::Value error);
  54. void writable_stream_finish_in_flight_write(WritableStream&);
  55. WebIDL::ExceptionOr<void> writable_stream_finish_in_flight_write_with_error(WritableStream&, JS::Value error);
  56. bool writable_stream_has_operation_marked_in_flight(WritableStream const&);
  57. void writable_stream_mark_close_request_in_flight(WritableStream&);
  58. void writable_stream_mark_first_write_request_in_flight(WritableStream&);
  59. void writable_stream_reject_close_and_closed_promise_if_needed(WritableStream&);
  60. WebIDL::ExceptionOr<void> writable_stream_start_erroring(WritableStream&, JS::Value reason);
  61. void writable_stream_update_backpressure(WritableStream&, bool backpressure);
  62. Optional<double> writable_stream_default_writer_get_desired_size(WritableStreamDefaultWriter const&);
  63. void writable_stream_default_writer_ensure_ready_promise_rejected(WritableStreamDefaultWriter&, JS::Value error);
  64. Optional<double> writable_stream_default_writer_get_desired_size(WritableStreamDefaultWriter const&);
  65. WebIDL::ExceptionOr<void> writable_stream_default_controller_advance_queue_if_needed(WritableStreamDefaultController&);
  66. void writable_stream_default_controller_clear_algorithms(WritableStreamDefaultController&);
  67. WebIDL::ExceptionOr<void> writable_stream_default_controller_close(WritableStreamDefaultController&);
  68. WebIDL::ExceptionOr<void> writable_stream_default_controller_error(WritableStreamDefaultController&, JS::Value error);
  69. bool writable_stream_default_controller_get_backpressure(WritableStreamDefaultController const&);
  70. double writable_stream_default_controller_get_desired_size(WritableStreamDefaultController const&);
  71. WebIDL::ExceptionOr<void> writable_stream_default_controller_process_close(WritableStreamDefaultController&);
  72. WebIDL::ExceptionOr<void> writable_stream_default_controller_process_write(WritableStreamDefaultController&, JS::Value chunk);
  73. JS::Value create_close_sentinel();
  74. bool is_close_sentinel(JS::Value);
  75. JS::ThrowCompletionOr<JS::Handle<WebIDL::CallbackType>> property_to_callback(JS::VM& vm, JS::Value value, JS::PropertyKey const& property_key);
  76. }