#include "third_party/blink/renderer/platform/blob/blob_data.h"
#include <memory>
#include <utility>
#include "base/containers/span.h"
#include "base/memory/ptr_util.h"
#include "base/memory/scoped_refptr.h"
#include "base/task/single_thread_task_runner.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/network/public/mojom/data_pipe_getter.mojom-blink.h"
#include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h"
#include "third_party/blink/public/mojom/blob/blob.mojom-blink.h"
#include "third_party/blink/public/mojom/blob/blob_registry.mojom-blink.h"
#include "third_party/blink/public/mojom/blob/data_element.mojom-blink.h"
#include "third_party/blink/public/mojom/blob/file_backed_blob_factory.mojom-blink.h"
#include "third_party/blink/public/platform/file_path_conversion.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/blob/blob_bytes_provider.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/text/line_ending.h"
#include "third_party/blink/renderer/platform/wtf/text/text_encoding.h"
#include "third_party/blink/renderer/platform/wtf/thread_specific.h"
#include "third_party/blink/renderer/platform/wtf/uuid.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
BytesProvider;
DataElement;
DataElementBlob;
DataElementBytes;
DataElementBytesPtr;
DataElementFile;
DataElementPtr;
namespace {
bool IsValidBlobType(const String& type) { … }
mojom::blink::BlobRegistry* g_blob_registry_for_testing = …;
mojom::blink::BlobRegistry* GetThreadSpecificRegistry() { … }
}
constexpr int64_t BlobData::kToEndOfFile;
RawData::RawData() = default;
BlobData::BlobData(FileCompositionStatus composition)
: … { … }
BlobData::~BlobData() = default;
Vector<mojom::blink::DataElementPtr> BlobData::ReleaseElements() { … }
void BlobData::SetContentType(const String& content_type) { … }
void BlobData::AppendData(scoped_refptr<RawData> data) { … }
void BlobData::AppendBlob(scoped_refptr<BlobDataHandle> data_handle,
int64_t offset,
int64_t length) { … }
void BlobData::AppendText(const String& text,
bool do_normalize_line_endings_to_native) { … }
void BlobData::AppendBytes(base::span<const uint8_t> bytes) { … }
uint64_t BlobData::length() const { … }
void BlobData::AppendDataInternal(base::span<const char> data,
scoped_refptr<RawData> raw_data) { … }
scoped_refptr<BlobDataHandle> BlobDataHandle::CreateForFile(
mojom::blink::FileBackedBlobFactory* file_backed_blob_factory,
const String& path,
int64_t offset,
int64_t length,
const std::optional<base::Time>& expected_modification_time,
const String& content_type) { … }
scoped_refptr<BlobDataHandle> BlobDataHandle::CreateForFileSync(
mojom::blink::FileBackedBlobFactory* file_backed_blob_factory,
const String& path,
int64_t offset,
int64_t length,
const std::optional<base::Time>& expected_modification_time,
const String& content_type) { … }
scoped_refptr<BlobDataHandle> BlobDataHandle::Create(
const String& uuid,
const String& type,
uint64_t size,
mojo::PendingRemote<mojom::blink::Blob> blob_remote) { … }
BlobDataHandle::BlobDataHandle()
: … { … }
BlobDataHandle::BlobDataHandle(std::unique_ptr<BlobData> data, uint64_t size)
: … { … }
BlobDataHandle::BlobDataHandle(
mojom::blink::FileBackedBlobFactory* file_backed_blob_factory,
mojom::blink::DataElementFilePtr file_element,
const String& content_type,
uint64_t size,
bool synchronous_register)
: … { … }
BlobDataHandle::BlobDataHandle(const String& uuid,
const String& type,
uint64_t size)
: … { … }
BlobDataHandle::BlobDataHandle(
const String& uuid,
const String& type,
uint64_t size,
mojo::PendingRemote<mojom::blink::Blob> blob_remote)
: … { … }
BlobDataHandle::~BlobDataHandle() = default;
mojo::PendingRemote<mojom::blink::Blob> BlobDataHandle::CloneBlobRemote() { … }
void BlobDataHandle::CloneBlobRemote(
mojo::PendingReceiver<mojom::blink::Blob> receiver) { … }
mojo::PendingRemote<network::mojom::blink::DataPipeGetter>
BlobDataHandle::AsDataPipeGetter() { … }
void BlobDataHandle::ReadAll(
mojo::ScopedDataPipeProducerHandle pipe,
mojo::PendingRemote<mojom::blink::BlobReaderClient> client) { … }
void BlobDataHandle::ReadRange(
uint64_t offset,
uint64_t length,
mojo::ScopedDataPipeProducerHandle pipe,
mojo::PendingRemote<mojom::blink::BlobReaderClient> client) { … }
bool BlobDataHandle::CaptureSnapshot(
uint64_t* snapshot_size,
std::optional<base::Time>* snapshot_modification_time) { … }
mojom::blink::BlobRegistry* BlobDataHandle::GetBlobRegistry() { … }
void BlobDataHandle::SetBlobRegistryForTesting(
mojom::blink::BlobRegistry* registry) { … }
}