#include "third_party/blink/renderer/core/fetch/body.h"
#include <memory>
#include <utility>
#include "base/memory/scoped_refptr.h"
#include "base/task/single_thread_task_runner.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/fetch/body_stream_buffer.h"
#include "third_party/blink/renderer/core/fetch/fetch_data_loader.h"
#include "third_party/blink/renderer/core/fileapi/blob.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/html/forms/form_data.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
#include "third_party/blink/renderer/core/url/url_search_params.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/heap/disallow_new_wrapper.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/loader/fetch/text_resource_decoder_options.h"
#include "third_party/blink/renderer/platform/network/parsed_content_type.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
namespace blink {
namespace {
class BodyConsumerBase : public GarbageCollected<BodyConsumerBase>,
public FetchDataLoader::Client { … };
class BodyBlobConsumer final : public BodyConsumerBase { … };
class BodyArrayBufferConsumer final : public BodyConsumerBase { … };
class BodyFormDataConsumer final : public BodyConsumerBase { … };
class BodyTextConsumer final : public BodyConsumerBase { … };
class BodyJsonConsumer final : public BodyConsumerBase { … };
FetchDataLoader* CreateLoaderAsStringWithUTF8Decode() { … }
}
bool Body::ShouldLoadBody(ScriptState* script_state,
ExceptionState& exception_state) { … }
template <class Consumer,
typename CreateLoaderFunction,
typename OnNoBodyFunction>
ScriptPromise<typename Consumer::ResolveType> Body::LoadAndConvertBody(
ScriptState* script_state,
CreateLoaderFunction create_loader,
OnNoBodyFunction on_no_body,
ExceptionState& exception_state) { … }
ScriptPromise<DOMArrayBuffer> Body::arrayBuffer(
ScriptState* script_state,
ExceptionState& exception_state) { … }
ScriptPromise<Blob> Body::blob(ScriptState* script_state,
ExceptionState& exception_state) { … }
ScriptPromise<FormData> Body::formData(ScriptState* script_state,
ExceptionState& exception_state) { … }
ScriptPromise<IDLAny> Body::json(ScriptState* script_state,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUSVString> Body::text(ScriptState* script_state,
ExceptionState& exception_state) { … }
ReadableStream* Body::body() { … }
bool Body::IsBodyUsed() const { … }
bool Body::IsBodyLocked() const { … }
Body::Body(ExecutionContext* context) : … { … }
void Body::RejectInvalidConsumption(ExceptionState& exception_state) const { … }
}