#include "ipcz/node_link_memory.h"
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <utility>
#include "ipcz/buffer_id.h"
#include "ipcz/driver_memory.h"
#include "ipcz/fragment_descriptor.h"
#include "ipcz/ipcz.h"
#include "ipcz/link_side.h"
#include "ipcz/node.h"
#include "ipcz/node_link.h"
#include "third_party/abseil-cpp/absl/base/macros.h"
#include "third_party/abseil-cpp/absl/numeric/bits.h"
#include "third_party/abseil-cpp/absl/synchronization/mutex.h"
#include "util/log.h"
#include "util/ref_counted.h"
namespace ipcz {
namespace {
constexpr size_t kPrimaryBufferSize = …;
constexpr size_t kPrimaryBufferReservedHeaderSize = …;
constexpr size_t kBlockAllocatorPageSize = …;
constexpr size_t kMinBlockAllocatorCapacity = …;
constexpr size_t kMaxBlockAllocatorCapacityPerFragmentSize = …;
constexpr size_t kMinFragmentSize = …;
constexpr size_t kMaxFragmentSizeForBlockAllocation = …;
constexpr size_t kMinBestEffortFallbackBlockSize = …;
InitialRouterLinkStateArray;
static_assert …;
struct IPCZ_ALIGN(8) PrimaryBufferHeader { … };
static_assert …;
constexpr size_t kPrimaryBufferHeaderPaddingSize = …;
uint32_t ToOffset(void* ptr, void* base) { … }
size_t GetBlockSizeForFragmentSize(size_t fragment_size) { … }
}
struct IPCZ_ALIGN(8) NodeLinkMemory::PrimaryBuffer { … };
NodeLinkMemory::NodeLinkMemory(Ref<Node> node,
LinkSide side,
const Features& remote_features,
DriverMemoryMapping primary_buffer_memory)
: … { … }
NodeLinkMemory::~NodeLinkMemory() = default;
void NodeLinkMemory::SetNodeLink(Ref<NodeLink> link) { … }
DriverMemoryWithMapping NodeLinkMemory::AllocateMemory(
const IpczDriver& driver) { … }
Ref<NodeLinkMemory> NodeLinkMemory::Create(Ref<Node> node,
LinkSide side,
const Features& remote_features,
DriverMemoryMapping memory) { … }
BufferId NodeLinkMemory::AllocateNewBufferId() { … }
SublinkId NodeLinkMemory::AllocateSublinkIds(size_t count) { … }
FragmentRef<RouterLinkState> NodeLinkMemory::GetInitialRouterLinkState(
size_t i) { … }
Fragment NodeLinkMemory::GetFragment(const FragmentDescriptor& descriptor) { … }
bool NodeLinkMemory::AddBlockBuffer(BufferId id,
size_t block_size,
DriverMemoryMapping mapping) { … }
Fragment NodeLinkMemory::AllocateFragment(size_t size) { … }
Fragment NodeLinkMemory::AllocateFragmentBestEffort(size_t size) { … }
bool NodeLinkMemory::FreeFragment(const Fragment& fragment) { … }
FragmentRef<RouterLinkState> NodeLinkMemory::TryAllocateRouterLinkState() { … }
void NodeLinkMemory::AllocateRouterLinkState(RouterLinkStateCallback callback) { … }
void NodeLinkMemory::WaitForBufferAsync(
BufferId id,
BufferPool::WaitForBufferCallback callback) { … }
bool NodeLinkMemory::CanExpandBlockCapacity(size_t block_size) { … }
void NodeLinkMemory::RequestBlockCapacity(
size_t block_size,
RequestBlockCapacityCallback callback) { … }
void NodeLinkMemory::OnCapacityRequestComplete(size_t block_size,
bool success) { … }
FragmentRef<RouterLinkState> NodeLinkMemory::InitializeRouterLinkStateFragment(
const Fragment& fragment) { … }
}