Copy as Markdown

Other Tools

//
// Automatically generated by ipdlc.
// Edit at your own risk
//
#include "mozilla/_ipdltest/PTestAsyncReturnsParent.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 PTestAsyncReturnsParent::ProcessingError(
Result aCode,
const char* aReason) -> void
{
}
auto PTestAsyncReturnsParent::ShouldContinueFromReplyTimeout() -> bool
{
return true;
}
MOZ_IMPLICIT PTestAsyncReturnsParent::PTestAsyncReturnsParent() :
mozilla::ipc::IToplevelProtocol("PTestAsyncReturnsParent", kProtocolId, mozilla::ipc::ParentSide)
{
MOZ_COUNT_CTOR(PTestAsyncReturnsParent);
}
PTestAsyncReturnsParent::~PTestAsyncReturnsParent()
{
MOZ_COUNT_DTOR(PTestAsyncReturnsParent);
}
auto PTestAsyncReturnsParent::ActorAlloc() -> void
{
MOZ_RELEASE_ASSERT(XRE_IsParentProcess(), "Invalid process for `PTestAsyncReturnsParent'");
AddRef();
}
auto PTestAsyncReturnsParent::ActorDealloc() -> void
{
Release();
}
auto PTestAsyncReturnsParent::ManagedProtocolIds() const -> mozilla::Span<mozilla::ipc::ProtocolId const>
{
return {};
}
auto PTestAsyncReturnsParent::GetManagedActors(mozilla::ipc::ProtocolId aProtocol) -> UntypedManagedContainer*
{
switch (aProtocol) {
default:
return nullptr;
}
}
auto PTestAsyncReturnsParent::RejectPendingResponses(ResponseRejectReason aReason) -> void
{
mAsyncCallbacks.RejectPendingResponses(aReason);
}
auto PTestAsyncReturnsParent::SendPing(
mozilla::ipc::ResolveCallback<bool>&& aResolve,
mozilla::ipc::RejectCallback&& aReject) -> void
{
UniquePtr<IPC::Message> msg__ = PTestAsyncReturns::Msg_Ping(MSG_ROUTING_CONTROL);
IPC::MessageWriter writer__{
(*(msg__)),
this};
if (mozilla::ipc::LoggingEnabledFor("PTestAsyncReturns", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTestAsyncReturnsParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PTestAsyncReturns::Msg_Ping", OTHER);
int32_t seqno__ = 0;
if (ChannelSend(std::move(msg__), (&(seqno__)))) {
mAsyncCallbacks.AddCallback(seqno__, PTestAsyncReturns::Reply_Ping__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
auto maybe__one = IPC::ReadParam<bool>(aReader);
if (!maybe__one) {
(aReader)->FatalError("Error deserializing 'bool'");
return MsgValueError;
}
auto& one = *maybe__one;
// Sentinel = 'one'
if ((!((aReader)->ReadSentinel(43057475)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
return MsgValueError;
}
aReader->EndRead();
resolve(std::move(one));
return MsgProcessed;
}, std::move(aReject));
}
else {
aReject(::mozilla::ipc::ResponseRejectReason::SendError);
}
return;
}
auto PTestAsyncReturnsParent::SendPing() -> RefPtr<PingPromise>
{
RefPtr<MozPromise<bool, ResponseRejectReason, true>::Private> promise__ = new MozPromise<bool, ResponseRejectReason, true>::Private(__func__);
promise__->UseDirectTaskDispatch(__func__);
SendPing([promise__](bool&& aValue) {
promise__->Resolve(std::move(aValue), __func__);
}, [promise__](ResponseRejectReason&& aReason) {
promise__->Reject(std::move(aReason), __func__);
});
return promise__;
}
auto PTestAsyncReturnsParent::SendNoReturn(
mozilla::ipc::ResolveCallback<bool>&& aResolve,
mozilla::ipc::RejectCallback&& aReject) -> void
{
UniquePtr<IPC::Message> msg__ = PTestAsyncReturns::Msg_NoReturn(MSG_ROUTING_CONTROL);
IPC::MessageWriter writer__{
(*(msg__)),
this};
if (mozilla::ipc::LoggingEnabledFor("PTestAsyncReturns", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTestAsyncReturnsParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PTestAsyncReturns::Msg_NoReturn", OTHER);
int32_t seqno__ = 0;
if (ChannelSend(std::move(msg__), (&(seqno__)))) {
mAsyncCallbacks.AddCallback(seqno__, PTestAsyncReturns::Reply_NoReturn__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
auto maybe__unused = IPC::ReadParam<bool>(aReader);
if (!maybe__unused) {
(aReader)->FatalError("Error deserializing 'bool'");
return MsgValueError;
}
auto& unused = *maybe__unused;
// Sentinel = 'unused'
if ((!((aReader)->ReadSentinel(155517589)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
return MsgValueError;
}
aReader->EndRead();
resolve(std::move(unused));
return MsgProcessed;
}, std::move(aReject));
}
else {
aReject(::mozilla::ipc::ResponseRejectReason::SendError);
}
return;
}
auto PTestAsyncReturnsParent::SendNoReturn() -> RefPtr<NoReturnPromise>
{
RefPtr<MozPromise<bool, ResponseRejectReason, true>::Private> promise__ = new MozPromise<bool, ResponseRejectReason, true>::Private(__func__);
promise__->UseDirectTaskDispatch(__func__);
SendNoReturn([promise__](bool&& aValue) {
promise__->Resolve(std::move(aValue), __func__);
}, [promise__](ResponseRejectReason&& aReason) {
promise__->Reject(std::move(aReason), __func__);
});
return promise__;
}
auto PTestAsyncReturnsParent::DeallocManagee(
int32_t aProtocolId,
IProtocol* aListener) -> void
{
FatalError("unreached");
return;
}
auto PTestAsyncReturnsParent::OnMessageReceived(const Message& msg__) -> PTestAsyncReturnsParent::Result
{
switch (msg__.type()) {
case PTestAsyncReturns::Reply_Ping__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PTestAsyncReturns", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTestAsyncReturnsParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PTestAsyncReturns::Msg_Ping", OTHER);
return mAsyncCallbacks.GotReply(this, msg__);
}
case PTestAsyncReturns::Reply_NoReturn__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PTestAsyncReturns", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTestAsyncReturnsParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PTestAsyncReturns::Msg_NoReturn", OTHER);
return mAsyncCallbacks.GotReply(this, msg__);
}
case PTestAsyncReturns::Msg_Pong__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PTestAsyncReturns", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTestAsyncReturnsParent",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PTestAsyncReturns::Msg_Pong", OTHER);
int32_t id__ = MSG_ROUTING_CONTROL;
UniquePtr<IPC::Message> reply__(PTestAsyncReturns::Reply_Pong(id__));
reply__->set_seqno(msg__.seqno());
RefPtr<mozilla::ipc::IPDLResolverInner> resolver__ =
new mozilla::ipc::IPDLResolverInner(std::move(reply__), this);
PongResolver resolver = [resolver__ = std::move(resolver__)](std::tuple<const uint32_t&, const uint32_t&> aParam) {
resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) {
IPC::MessageWriter writer__(*reply__, self__);
IPC::WriteParam((&(writer__)), std::get<0>(aParam));
// Sentinel = 'param1'
((&(writer__)))->WriteSentinel(142672451);
IPC::WriteParam((&(writer__)), std::get<1>(aParam));
// Sentinel = 'param2'
((&(writer__)))->WriteSentinel(142737988);
if (mozilla::ipc::LoggingEnabledFor("PTestAsyncReturns", mozilla::ipc::ParentSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTestAsyncReturnsParent",
self__->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending reply ",
reply__->type(),
mozilla::ipc::MessageDirection::eSending);
}
});
};
mozilla::ipc::IPCResult __ok = (this)->RecvPong(std::move(resolver));
if ((!(__ok))) {
mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
// Error handled in mozilla::ipc::IPCResult
return MsgProcessingError;
}
return MsgProcessed;
}
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 PTestAsyncReturnsParent::OnMessageReceived(
const Message& msg__,
UniquePtr<Message>& reply__) -> PTestAsyncReturnsParent::Result
{
MOZ_ASSERT_UNREACHABLE("message protocol not supported");
return MsgNotKnown;
}
} // namespace _ipdltest
} // namespace mozilla
namespace IPC {
auto ParamTraits<::mozilla::_ipdltest::PTestAsyncReturnsParent*>::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::PTestAsyncReturnsParent*>::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, "PTestAsyncReturns", PTestAsyncReturnsMsgStart);
if (actor.isSome()) {
return static_cast<::mozilla::_ipdltest::PTestAsyncReturnsParent*>(actor.ref());
}
return {};
}
} // namespace IPC