#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/fetch/body_stream_buffer.h"
#include <memory>
#include "base/auto_reset.h"
#include "base/compiler_specific.h"
#include "base/numerics/safe_conversions.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_throw_dom_exception.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/fetch/body.h"
#include "third_party/blink/renderer/core/fetch/bytes_consumer_tee.h"
#include "third_party/blink/renderer/core/fetch/bytes_uploader.h"
#include "third_party/blink/renderer/core/fetch/readable_stream_bytes_consumer.h"
#include "third_party/blink/renderer/core/streams/readable_byte_stream_controller.h"
#include "third_party/blink/renderer/core/streams/readable_stream.h"
#include "third_party/blink/renderer/core/streams/readable_stream_byob_request.h"
#include "third_party/blink/renderer/core/streams/readable_stream_default_controller_with_script_scope.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_typed_array.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/bindings/v8_throw_exception.h"
#include "third_party/blink/renderer/platform/blob/blob_data.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.h"
#include "third_party/blink/renderer/platform/network/encoded_form_data.h"
#include "third_party/blink/renderer/platform/scheduler/public/frame_or_worker_scheduler.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "v8/include/v8.h"
namespace blink {
class BodyStreamBuffer::LoaderClient final
: public GarbageCollected<LoaderClient>,
public ExecutionContextLifecycleObserver,
public FetchDataLoader::Client { … };
BodyStreamBuffer* BodyStreamBuffer::Create(
ScriptState* script_state,
BytesConsumer* consumer,
AbortSignal* signal,
ScriptCachedMetadataHandler* cached_metadata_handler,
scoped_refptr<BlobDataHandle> side_data_blob) { … }
BodyStreamBuffer::BodyStreamBuffer(
PassKey,
ScriptState* script_state,
BytesConsumer* consumer,
AbortSignal* signal,
ScriptCachedMetadataHandler* cached_metadata_handler,
scoped_refptr<BlobDataHandle> side_data_blob)
: … { … }
void BodyStreamBuffer::Init() { … }
BodyStreamBuffer::BodyStreamBuffer(
ScriptState* script_state,
ReadableStream* stream,
ScriptCachedMetadataHandler* cached_metadata_handler,
scoped_refptr<BlobDataHandle> side_data_blob)
: … { … }
scoped_refptr<BlobDataHandle> BodyStreamBuffer::DrainAsBlobDataHandle(
BytesConsumer::BlobSizePolicy policy,
ExceptionState& exception_state) { … }
scoped_refptr<EncodedFormData> BodyStreamBuffer::DrainAsFormData(
ExceptionState& exception_state) { … }
void BodyStreamBuffer::DrainAsChunkedDataPipeGetter(
ScriptState* script_state,
mojo::PendingReceiver<network::mojom::blink::ChunkedDataPipeGetter>
pending_receiver,
BytesUploader::Client* client) { … }
void BodyStreamBuffer::StartLoading(FetchDataLoader* loader,
FetchDataLoader::Client* client,
ExceptionState& exception_state) { … }
void BodyStreamBuffer::Tee(BodyStreamBuffer** branch1,
BodyStreamBuffer** branch2,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> BodyStreamBuffer::Pull(
ReadableByteStreamController* controller,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> BodyStreamBuffer::Cancel(
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> BodyStreamBuffer::Cancel(
v8::Local<v8::Value> reason,
ExceptionState& exception_state) { … }
ScriptState* BodyStreamBuffer::GetScriptState() { … }
void BodyStreamBuffer::OnStateChange() { … }
void BodyStreamBuffer::ContextDestroyed() { … }
bool BodyStreamBuffer::IsStreamReadable() const { … }
bool BodyStreamBuffer::IsStreamClosed() const { … }
bool BodyStreamBuffer::IsStreamErrored() const { … }
bool BodyStreamBuffer::IsStreamLocked() const { … }
bool BodyStreamBuffer::IsStreamDisturbed() const { … }
void BodyStreamBuffer::CloseAndLockAndDisturb(ExceptionState& exception_state) { … }
bool BodyStreamBuffer::IsAborted() { … }
scoped_refptr<BlobDataHandle> BodyStreamBuffer::TakeSideDataBlob() { … }
void BodyStreamBuffer::Trace(Visitor* visitor) const { … }
void BodyStreamBuffer::Abort() { … }
void BodyStreamBuffer::Close(ExceptionState& exception_state) { … }
void BodyStreamBuffer::GetError() { … }
void BodyStreamBuffer::RaiseOOMError() { … }
void BodyStreamBuffer::CancelConsumer() { … }
void BodyStreamBuffer::ProcessData(ExceptionState& exception_state) { … }
void BodyStreamBuffer::EndLoading() { … }
void BodyStreamBuffer::StopLoading() { … }
BytesConsumer* BodyStreamBuffer::ReleaseHandle(
ExceptionState& exception_state) { … }
}