Copy as Markdown

Other Tools

//
// Automatically generated by ipdlc.
// Edit at your own risk
//
#include "mozilla/_ipdltest/PTestHangsParent.h"
#include "mozilla/ProfilerLabels.h"
#include "ipc/IPCMessageUtils.h"
#include "ipc/IPCMessageUtilsSpecializations.h"
#include "nsIFile.h"
#include "mozilla/ipc/Endpoint.h"
#include "mozilla/ipc/ProtocolMessageUtils.h"
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/ipc/ShmemMessageUtils.h"
#include "mozilla/ipc/TaintingIPCUtils.h"
namespace mozilla {
namespace _ipdltest {
auto PTestHangsParent::ProcessingError(
Result aCode,
const char* aReason) -> void
{
}
auto PTestHangsParent::ShouldContinueFromReplyTimeout() -> bool
{
return true;
}
MOZ_IMPLICIT PTestHangsParent::PTestHangsParent() :
mozilla::ipc::IToplevelProtocol("PTestHangsParent", kProtocolId, mozilla::ipc::ParentSide)
{
MOZ_COUNT_CTOR(PTestHangsParent);
}
PTestHangsParent::~PTestHangsParent()
{
MOZ_COUNT_DTOR(PTestHangsParent);
}
auto PTestHangsParent::ActorAlloc() -> void
{
MOZ_RELEASE_ASSERT(XRE_IsParentProcess(), "Invalid process for `PTestHangsParent'");
AddRef();
}
auto PTestHangsParent::ActorDealloc() -> void
{
Release();
}
auto PTestHangsParent::ManagedProtocolIds() const -> mozilla::Span<mozilla::ipc::ProtocolId const>
{
return {};
}
auto PTestHangsParent::GetManagedActors(mozilla::ipc::ProtocolId aProtocol) -> UntypedManagedContainer*
{
switch (aProtocol) {
default:
return nullptr;
}
}
auto PTestHangsParent::RejectPendingResponses(ResponseRejectReason aReason) -> void
{
mAsyncCallbacks.RejectPendingResponses(aReason);
}
auto PTestHangsParent::SendStart(
const uint32_t& hangMode,
mozilla::ipc::ResolveCallback<bool>&& aResolve,
mozilla::ipc::RejectCallback&& aReject) -> void
{
UniquePtr<IPC::Message> msg__ = PTestHangs::Msg_Start(MSG_ROUTING_CONTROL);
IPC::MessageWriter writer__{
(*(msg__)),
this};
IPC::WriteParam((&(writer__)), hangMode);
// Sentinel = 'hangMode'
((&(writer__)))->WriteSentinel(238289700);
if (mozilla::ipc::LoggingEnabledFor("PTestHangs", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTestHangsParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PTestHangs::Msg_Start", OTHER);
int32_t seqno__ = 0;
if (ChannelSend(std::move(msg__), (&(seqno__)))) {
mAsyncCallbacks.AddCallback(seqno__, PTestHangs::Reply_Start__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
auto maybe__detectedHang = IPC::ReadParam<bool>(aReader);
if (!maybe__detectedHang) {
(aReader)->FatalError("Error deserializing 'bool'");
return MsgValueError;
}
auto& detectedHang = *maybe__detectedHang;
// Sentinel = 'detectedHang'
if ((!((aReader)->ReadSentinel(524551361)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
return MsgValueError;
}
aReader->EndRead();
resolve(std::move(detectedHang));
return MsgProcessed;
}, std::move(aReject));
}
else {
aReject(::mozilla::ipc::ResponseRejectReason::SendError);
}
return;
}
auto PTestHangsParent::SendStart(const uint32_t& hangMode) -> RefPtr<StartPromise>
{
RefPtr<MozPromise<bool, ResponseRejectReason, true>::Private> promise__ = new MozPromise<bool, ResponseRejectReason, true>::Private(__func__);
promise__->UseDirectTaskDispatch(__func__);
SendStart(std::move(hangMode), [promise__](bool&& aValue) {
promise__->Resolve(std::move(aValue), __func__);
}, [promise__](ResponseRejectReason&& aReason) {
promise__->Reject(std::move(aReason), __func__);
});
return promise__;
}
auto PTestHangsParent::DeallocManagee(
int32_t aProtocolId,
IProtocol* aListener) -> void
{
FatalError("unreached");
return;
}
auto PTestHangsParent::OnMessageReceived(const Message& msg__) -> PTestHangsParent::Result
{
switch (msg__.type()) {
case PTestHangs::Reply_Start__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PTestHangs", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTestHangsParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PTestHangs::Msg_Start", OTHER);
return mAsyncCallbacks.GotReply(this, msg__);
}
default:
return MsgNotKnown;
case SHMEM_CREATED_MESSAGE_TYPE:
{
if (!ShmemCreated(msg__)) {
return MsgPayloadError;
}
return MsgProcessed;
}
case SHMEM_DESTROYED_MESSAGE_TYPE:
{
if (!ShmemDestroyed(msg__)) {
return MsgPayloadError;
}
return MsgProcessed;
}
}
}
auto PTestHangsParent::OnMessageReceived(
const Message& msg__,
UniquePtr<Message>& reply__) -> PTestHangsParent::Result
{
switch (msg__.type()) {
case PTestHangs::Msg_Hang__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PTestHangs", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTestHangsParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PTestHangs::Msg_Hang", OTHER);
IPC::MessageReader reader__{
msg__,
this};
auto maybe__hangMode = IPC::ReadParam<uint32_t>((&(reader__)));
if (!maybe__hangMode) {
FatalError("Error deserializing 'uint32_t'");
return MsgValueError;
}
auto& hangMode = *maybe__hangMode;
// Sentinel = 'hangMode'
if ((!(((&(reader__)))->ReadSentinel(238289700)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
return MsgValueError;
}
auto maybe__timeout = IPC::ReadParam<CrossProcessSemaphoreHandle>((&(reader__)));
if (!maybe__timeout) {
FatalError("Error deserializing 'CrossProcessSemaphoreHandle'");
return MsgValueError;
}
auto& timeout = *maybe__timeout;
// Sentinel = 'timeout'
if ((!(((&(reader__)))->ReadSentinel(201917192)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'CrossProcessSemaphoreHandle'");
return MsgValueError;
}
reader__.EndRead();
int32_t id__ = MSG_ROUTING_CONTROL;
mozilla::ipc::IPCResult __ok = (this)->RecvHang(std::move(hangMode), std::move(timeout));
if ((!(__ok))) {
mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
// Error handled in mozilla::ipc::IPCResult
return MsgProcessingError;
}
reply__ = PTestHangs::Reply_Hang(id__);
IPC::MessageWriter writer__{
(*(reply__)),
this};
if (mozilla::ipc::LoggingEnabledFor("PTestHangs", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTestHangsParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending reply ",
reply__->type(),
mozilla::ipc::MessageDirection::eSending);
}
return MsgProcessed;
}
default:
return MsgNotKnown;
}
}
} // namespace _ipdltest
} // namespace mozilla
namespace IPC {
auto ParamTraits<::mozilla::_ipdltest::PTestHangsParent*>::Write(
IPC::MessageWriter* aWriter,
const paramType& aVar) -> void
{
MOZ_RELEASE_ASSERT(
aWriter->GetActor(),
"Cannot serialize managed actors without an actor");
int32_t id;
if (!aVar) {
id = 0; // kNullActorId
} else {
id = aVar->Id();
if (id == 1) { // kFreedActorId
aVar->FatalError("Actor has been |delete|d");
}
MOZ_RELEASE_ASSERT(
aWriter->GetActor()->GetIPCChannel() == aVar->GetIPCChannel(),
"Actor must be from the same channel as the"
" actor it's being sent over");
MOZ_RELEASE_ASSERT(
aVar->CanSend(),
"Actor must still be open when sending");
}
IPC::WriteParam(aWriter, id);
}
auto ParamTraits<::mozilla::_ipdltest::PTestHangsParent*>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
MOZ_RELEASE_ASSERT(
aReader->GetActor(),
"Cannot deserialize managed actors without an actor");
mozilla::Maybe<mozilla::ipc::IProtocol*> actor = aReader->GetActor()
->ReadActor(aReader, true, "PTestHangs", PTestHangsMsgStart);
if (actor.isSome()) {
return static_cast<::mozilla::_ipdltest::PTestHangsParent*>(actor.ref());
}
return {};
}
} // namespace IPC