#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "mojo/core/ipcz_driver/mojo_trap.h"
#include <cstdint>
#include <optional>
#include <tuple>
#include <utility>
#include "base/check_op.h"
#include "base/feature_list.h"
#include "base/memory/ref_counted.h"
#include "base/not_fatal_until.h"
#include "base/notreached.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_restrictions.h"
#include "mojo/core/ipcz_api.h"
#include "mojo/core/ipcz_driver/data_pipe.h"
#include "third_party/ipcz/include/ipcz/ipcz.h"
namespace mojo::core::ipcz_driver {
namespace {
BASE_FEATURE(…);
void GetConditionsForMessagePipeSignals(MojoHandleSignals signals,
IpczTrapConditions* conditions) { … }
void GetConditionsForDataPipeSignals(MojoHandleSignals signals,
IpczTrapConditions* conditions) { … }
bool GetEventResultForSignalsState(const MojoHandleSignalsState& state,
MojoHandleSignals trapped_signals,
MojoResult& result) { … }
bool PopulateEventForDataPipe(DataPipe& pipe,
MojoHandleSignals trigger_signals,
MojoTrapEvent& event) { … }
void PopulateEventForMessagePipe(MojoHandleSignals trigger_signals,
const IpczPortalStatus& current_status,
MojoTrapEvent& event) { … }
bool CanArmDataPipeTrigger(DataPipe& pipe,
MojoHandleSignals signals,
MojoTrapEvent& event) { … }
}
struct MojoTrap::Trigger : public base::RefCountedThreadSafe<Trigger> { … };
MojoTrap::MojoTrap(MojoTrapEventHandler handler) : … { … }
MojoTrap::~MojoTrap() = default;
MojoResult MojoTrap::AddTrigger(MojoHandle handle,
MojoHandleSignals signals,
MojoTriggerCondition condition,
uintptr_t trigger_context) { … }
MojoResult MojoTrap::RemoveTrigger(uintptr_t trigger_context) { … }
MojoResult MojoTrap::Arm(MojoTrapEvent* blocking_events,
uint32_t* num_blocking_events) { … }
void MojoTrap::Close() { … }
void MojoTrap::TrapEventHandler(const IpczTrapEvent* event) { … }
void MojoTrap::TrapRemovalEventHandler(const IpczTrapEvent* event) { … }
void MojoTrap::HandleEvent(const IpczTrapEvent& event) { … }
void MojoTrap::HandleTrapRemoved(const IpczTrapEvent& event) { … }
IpczResult MojoTrap::ArmTrigger(Trigger& trigger, MojoTrapEvent& event) { … }
void MojoTrap::DispatchOrQueueTriggerRemoval(Trigger& trigger) { … }
void MojoTrap::DispatchOrQueueEvent(Trigger& trigger,
const MojoTrapEvent& event) { … }
void MojoTrap::DispatchEvent(const MojoTrapEvent& event) { … }
MojoTrap::PendingEvent::PendingEvent() = default;
MojoTrap::PendingEvent::PendingEvent(scoped_refptr<Trigger> trigger,
const MojoTrapEvent& event)
: … { … }
MojoTrap::PendingEvent::PendingEvent(PendingEvent&&) = default;
MojoTrap::PendingEvent::~PendingEvent() = default;
}