chromium/mojo/core/ipcz_driver/data_pipe.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "mojo/core/ipcz_driver/data_pipe.h"

#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <limits>
#include <optional>
#include <tuple>

#include "base/check.h"
#include "base/memory/ref_counted.h"
#include "base/memory/unsafe_shared_memory_region.h"
#include "base/numerics/safe_math.h"
#include "base/synchronization/lock.h"
#include "mojo/core/ipcz_api.h"
#include "mojo/core/ipcz_driver/ring_buffer.h"
#include "third_party/ipcz/include/ipcz/ipcz.h"

namespace mojo::core::ipcz_driver {

namespace {

// The wire representation of a serialized DataPipe endpoint.
struct IPCZ_ALIGN(8) DataPipeHeader {};
static_assert;

// Attempts to put a single (32-bit) integer into the given `portal`. Returns
// true if successful, or false to indicate that the peer portal is closed.
bool SendPeerUpdate(IpczHandle portal, size_t num_bytes) {}

// Drains control messages from a DataPipe's portal. Each control message is a
// 32-bit unsigned integer conveying the size of a transaction. This accumulates
// the sum of any received sizes and returns it, along with a bit indicating
// whether the control portal is dead.
struct DrainResult {};
DrainResult DrainPeerUpdates(IpczHandle portal) {}

}  // namespace

DataPipe::PortalWrapper::PortalWrapper(ScopedIpczHandle handle)
    :{}

DataPipe::PortalWrapper::~PortalWrapper() = default;

DataPipe::DataPipe(EndpointType endpoint_type,
                   const Config& config,
                   scoped_refptr<SharedBuffer> buffer,
                   scoped_refptr<SharedBufferMapping> mapping)
    :{}

DataPipe::~DataPipe() {}

// static
std::optional<DataPipe::Pair> DataPipe::CreatePair(const Config& config) {}

bool DataPipe::AdoptPortal(ScopedIpczHandle portal) {}

scoped_refptr<DataPipe::PortalWrapper> DataPipe::GetPortal() {}

ScopedIpczHandle DataPipe::TakePortal() {}

MojoResult DataPipe::WriteData(const void* elements,
                               uint32_t& num_bytes,
                               MojoWriteDataFlags flags) {}

MojoResult DataPipe::BeginWriteData(void*& data,
                                    uint32_t& num_bytes,
                                    MojoBeginWriteDataFlags flags) {}

MojoResult DataPipe::EndWriteData(size_t num_bytes_produced) {}

MojoResult DataPipe::ReadData(void* elements,
                              uint32_t& num_bytes,
                              MojoReadDataFlags flags) {}

MojoResult DataPipe::BeginReadData(const void*& buffer,
                                   uint32_t& buffer_num_bytes) {}

MojoResult DataPipe::EndReadData(size_t num_bytes_consumed) {}

void DataPipe::Close() {}

bool DataPipe::IsSerializable() const {}

bool DataPipe::GetSerializedDimensions(Transport& transmitter,
                                       size_t& num_bytes,
                                       size_t& num_handles) {}

bool DataPipe::Serialize(Transport& transmitter,
                         base::span<uint8_t> data,
                         base::span<PlatformHandle> handles) {}

// static
scoped_refptr<DataPipe> DataPipe::Deserialize(
    base::span<const uint8_t> data,
    base::span<PlatformHandle> handles) {}

bool DataPipe::GetSignals(MojoHandleSignalsState& signals_state) {}

void DataPipe::FlushUpdatesFromPeer() {}

bool DataPipe::DeserializeRingBuffer(const RingBuffer::SerializedState& state) {}

DataPipe::Pair::Pair() = default;

DataPipe::Pair::Pair(const Pair&) = default;

DataPipe::Pair& DataPipe::Pair::operator=(const Pair&) = default;

DataPipe::Pair::~Pair() = default;

}  // namespace mojo::core::ipcz_driver