Copy as Markdown

Other Tools

//
// Automatically generated by ipdlc.
// Edit at your own risk
//
#include "mozilla/_ipdltest/PTestJSONChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/ipc/IPCCore.h"
#include "mozilla/_ipdltest/PTestJSONHandleChild.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 PTestJSONChild::ProcessingError(
Result aCode,
const char* aReason) -> void
{
}
auto PTestJSONChild::ShouldContinueFromReplyTimeout() -> bool
{
return true;
}
MOZ_IMPLICIT PTestJSONChild::PTestJSONChild() :
mozilla::ipc::IToplevelProtocol("PTestJSONChild", PTestJSONMsgStart, mozilla::ipc::ChildSide)
{
MOZ_COUNT_CTOR(PTestJSONChild);
}
PTestJSONChild::~PTestJSONChild()
{
MOZ_COUNT_DTOR(PTestJSONChild);
}
auto PTestJSONChild::ActorAlloc() -> void
{
AddRef();
}
auto PTestJSONChild::ActorDealloc() -> void
{
Release();
}
auto PTestJSONChild::ManagedPTestJSONHandleChild(nsTArray<PTestJSONHandleChild*>& aArr) const -> void
{
mManagedPTestJSONHandleChild.ToArray(aArr);
}
auto PTestJSONChild::ManagedPTestJSONHandleChild() const -> const ManagedContainer<PTestJSONHandleChild>&
{
return mManagedPTestJSONHandleChild;
}
auto PTestJSONChild::AllManagedActorsCount() const -> uint32_t
{
uint32_t total = 0;
total += mManagedPTestJSONHandleChild.Count();
return total;
}
auto PTestJSONChild::OpenPTestJSONHandleEndpoint(PTestJSONHandleChild* aActor) -> ManagedEndpoint<PTestJSONHandleParent>
{
if (!aActor) {
NS_WARNING("Cannot bind null PTestJSONHandleChild actor");
return ManagedEndpoint<PTestJSONHandleParent>();
}
if (aActor->SetManagerAndRegister(this)) {
mManagedPTestJSONHandleChild.Insert(aActor);
} else {
NS_WARNING("Failed to bind PTestJSONHandleChild actor");
return ManagedEndpoint<PTestJSONHandleParent>();
}
// Mark our actor as awaiting the other side to be bound. This will
// be cleared when a `MANAGED_ENDPOINT_{DROPPED,BOUND}` message is
// received.
aActor->mAwaitingManagedEndpointBind = true;
return ManagedEndpoint<PTestJSONHandleParent>(mozilla::ipc::PrivateIPDLInterface(), aActor);
}
auto PTestJSONChild::BindPTestJSONHandleEndpoint(
ManagedEndpoint<PTestJSONHandleChild> aEndpoint,
PTestJSONHandleChild* aActor) -> bool
{
return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this, mManagedPTestJSONHandleChild);
}
auto PTestJSONChild::SendPTestJSONHandleConstructor(PTestJSONHandleChild* actor) -> PTestJSONHandleChild*
{
if (!actor) {
NS_WARNING("Cannot bind null PTestJSONHandleChild actor");
return nullptr;
}
if (actor->SetManagerAndRegister(this)) {
mManagedPTestJSONHandleChild.Insert(actor);
} else {
NS_WARNING("Failed to bind PTestJSONHandleChild actor");
return nullptr;
}
// Build our constructor message.
UniquePtr<IPC::Message> msg__ = PTestJSON::Msg_PTestJSONHandleConstructor(MSG_ROUTING_CONTROL);
IPC::MessageWriter writer__{
(*(msg__)),
this};
IPC::WriteParam((&(writer__)), actor);
// Sentinel = 'actor'
((&(writer__)))->WriteSentinel(102892058);
// Notify the other side about the newly created actor. This can
// fail if our manager has already been destroyed.
//
// NOTE: If the send call fails due to toplevel channel teardown,
// the `IProtocol::ChannelSend` wrapper absorbs the error for us,
// so we don't tear down actors unexpectedly.
if (mozilla::ipc::LoggingEnabledFor("PTestJSON", mozilla::ipc::ChildSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTestJSONChild",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PTestJSON::Msg_PTestJSONHandleConstructor", OTHER);
bool sendok__ = ChannelSend(std::move(msg__));
// Warn, destroy the actor, and return null if the message failed to
// send. Otherwise, return the successfully created actor reference.
if (!sendok__) {
NS_WARNING("Error sending PTestJSONHandleChild constructor");
actor->ActorDisconnected(FailedConstructor);
return nullptr;
}
return actor;
}
auto PTestJSONChild::SendTest(
const JSONVariant& i,
JSONVariant* o) -> bool
{
UniquePtr<IPC::Message> msg__ = PTestJSON::Msg_Test(MSG_ROUTING_CONTROL);
IPC::MessageWriter writer__{
(*(msg__)),
this};
IPC::WriteParam((&(writer__)), i);
// Sentinel = 'i'
((&(writer__)))->WriteSentinel(6946922);
UniquePtr<Message> reply__;
if (mozilla::ipc::LoggingEnabledFor("PTestJSON", mozilla::ipc::ChildSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTestJSONChild",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Sending ",
msg__->type(),
mozilla::ipc::MessageDirection::eSending);
}
AUTO_PROFILER_LABEL("PTestJSON::Msg_Test", OTHER);
bool sendok__ = false;
{
AUTO_PROFILER_TRACING_MARKER("Sync IPC", "PTestJSON::Msg_Test", IPC);
sendok__ = ChannelSend(std::move(msg__), (&(reply__)));
}
if ((!(sendok__))) {
return false;
}
if (mozilla::ipc::LoggingEnabledFor("PTestJSON", mozilla::ipc::ChildSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTestJSONChild",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received reply ",
reply__->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
IPC::MessageReader reader__{
(*(reply__)),
this};
auto maybe__o__reply = IPC::ReadParam<JSONVariant>((&(reader__)));
if (!maybe__o__reply) {
FatalError("Error deserializing 'JSONVariant'");
return false;
}
auto& o__reply = *maybe__o__reply;
// Sentinel = 'o'
if ((!(((&(reader__)))->ReadSentinel(7340144)))) {
mozilla::ipc::SentinelReadError("Error deserializing 'JSONVariant'");
return false;
}
(*(o)) = std::move(o__reply);
reader__.EndRead();
return true;
}
auto PTestJSONChild::RemoveManagee(
int32_t aProtocolId,
IProtocol* aListener) -> void
{
switch (aProtocolId) {
case PTestJSONHandleMsgStart:
MOZ_ALWAYS_TRUE(mManagedPTestJSONHandleChild.EnsureRemoved(static_cast<PTestJSONHandleChild*>(aListener)));
return;
default:
FatalError("unreached");
return; }
}
auto PTestJSONChild::DeallocManagee(
int32_t aProtocolId,
IProtocol* aListener) -> void
{
switch (aProtocolId) {
default:
FatalError("unreached");
return;
}
}
auto PTestJSONChild::OnMessageReceived(const Message& msg__) -> PTestJSONChild::Result
{
int32_t route__ = msg__.routing_id();
if (MSG_ROUTING_CONTROL != route__) {
IProtocol* routed__ = Lookup(route__);
if (!routed__ || !routed__->GetLifecycleProxy()) {
if (mozilla::ipc::LoggingEnabledFor("PTestJSON", mozilla::ipc::ChildSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTestJSONChild",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Ignored message for dead actor",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eSending);
}
return MsgProcessed;
}
RefPtr<mozilla::ipc::ActorLifecycleProxy> proxy__ =
routed__->GetLifecycleProxy();
return proxy__->Get()->OnMessageReceived(msg__);
}
switch (msg__.type()) {
case PTestJSON::Msg_Start__ID:
{
if (mozilla::ipc::LoggingEnabledFor("PTestJSON", mozilla::ipc::ChildSide)) {
mozilla::ipc::LogMessageForProtocol(
"PTestJSONChild",
this->ToplevelProtocol()->OtherPidMaybeInvalid(),
"Received ",
(&(msg__))->type(),
mozilla::ipc::MessageDirection::eReceiving);
}
AUTO_PROFILER_LABEL("PTestJSON::Msg_Start", OTHER);
mozilla::ipc::IPCResult __ok = (this)->RecvStart();
if ((!(__ok))) {
mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
// Error handled in mozilla::ipc::IPCResult
return MsgProcessingError;
}
return MsgProcessed;
}
case PTestJSON::Reply_PTestJSONHandleConstructor__ID:
{
return MsgProcessed;
}
case PTestJSON::Reply___delete____ID:
{
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 PTestJSONChild::OnMessageReceived(
const Message& msg__,
UniquePtr<Message>& reply__) -> PTestJSONChild::Result
{
int32_t route__ = msg__.routing_id();
if (MSG_ROUTING_CONTROL != route__) {
IProtocol* routed__ = Lookup(route__);
if (!routed__ || !routed__->GetLifecycleProxy()) {
return MsgRouteError;
}
RefPtr<mozilla::ipc::ActorLifecycleProxy> proxy__ =
routed__->GetLifecycleProxy();
return proxy__->Get()->OnMessageReceived(msg__, reply__);
}
return MsgNotKnown;
}
auto PTestJSONChild::DoomSubtree() -> void
{
for (auto* key : mManagedPTestJSONHandleChild) {
key->DoomSubtree();
}
SetDoomed();
}
auto PTestJSONChild::PeekManagedActor() -> IProtocol*
{
if (IProtocol* actor = mManagedPTestJSONHandleChild.Peek()) {
return actor;
}
return nullptr;
}
} // namespace _ipdltest
} // namespace mozilla
namespace IPC {
auto ParamTraits<::mozilla::_ipdltest::PTestJSONChild*>::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::PTestJSONChild*>::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, "PTestJSON", PTestJSONMsgStart);
if (actor.isSome()) {
return static_cast<::mozilla::_ipdltest::PTestJSONChild*>(actor.ref());
}
return {};
}
} // namespace IPC