// // Automatically generated by ipdlc. // Edit at your own risk // #include "mozilla/dom/PRemoteWorkerControllerChild.h" #include "mozilla/ProfilerLabels.h" #include "mozilla/dom/ClientIPCUtils.h" #include "mozilla/dom/ReferrerInfoUtils.h" #include "mozilla/dom/RemoteType.h" #include "mozilla/dom/RemoteWorkerControllerChild.h" #include "mozilla/dom/ServiceWorkerIPCUtils.h" #include "mozilla/dom/WorkerIPCUtils.h" #include "mozilla/ipc/IPCCore.h" #include "nsIPrincipal.h" #include "mozilla/ipc/PBackgroundChild.h" #include "mozilla/dom/PFetchEventOpChild.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 dom { MOZ_IMPLICIT PRemoteWorkerControllerChild::PRemoteWorkerControllerChild() : mozilla::ipc::IRefCountedProtocol(kProtocolId, mozilla::ipc::ChildSide) { MOZ_COUNT_CTOR(PRemoteWorkerControllerChild); } PRemoteWorkerControllerChild::~PRemoteWorkerControllerChild() { MOZ_COUNT_DTOR(PRemoteWorkerControllerChild); } auto PRemoteWorkerControllerChild::ActorAlloc() -> void { AddRef(); } auto PRemoteWorkerControllerChild::ActorDealloc() -> void { Release(); } auto PRemoteWorkerControllerChild::OtherPid() const -> ::base::ProcessId { ::base::ProcessId pid = ::mozilla::ipc::IProtocol::ToplevelProtocol()->OtherPidMaybeInvalid(); MOZ_RELEASE_ASSERT(pid != ::base::kInvalidProcessId); return pid; } auto PRemoteWorkerControllerChild::OtherChildID() const -> ::GeckoChildID { ::GeckoChildID childID = ::mozilla::ipc::IProtocol::ToplevelProtocol()->OtherChildIDMaybeInvalid(); MOZ_RELEASE_ASSERT(childID != -1); return childID; } auto PRemoteWorkerControllerChild::OtherEndpointProcInfo() const -> ::mozilla::ipc::EndpointProcInfo { return ::mozilla::ipc::EndpointProcInfo{OtherPid(), OtherChildID()}; } auto PRemoteWorkerControllerChild::Manager() const -> PBackgroundChild* { return static_cast(IProtocol::Manager()); } auto PRemoteWorkerControllerChild::ManagedPFetchEventOpChild(nsTArray& aArr) const -> void { mManagedPFetchEventOpChild.ToArray(aArr); } auto PRemoteWorkerControllerChild::ManagedPFetchEventOpChild() const -> const ManagedContainer& { return mManagedPFetchEventOpChild; } auto PRemoteWorkerControllerChild::ManagedProtocolIds() const -> mozilla::Span { static constexpr ::mozilla::ipc::ProtocolId sIds[] = { PFetchEventOpMsgStart }; return sIds; } auto PRemoteWorkerControllerChild::GetManagedActors(mozilla::ipc::ProtocolId aProtocol) -> UntypedManagedContainer* { switch (aProtocol) { case PFetchEventOpMsgStart: return (&(mManagedPFetchEventOpChild)); default: return nullptr; } } auto PRemoteWorkerControllerChild::RejectPendingResponses(ResponseRejectReason aReason) -> void { mAsyncCallbacks.RejectPendingResponses(aReason); } auto PRemoteWorkerControllerChild::OpenPFetchEventOpEndpoint(PFetchEventOpChild* aActor) -> ManagedEndpoint { if (!aActor) { NS_WARNING("Cannot bind null PFetchEventOpChild actor"); return ManagedEndpoint(); } if (!aActor->SetManagerAndRegister(this)) { NS_WARNING("Failed to bind PFetchEventOpChild 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 PRemoteWorkerControllerChild::BindPFetchEventOpEndpoint( ManagedEndpoint aEndpoint, PFetchEventOpChild* aActor) -> bool { return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this); } auto PRemoteWorkerControllerChild::SendPFetchEventOpConstructor(const ParentToParentServiceWorkerFetchEventOpArgs& aArgs) -> PFetchEventOpChild* { PFetchEventOpChild* actor = (static_cast<::mozilla::dom::RemoteWorkerControllerChild*>(this))->AllocPFetchEventOpChild(aArgs); return SendPFetchEventOpConstructor(std::forward(actor), std::forward(aArgs)); } auto PRemoteWorkerControllerChild::SendPFetchEventOpConstructor( PFetchEventOpChild* actor, const ParentToParentServiceWorkerFetchEventOpArgs& aArgs) -> PFetchEventOpChild* { if (!actor) { NS_WARNING("Cannot bind null PFetchEventOpChild actor"); return nullptr; } if (!actor->SetManagerAndRegister(this)) { NS_WARNING("Failed to bind PFetchEventOpChild actor"); return nullptr; } // Build our constructor message. UniquePtr msg__ = PRemoteWorkerController::Msg_PFetchEventOpConstructor(Id()); IPC::MessageWriter writer__{ (*(msg__)), this}; IPC::WriteParam((&(writer__)), (actor)->Id()); // Sentinel = 'actorid' ((&(writer__)))->WriteSentinel(193725159); IPC::WriteParam((&(writer__)), aArgs); // Sentinel = 'aArgs' ((&(writer__)))->WriteSentinel(92602863); // 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("PRemoteWorkerController", mozilla::ipc::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PRemoteWorkerControllerChild", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Sending ", msg__->type(), mozilla::ipc::MessageDirection::eSending); } AUTO_PROFILER_LABEL("PRemoteWorkerController::Msg_PFetchEventOpConstructor", 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 PFetchEventOpChild constructor"); actor->ActorDisconnected(FailedConstructor); return nullptr; } return actor; } auto PRemoteWorkerControllerChild::Send__delete__(PRemoteWorkerControllerChild* actor) -> bool { if (!actor || !actor->CanSend()) { NS_WARNING("Attempt to __delete__ missing or closed actor"); return false; } UniquePtr msg__ = PRemoteWorkerController::Msg___delete__((actor)->Id()); IPC::MessageWriter writer__{ (*(msg__)), actor}; if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerController", mozilla::ipc::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PRemoteWorkerControllerChild", actor->ToplevelProtocol()->OtherPidMaybeInvalid(), "Sending ", msg__->type(), mozilla::ipc::MessageDirection::eSending); } AUTO_PROFILER_LABEL("PRemoteWorkerController::Msg___delete__", OTHER); bool sendok__ = (actor)->ChannelSend(std::move(msg__)); actor->ActorDisconnected(Deletion); return sendok__; } auto PRemoteWorkerControllerChild::SendShutdown( mozilla::ipc::ResolveCallback&& aResolve, mozilla::ipc::RejectCallback&& aReject) -> void { UniquePtr msg__ = PRemoteWorkerController::Msg_Shutdown(Id()); IPC::MessageWriter writer__{ (*(msg__)), this}; if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerController", mozilla::ipc::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PRemoteWorkerControllerChild", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Sending ", msg__->type(), mozilla::ipc::MessageDirection::eSending); } AUTO_PROFILER_LABEL("PRemoteWorkerController::Msg_Shutdown", OTHER); IPC::Message::seqno_t seqno__ = 0; if (ChannelSend(std::move(msg__), (&(seqno__)))) { mAsyncCallbacks.AddCallback(seqno__, PRemoteWorkerController::Reply_Shutdown__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable { auto maybe__aOk = IPC::ReadParam(aReader); if (!maybe__aOk) { (aReader)->FatalError("Error deserializing 'bool'"); return MsgValueError; } auto& aOk = *maybe__aOk; // Sentinel = 'aOk' if ((!((aReader)->ReadSentinel(36634908)))) { mozilla::ipc::SentinelReadError("Error deserializing 'bool'"); return MsgValueError; } aReader->EndRead(); resolve(std::move(aOk)); return MsgProcessed; }, std::move(aReject)); } else { aReject(::mozilla::ipc::ResponseRejectReason::SendError); } return; } auto PRemoteWorkerControllerChild::SendShutdown() -> RefPtr { RefPtr::Private> promise__ = new MozPromise::Private(__func__); promise__->UseDirectTaskDispatch(__func__); SendShutdown([promise__](bool&& aValue) { promise__->Resolve(std::move(aValue), __func__); }, [promise__](ResponseRejectReason&& aReason) { promise__->Reject(std::move(aReason), __func__); }); return promise__; } auto PRemoteWorkerControllerChild::SendExecServiceWorkerOp( const ServiceWorkerOpArgs& aArgs, mozilla::ipc::ResolveCallback&& aResolve, mozilla::ipc::RejectCallback&& aReject) -> void { UniquePtr msg__ = PRemoteWorkerController::Msg_ExecServiceWorkerOp(Id()); IPC::MessageWriter writer__{ (*(msg__)), this}; IPC::WriteParam((&(writer__)), aArgs); // Sentinel = 'aArgs' ((&(writer__)))->WriteSentinel(92602863); if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerController", mozilla::ipc::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PRemoteWorkerControllerChild", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Sending ", msg__->type(), mozilla::ipc::MessageDirection::eSending); } AUTO_PROFILER_LABEL("PRemoteWorkerController::Msg_ExecServiceWorkerOp", OTHER); IPC::Message::seqno_t seqno__ = 0; if (ChannelSend(std::move(msg__), (&(seqno__)))) { mAsyncCallbacks.AddCallback(seqno__, PRemoteWorkerController::Reply_ExecServiceWorkerOp__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable { auto maybe__aResult = IPC::ReadParam(aReader); if (!maybe__aResult) { (aReader)->FatalError("Error deserializing 'ServiceWorkerOpResult'"); return MsgValueError; } auto& aResult = *maybe__aResult; // Sentinel = 'aResult' if ((!((aReader)->ReadSentinel(185205473)))) { mozilla::ipc::SentinelReadError("Error deserializing 'ServiceWorkerOpResult'"); return MsgValueError; } aReader->EndRead(); resolve(std::move(aResult)); return MsgProcessed; }, std::move(aReject)); } else { aReject(::mozilla::ipc::ResponseRejectReason::SendError); } return; } auto PRemoteWorkerControllerChild::SendExecServiceWorkerOp(const ServiceWorkerOpArgs& aArgs) -> RefPtr { RefPtr::Private> promise__ = new MozPromise::Private(__func__); promise__->UseDirectTaskDispatch(__func__); SendExecServiceWorkerOp(std::forward(aArgs), [promise__](ServiceWorkerOpResult&& aValue) { promise__->Resolve(std::move(aValue), __func__); }, [promise__](ResponseRejectReason&& aReason) { promise__->Reject(std::move(aReason), __func__); }); return promise__; } auto PRemoteWorkerControllerChild::DeallocManagee( mozilla::ipc::ProtocolId aProtocolId, IProtocol* aListener) -> void { switch (aProtocolId) { case PFetchEventOpMsgStart: static_cast<::mozilla::dom::RemoteWorkerControllerChild*>(this)->DeallocPFetchEventOpChild(static_cast(aListener)); return; default: FatalError("unreached"); return; } } auto PRemoteWorkerControllerChild::OnMessageReceived(const Message& msg__) -> PRemoteWorkerControllerChild::Result { if (!CanSend()) { if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerController", mozilla::ipc::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PRemoteWorkerControllerChild", 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 PRemoteWorkerController::Msg_CreationFailed__ID: { if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerController", mozilla::ipc::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PRemoteWorkerControllerChild", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Received ", (&(msg__))->type(), mozilla::ipc::MessageDirection::eReceiving); } AUTO_PROFILER_LABEL("PRemoteWorkerController::Msg_CreationFailed", OTHER); mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::dom::RemoteWorkerControllerChild*>(this))->RecvCreationFailed(); if ((!(__ok))) { mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!"); // Error handled in mozilla::ipc::IPCResult return MsgProcessingError; } return MsgProcessed; } case PRemoteWorkerController::Msg_CreationSucceeded__ID: { if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerController", mozilla::ipc::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PRemoteWorkerControllerChild", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Received ", (&(msg__))->type(), mozilla::ipc::MessageDirection::eReceiving); } AUTO_PROFILER_LABEL("PRemoteWorkerController::Msg_CreationSucceeded", OTHER); mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::dom::RemoteWorkerControllerChild*>(this))->RecvCreationSucceeded(); if ((!(__ok))) { mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!"); // Error handled in mozilla::ipc::IPCResult return MsgProcessingError; } return MsgProcessed; } case PRemoteWorkerController::Msg_ErrorReceived__ID: { if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerController", mozilla::ipc::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PRemoteWorkerControllerChild", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Received ", (&(msg__))->type(), mozilla::ipc::MessageDirection::eReceiving); } AUTO_PROFILER_LABEL("PRemoteWorkerController::Msg_ErrorReceived", OTHER); IPC::MessageReader reader__{ msg__, this}; auto maybe__aError = IPC::ReadParam((&(reader__))); if (!maybe__aError) { FatalError("Error deserializing 'ErrorValue'"); return MsgValueError; } auto& aError = *maybe__aError; // Sentinel = 'aError' if ((!(((&(reader__)))->ReadSentinel(135463532)))) { mozilla::ipc::SentinelReadError("Error deserializing 'ErrorValue'"); return MsgValueError; } reader__.EndRead(); mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::dom::RemoteWorkerControllerChild*>(this))->RecvErrorReceived(std::move(aError)); if ((!(__ok))) { mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!"); // Error handled in mozilla::ipc::IPCResult return MsgProcessingError; } return MsgProcessed; } case PRemoteWorkerController::Msg_Terminated__ID: { if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerController", mozilla::ipc::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PRemoteWorkerControllerChild", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Received ", (&(msg__))->type(), mozilla::ipc::MessageDirection::eReceiving); } AUTO_PROFILER_LABEL("PRemoteWorkerController::Msg_Terminated", OTHER); mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::dom::RemoteWorkerControllerChild*>(this))->RecvTerminated(); if ((!(__ok))) { mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!"); // Error handled in mozilla::ipc::IPCResult return MsgProcessingError; } return MsgProcessed; } case PRemoteWorkerController::Msg_SetServiceWorkerSkipWaitingFlag__ID: { if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerController", mozilla::ipc::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PRemoteWorkerControllerChild", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Received ", (&(msg__))->type(), mozilla::ipc::MessageDirection::eReceiving); } AUTO_PROFILER_LABEL("PRemoteWorkerController::Msg_SetServiceWorkerSkipWaitingFlag", OTHER); mozilla::ipc::ActorId id__ = Id(); UniquePtr reply__(PRemoteWorkerController::Reply_SetServiceWorkerSkipWaitingFlag(id__)); reply__->set_seqno(msg__.seqno()); RefPtr resolver__ = new mozilla::ipc::IPDLResolverInner(std::move(reply__), this); SetServiceWorkerSkipWaitingFlagResolver resolver = [resolver__ = std::move(resolver__)](const bool& aParam) { resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) { IPC::MessageWriter writer__(*reply__, self__); IPC::WriteParam((&(writer__)), aParam); // Sentinel = 'aOk' ((&(writer__)))->WriteSentinel(36634908); if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerController", mozilla::ipc::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PRemoteWorkerControllerChild", self__->ToplevelProtocol()->OtherPidMaybeInvalid(), "Sending reply ", reply__->type(), mozilla::ipc::MessageDirection::eSending); } }); }; mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::dom::RemoteWorkerControllerChild*>(this))->RecvSetServiceWorkerSkipWaitingFlag(std::move(resolver)); if ((!(__ok))) { mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!"); // Error handled in mozilla::ipc::IPCResult return MsgProcessingError; } return MsgProcessed; } case PRemoteWorkerController::Reply_PFetchEventOpConstructor__ID: { return MsgProcessed; } case PRemoteWorkerController::Reply___delete____ID: { return MsgProcessed; } case PRemoteWorkerController::Reply_Shutdown__ID: { if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerController", mozilla::ipc::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PRemoteWorkerControllerChild", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Received ", (&(msg__))->type(), mozilla::ipc::MessageDirection::eReceiving); } AUTO_PROFILER_LABEL("PRemoteWorkerController::Msg_Shutdown", OTHER); return mAsyncCallbacks.GotReply(this, msg__); } case PRemoteWorkerController::Reply_ExecServiceWorkerOp__ID: { if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerController", mozilla::ipc::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PRemoteWorkerControllerChild", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Received ", (&(msg__))->type(), mozilla::ipc::MessageDirection::eReceiving); } AUTO_PROFILER_LABEL("PRemoteWorkerController::Msg_ExecServiceWorkerOp", OTHER); return mAsyncCallbacks.GotReply(this, msg__); } default: return MsgNotKnown; } } auto PRemoteWorkerControllerChild::OnMessageReceived( const Message& msg__, UniquePtr& reply__) -> PRemoteWorkerControllerChild::Result { if (!CanSend()) { return MsgDropped; } return MsgNotKnown; } } // namespace dom } // namespace mozilla