#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "mojo/core/ipcz_driver/mojo_message.h"
#include <cstddef>
#include <cstdint>
#include <utility>
#include "base/containers/span.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "mojo/core/ipcz_api.h"
#include "mojo/core/ipcz_driver/data_pipe.h"
#include "mojo/core/scoped_ipcz_handle.h"
#include "third_party/abseil-cpp/absl/container/inlined_vector.h"
#include "third_party/ipcz/include/ipcz/ipcz.h"
namespace mojo::core::ipcz_driver {
namespace {
constexpr int kGrowthFactor = …;
bool FixUpDataPipeHandles(std::vector<IpczHandle>& handles) { … }
}
MojoMessage::MojoMessage() = default;
MojoMessage::MojoMessage(std::vector<uint8_t> data,
std::vector<IpczHandle> handles)
: … { … }
MojoMessage::~MojoMessage() { … }
void MojoMessage::SetParcel(ScopedIpczHandle parcel) { … }
MojoResult MojoMessage::ReserveCapacity(uint32_t payload_buffer_size,
uint32_t* buffer_size) { … }
MojoResult MojoMessage::AppendData(uint32_t additional_num_bytes,
const MojoHandle* handles,
uint32_t num_handles,
void** buffer,
uint32_t* buffer_size,
bool commit_size) { … }
IpczResult MojoMessage::GetData(void** buffer,
uint32_t* num_bytes,
MojoHandle* handles,
uint32_t* num_handles,
bool consume_handles) { … }
void MojoMessage::AttachDataPipePortals() { … }
MojoResult MojoMessage::SetContext(uintptr_t context,
MojoMessageContextSerializer serializer,
MojoMessageContextDestructor destructor) { … }
MojoResult MojoMessage::Serialize() { … }
IpczResult MojoMessage::SerializeForIpcz(uintptr_t object,
uint32_t,
const void*,
volatile void* data,
size_t* num_bytes,
IpczHandle* handles,
size_t* num_handles) { … }
void MojoMessage::DestroyForIpcz(uintptr_t object, uint32_t, const void*) { … }
ScopedIpczHandle MojoMessage::Box(std::unique_ptr<MojoMessage> message) { … }
std::unique_ptr<MojoMessage> MojoMessage::UnwrapFrom(MojoMessage& message) { … }
IpczResult MojoMessage::SerializeForIpczImpl(volatile void* data,
size_t* num_bytes,
IpczHandle* handles,
size_t* num_handles) { … }
}