#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/modules/webtransport/outgoing_stream.h"
#include <cstring>
#include <utility>
#include "base/numerics/safe_conversions.h"
#include "mojo/public/cpp/system/simple_watcher.h"
#include "partition_alloc/partition_alloc.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_throw_dom_exception.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_typedefs.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_arraybuffer_arraybufferview.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_web_transport_error.h"
#include "third_party/blink/renderer/core/dom/abort_signal.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/streams/promise_handler.h"
#include "third_party/blink/renderer/core/streams/underlying_sink_base.h"
#include "third_party/blink/renderer/core/streams/writable_stream.h"
#include "third_party/blink/renderer/core/streams/writable_stream_default_controller.h"
#include "third_party/blink/renderer/core/streams/writable_stream_transferring_optimizer.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_piece.h"
#include "third_party/blink/renderer/modules/webtransport/web_transport_error.h"
#include "third_party/blink/renderer/platform/bindings/exception_code.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/heap/visitor.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
namespace blink {
namespace {
class SendStreamAbortAlgorithm final : public AbortSignal::Algorithm { … };
}
class OutgoingStream::UnderlyingSink final : public UnderlyingSinkBase { … };
OutgoingStream::CachedDataBuffer::CachedDataBuffer(v8::Isolate* isolate,
const uint8_t* data,
size_t length)
: … { … }
OutgoingStream::CachedDataBuffer::~CachedDataBuffer() { … }
OutgoingStream::OutgoingStream(ScriptState* script_state,
Client* client,
mojo::ScopedDataPipeProducerHandle handle)
: … { … }
OutgoingStream::~OutgoingStream() = default;
void OutgoingStream::Init(ExceptionState& exception_state) { … }
void OutgoingStream::InitWithExistingWritableStream(
WritableStream* stream,
ExceptionState& exception_state) { … }
void OutgoingStream::AbortAlgorithm(OutgoingStream* stream) { … }
void OutgoingStream::OnOutgoingStreamClosed() { … }
void OutgoingStream::Error(ScriptValue reason) { … }
void OutgoingStream::ContextDestroyed() { … }
void OutgoingStream::Trace(Visitor* visitor) const { … }
void OutgoingStream::OnHandleReady(MojoResult result,
const mojo::HandleSignalsState&) { … }
void OutgoingStream::OnPeerClosed(MojoResult result,
const mojo::HandleSignalsState&) { … }
void OutgoingStream::HandlePipeClosed() { … }
ScriptPromise<IDLUndefined> OutgoingStream::SinkWrite(
ScriptState* script_state,
ScriptValue chunk,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> OutgoingStream::WriteOrCacheData(
ScriptState* script_state,
base::span<const uint8_t> data) { … }
void OutgoingStream::WriteCachedData() { … }
size_t OutgoingStream::WriteDataSynchronously(base::span<const uint8_t> data) { … }
ScriptValue OutgoingStream::CreateAbortException(IsLocalAbort is_local_abort) { … }
void OutgoingStream::ErrorStreamAbortAndReset(ScriptValue reason) { … }
void OutgoingStream::AbortAndReset() { … }
void OutgoingStream::ResetPipe() { … }
void OutgoingStream::Dispose() { … }
}