chromium/third_party/ipcz/src/reference_drivers/socket_transport.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.

#include "reference_drivers/socket_transport.h"

#include <fcntl.h>
#include <poll.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>

#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <memory>
#include <optional>
#include <utility>
#include <vector>

#include "reference_drivers/file_descriptor.h"
#include "reference_drivers/handle_eintr.h"
#include "third_party/abseil-cpp/absl/synchronization/mutex.h"
#include "third_party/abseil-cpp/absl/types/span.h"
#include "util/log.h"
#include "util/ref_counted.h"
#include "util/safe_math.h"

namespace ipcz::reference_drivers {

namespace {

constexpr size_t kMaxDescriptorsPerMessage =;

bool CreateNonBlockingSocketPair(FileDescriptor& first,
                                 FileDescriptor& second) {}

// Assuming `occupied` is either empty or a subspan of `container`, this ensures
// that `container` has at least `capacity` elements of storage available beyond
// the end of `occupied`, allocating additional storage if necessary. Returns
// the span of elements between the end of `occupied` and the end of
// `container`, with a length of at least `capacity`.
template <typename T>
absl::Span<T> EnsureCapacity(std::vector<T>& container,
                             absl::Span<T>& occupied,
                             size_t capacity) {}

}  // namespace

SocketTransport::SocketTransport() = default;

SocketTransport::SocketTransport(FileDescriptor fd) :{}

SocketTransport::~SocketTransport() {}

void SocketTransport::Activate(MessageHandler message_handler,
                               ErrorHandler error_handler) {}

void SocketTransport::Deactivate(std::function<void()> shutdown_callback) {}

bool SocketTransport::Send(Message message) {}

FileDescriptor SocketTransport::TakeDescriptor() {}

std::optional<size_t> SocketTransport::TrySend(absl::Span<uint8_t> header,
                                               Message message) {}

// static
void SocketTransport::RunIOThreadForTransport(Ref<SocketTransport> transport) {}

void SocketTransport::RunIOThread() {}

bool SocketTransport::IsOutgoingQueueEmpty() {}

absl::Span<uint8_t> SocketTransport::EnsureReadCapacity(size_t num_bytes) {}

void SocketTransport::CommitRead(size_t num_bytes,
                                 std::vector<FileDescriptor> descriptors) {}

void SocketTransport::NotifyError() {}

bool SocketTransport::TryDispatchMessages() {}

void SocketTransport::TryFlushingOutgoingQueue() {}

void SocketTransport::WakeIOThread() {}

void SocketTransport::ClearIOThreadSignal() {}

SocketTransport::DeferredMessage::DeferredMessage() = default;

SocketTransport::DeferredMessage::DeferredMessage(absl::Span<uint8_t> header,
                                                  Message message) {}

SocketTransport::DeferredMessage::DeferredMessage(DeferredMessage&&) = default;

SocketTransport::DeferredMessage& SocketTransport::DeferredMessage::operator=(
    DeferredMessage&&) = default;

SocketTransport::DeferredMessage::~DeferredMessage() = default;

SocketTransport::Message SocketTransport::DeferredMessage::AsMessage() {}

// static
SocketTransport::Pair SocketTransport::CreatePair() {}

}  // namespace ipcz::reference_drivers