// // Automatically generated by ipdlc. // Edit at your own risk // #include "mozilla/ipc/PTestShellParent.h" #include "mozilla/ProfilerLabels.h" #include "mozilla/ipc/TestShellParent.h" #include "mozilla/dom/PContentParent.h" #include "mozilla/ipc/PTestShellCommandParent.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 ipc { MOZ_IMPLICIT PTestShellParent::PTestShellParent() : mozilla::ipc::IRefCountedProtocol(kProtocolId, mozilla::ipc::ParentSide) { MOZ_COUNT_CTOR(PTestShellParent); } PTestShellParent::~PTestShellParent() { MOZ_COUNT_DTOR(PTestShellParent); } auto PTestShellParent::ActorAlloc() -> void { AddRef(); } auto PTestShellParent::ActorDealloc() -> void { Release(); } auto PTestShellParent::OtherPid() const -> ::base::ProcessId { ::base::ProcessId pid = ::mozilla::ipc::IProtocol::ToplevelProtocol()->OtherPidMaybeInvalid(); MOZ_RELEASE_ASSERT(pid != ::base::kInvalidProcessId); return pid; } auto PTestShellParent::OtherChildID() const -> ::GeckoChildID { ::GeckoChildID childID = ::mozilla::ipc::IProtocol::ToplevelProtocol()->OtherChildIDMaybeInvalid(); MOZ_RELEASE_ASSERT(childID != -1); return childID; } auto PTestShellParent::OtherEndpointProcInfo() const -> ::mozilla::ipc::EndpointProcInfo { return ::mozilla::ipc::EndpointProcInfo{OtherPid(), OtherChildID()}; } auto PTestShellParent::Manager() const -> PContentParent* { return static_cast(IProtocol::Manager()); } auto PTestShellParent::ManagedPTestShellCommandParent(nsTArray& aArr) const -> void { mManagedPTestShellCommandParent.ToArray(aArr); } auto PTestShellParent::ManagedPTestShellCommandParent() const -> const ManagedContainer& { return mManagedPTestShellCommandParent; } auto PTestShellParent::ManagedProtocolIds() const -> mozilla::Span { static constexpr ::mozilla::ipc::ProtocolId sIds[] = { PTestShellCommandMsgStart }; return sIds; } auto PTestShellParent::GetManagedActors(mozilla::ipc::ProtocolId aProtocol) -> UntypedManagedContainer* { switch (aProtocol) { case PTestShellCommandMsgStart: return (&(mManagedPTestShellCommandParent)); default: return nullptr; } } auto PTestShellParent::OpenPTestShellCommandEndpoint(PTestShellCommandParent* aActor) -> ManagedEndpoint { if (!aActor) { NS_WARNING("Cannot bind null PTestShellCommandParent actor"); return ManagedEndpoint(); } if (!aActor->SetManagerAndRegister(this)) { NS_WARNING("Failed to bind PTestShellCommandParent actor"); return ManagedEndpoint(); } // 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(mozilla::ipc::PrivateIPDLInterface(), aActor); } auto PTestShellParent::BindPTestShellCommandEndpoint( ManagedEndpoint aEndpoint, PTestShellCommandParent* aActor) -> bool { return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this); } auto PTestShellParent::Send__delete__(PTestShellParent* actor) -> bool { if (!actor || !actor->CanSend()) { NS_WARNING("Attempt to __delete__ missing or closed actor"); return false; } UniquePtr msg__ = PTestShell::Msg___delete__((actor)->Id()); IPC::MessageWriter writer__{ (*(msg__)), actor}; if (mozilla::ipc::LoggingEnabledFor("PTestShell", mozilla::ipc::ParentSide)) { mozilla::ipc::LogMessageForProtocol( "PTestShellParent", actor->ToplevelProtocol()->OtherPidMaybeInvalid(), "Sending ", msg__->type(), mozilla::ipc::MessageDirection::eSending); } AUTO_PROFILER_LABEL("PTestShell::Msg___delete__", OTHER); bool sendok__ = (actor)->ChannelSend(std::move(msg__)); actor->ActorDisconnected(Deletion); return sendok__; } auto PTestShellParent::SendExecuteCommand(const nsAString& aCommand) -> bool { UniquePtr msg__ = PTestShell::Msg_ExecuteCommand(Id()); IPC::MessageWriter writer__{ (*(msg__)), this}; IPC::WriteParam((&(writer__)), aCommand); // Sentinel = 'aCommand' ((&(writer__)))->WriteSentinel(230097697); if (mozilla::ipc::LoggingEnabledFor("PTestShell", mozilla::ipc::ParentSide)) { mozilla::ipc::LogMessageForProtocol( "PTestShellParent", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Sending ", msg__->type(), mozilla::ipc::MessageDirection::eSending); } AUTO_PROFILER_LABEL("PTestShell::Msg_ExecuteCommand", OTHER); bool sendok__ = ChannelSend(std::move(msg__)); return sendok__; } auto PTestShellParent::SendPTestShellCommandConstructor(const nsAString& aCommand) -> PTestShellCommandParent* { PTestShellCommandParent* actor = (static_cast<::mozilla::ipc::TestShellParent*>(this))->AllocPTestShellCommandParent(aCommand); return SendPTestShellCommandConstructor(std::forward(actor), std::forward(aCommand)); } auto PTestShellParent::SendPTestShellCommandConstructor( PTestShellCommandParent* actor, const nsAString& aCommand) -> PTestShellCommandParent* { if (!actor) { NS_WARNING("Cannot bind null PTestShellCommandParent actor"); return nullptr; } if (!actor->SetManagerAndRegister(this)) { NS_WARNING("Failed to bind PTestShellCommandParent actor"); return nullptr; } // Build our constructor message. UniquePtr msg__ = PTestShell::Msg_PTestShellCommandConstructor(Id()); IPC::MessageWriter writer__{ (*(msg__)), this}; IPC::WriteParam((&(writer__)), (actor)->Id()); // Sentinel = 'actorid' ((&(writer__)))->WriteSentinel(193725159); IPC::WriteParam((&(writer__)), aCommand); // Sentinel = 'aCommand' ((&(writer__)))->WriteSentinel(230097697); // 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("PTestShell", mozilla::ipc::ParentSide)) { mozilla::ipc::LogMessageForProtocol( "PTestShellParent", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Sending ", msg__->type(), mozilla::ipc::MessageDirection::eSending); } AUTO_PROFILER_LABEL("PTestShell::Msg_PTestShellCommandConstructor", 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 PTestShellCommandParent constructor"); actor->ActorDisconnected(FailedConstructor); return nullptr; } return actor; } auto PTestShellParent::DeallocManagee( mozilla::ipc::ProtocolId aProtocolId, IProtocol* aListener) -> void { switch (aProtocolId) { case PTestShellCommandMsgStart: static_cast<::mozilla::ipc::TestShellParent*>(this)->DeallocPTestShellCommandParent(static_cast(aListener)); return; default: FatalError("unreached"); return; } } auto PTestShellParent::OnMessageReceived(const Message& msg__) -> PTestShellParent::Result { if (!CanSend()) { if (mozilla::ipc::LoggingEnabledFor("PTestShell", mozilla::ipc::ParentSide)) { mozilla::ipc::LogMessageForProtocol( "PTestShellParent", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Ignored message for dead actor", (&(msg__))->type(), mozilla::ipc::MessageDirection::eSending); } return MsgProcessed; } switch (msg__.type()) { case MANAGED_ENDPOINT_BOUND_MESSAGE_TYPE: { if (!mAwaitingManagedEndpointBind) { NS_WARNING("Unexpected managed endpoint lifecycle message after actor bound!"); return MsgNotAllowed; } mAwaitingManagedEndpointBind = false; return MsgProcessed; } case MANAGED_ENDPOINT_DROPPED_MESSAGE_TYPE: { if (!mAwaitingManagedEndpointBind) { NS_WARNING("Unexpected managed endpoint lifecycle message after actor bound!"); return MsgNotAllowed; } mAwaitingManagedEndpointBind = false; this->ActorDisconnected(ManagedEndpointDropped); return MsgProcessed; } case PTestShell::Reply___delete____ID: { return MsgProcessed; } case PTestShell::Reply_PTestShellCommandConstructor__ID: { return MsgProcessed; } default: return MsgNotKnown; } } auto PTestShellParent::OnMessageReceived( const Message& msg__, UniquePtr& reply__) -> PTestShellParent::Result { if (!CanSend()) { return MsgDropped; } return MsgNotKnown; } } // namespace ipc } // namespace mozilla