#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "services/network/web_bundle/web_bundle_chunked_buffer.h"
#include <algorithm>
#include "base/check.h"
#include "base/memory/ptr_util.h"
#include "base/not_fatal_until.h"
#include "base/numerics/checked_math.h"
namespace network {
namespace {
class ChunkedBufferDataSource : public mojo::DataPipeProducer::DataSource { … };
}
WebBundleChunkedBuffer::Chunk::Chunk(
uint64_t start_pos,
scoped_refptr<const base::RefCountedBytes> bytes)
: … { … }
WebBundleChunkedBuffer::Chunk::~Chunk() = default;
WebBundleChunkedBuffer::Chunk::Chunk(const WebBundleChunkedBuffer::Chunk&) =
default;
WebBundleChunkedBuffer::Chunk::Chunk(WebBundleChunkedBuffer::Chunk&&) = default;
uint64_t WebBundleChunkedBuffer::Chunk::start_pos() const { … }
uint64_t WebBundleChunkedBuffer::Chunk::end_pos() const { … }
size_t WebBundleChunkedBuffer::Chunk::size() const { … }
const uint8_t* WebBundleChunkedBuffer::Chunk::data() const { … }
WebBundleChunkedBuffer::WebBundleChunkedBuffer() = default;
WebBundleChunkedBuffer::WebBundleChunkedBuffer(ChunkVector chunks)
: … { … }
WebBundleChunkedBuffer::~WebBundleChunkedBuffer() = default;
void WebBundleChunkedBuffer::Append(base::span<const uint8_t> data) { … }
bool WebBundleChunkedBuffer::ContainsAll(uint64_t offset,
uint64_t length) const { … }
std::unique_ptr<mojo::DataPipeProducer::DataSource>
WebBundleChunkedBuffer::CreateDataSource(uint64_t offset,
uint64_t max_length) const { … }
uint64_t WebBundleChunkedBuffer::size() const { … }
WebBundleChunkedBuffer::ChunkVector::const_iterator
WebBundleChunkedBuffer::FindChunk(uint64_t pos) const { … }
std::unique_ptr<const WebBundleChunkedBuffer>
WebBundleChunkedBuffer::CreatePartialBuffer(uint64_t offset,
uint64_t length) const { … }
bool WebBundleChunkedBuffer::empty() const { … }
uint64_t WebBundleChunkedBuffer::start_pos() const { … }
uint64_t WebBundleChunkedBuffer::end_pos() const { … }
uint64_t WebBundleChunkedBuffer::GetAvailableLength(uint64_t offset,
uint64_t max_length) const { … }
uint64_t WebBundleChunkedBuffer::ReadData(uint64_t offset,
base::span<uint8_t> out) const { … }
}