chromium/third_party/blink/renderer/core/fileapi/blob.cc

/*
 * Copyright (C) 2010 Google Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following disclaimer
 * in the documentation and/or other materials provided with the
 * distribution.
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "third_party/blink/renderer/core/fileapi/blob.h"

#include <memory>
#include <utility>

#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/bindings/core/v8/v8_blob_property_bag.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_arraybuffer_arraybufferview_blob_usvstring.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/fetch/blob_bytes_consumer.h"
#include "third_party/blink/renderer/core/fetch/body_stream_buffer.h"
#include "third_party/blink/renderer/core/fileapi/file_read_type.h"
#include "third_party/blink/renderer/core/fileapi/file_reader_client.h"
#include "third_party/blink/renderer/core/fileapi/file_reader_loader.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/url/dom_url.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/blob/blob_url.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/self_keep_alive.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"

namespace blink {

namespace {

// http://dev.w3.org/2006/webapi/FileAPI/#constructorBlob
bool IsValidBlobType(const String& type) {}

}  // namespace

// TODO(https://crbug.com/989876): This is not used any more, refactor
// PublicURLManager to deprecate this.
class NullURLRegistry final : public URLRegistry {};

// Helper class to asynchronously read from a Blob using a FileReaderLoader.
// Each client is only good for one Blob read operation.
// This class is not thread-safe.
class BlobFileReaderClient : public GarbageCollected<BlobFileReaderClient>,
                             public FileReaderAccumulator {};

Blob::Blob(scoped_refptr<BlobDataHandle> data_handle)
    :{}

Blob::~Blob() = default;

// static
Blob* Blob::Create(ExecutionContext* context,
                   const HeapVector<Member<V8BlobPart>>& blob_parts,
                   const BlobPropertyBag* options) {}

Blob* Blob::Create(base::span<const uint8_t> data, const String& content_type) {}

// static
void Blob::PopulateBlobData(BlobData* blob_data,
                            const HeapVector<Member<V8BlobPart>>& parts,
                            bool normalize_line_endings_to_native) {}

// static
void Blob::ClampSliceOffsets(uint64_t size, int64_t& start, int64_t& end) {}

Blob* Blob::slice(int64_t start,
                  int64_t end,
                  const String& content_type,
                  ExceptionState& exception_state) const {}

ReadableStream* Blob::stream(ScriptState* script_state) const {}

ScriptPromise<IDLUSVString> Blob::text(ScriptState* script_state) {}

ScriptPromise<DOMArrayBuffer> Blob::arrayBuffer(ScriptState* script_state) {}

scoped_refptr<BlobDataHandle> Blob::GetBlobDataHandleWithKnownSize() const {}

void Blob::AppendTo(BlobData& blob_data) const {}

URLRegistry& Blob::Registry() const {}

bool Blob::IsMojoBlob() {}

void Blob::CloneMojoBlob(mojo::PendingReceiver<mojom::blink::Blob> receiver) {}

mojo::PendingRemote<mojom::blink::Blob> Blob::AsMojoBlob() const {}

// static
String Blob::NormalizeType(const String& type) {}

}  // namespace blink