#include "third_party/blink/renderer/modules/file_system_access/file_system_underlying_sink.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/system/string_data_source.h"
#include "net/base/net_errors.h"
#include "third_party/blink/public/common/blob/blob_utils.h"
#include "third_party/blink/public/mojom/blob/blob.mojom-blink.h"
#include "third_party/blink/public/mojom/file_system_access/file_system_access_error.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_arraybuffer_arraybufferview_blob_usvstring.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_arraybuffer_arraybufferview_blob_usvstring_writeparams.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_write_command_type.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_write_params.h"
#include "third_party/blink/renderer/core/fileapi/blob.h"
#include "third_party/blink/renderer/modules/file_system_access/file_system_access_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/blob/blob_data.h"
#include "third_party/blink/renderer/platform/wtf/text/string_utf8_adaptor.h"
namespace blink {
FileSystemUnderlyingSink::FileSystemUnderlyingSink(
ExecutionContext* context,
mojo::PendingRemote<mojom::blink::FileSystemAccessFileWriter> writer_remote)
: … { … }
ScriptPromise<IDLUndefined> FileSystemUnderlyingSink::start(
ScriptState* script_state,
WritableStreamDefaultController* controller,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> FileSystemUnderlyingSink::write(
ScriptState* script_state,
ScriptValue chunk,
WritableStreamDefaultController* controller,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> FileSystemUnderlyingSink::close(
ScriptState* script_state,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> FileSystemUnderlyingSink::abort(
ScriptState* script_state,
ScriptValue reason,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> FileSystemUnderlyingSink::HandleParams(
ScriptState* script_state,
const WriteParams& params,
ExceptionState& exception_state) { … }
namespace {
class WriterHelper { … };
class StreamWriterHelper final : public WriterHelper { … };
class BlobWriterHelper final : public mojom::blink::BlobReaderClient,
public WriterHelper { … };
bool CreateDataPipe(uint64_t data_size,
ExceptionState& exception_state,
mojo::ScopedDataPipeProducerHandle& producer,
mojo::ScopedDataPipeConsumerHandle& consumer) { … }
}
void FileSystemUnderlyingSink::ThrowDOMExceptionAndInvalidateSink(
ExceptionState& exception_state,
DOMExceptionCode error,
const char* message) { … }
void FileSystemUnderlyingSink::ThrowTypeErrorAndInvalidateSink(
ExceptionState& exception_state,
const char* message) { … }
ScriptPromise<IDLUndefined> FileSystemUnderlyingSink::WriteData(
ScriptState* script_state,
uint64_t position,
const V8UnionArrayBufferOrArrayBufferViewOrBlobOrUSVString* data,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> FileSystemUnderlyingSink::Truncate(
ScriptState* script_state,
uint64_t size,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> FileSystemUnderlyingSink::Seek(
ScriptState* script_state,
uint64_t offset,
ExceptionState& exception_state) { … }
void FileSystemUnderlyingSink::WriteComplete(
mojom::blink::FileSystemAccessErrorPtr result,
uint64_t bytes_written) { … }
void FileSystemUnderlyingSink::TruncateComplete(
uint64_t to_size,
mojom::blink::FileSystemAccessErrorPtr result) { … }
void FileSystemUnderlyingSink::CloseComplete(
mojom::blink::FileSystemAccessErrorPtr result) { … }
void FileSystemUnderlyingSink::Trace(Visitor* visitor) const { … }
}