// // Automatically generated by ipdlc. // Edit at your own risk // #include "mozilla/dom/cache/PBoundStorageKeyParent.h" #include "mozilla/ProfilerLabels.h" #include "mozilla/dom/DomSecurityIPCUtils.h" #include "mozilla/dom/cache/BoundStorageKeyParent.h" #include "mozilla/dom/cache/IPCUtils.h" #include "mozilla/ipc/IPCCore.h" #include "mozilla/dom/cache/PCacheParent.h" #include "mozilla/dom/cache/PCacheStorageParent.h" #include "mozilla/dom/cache/PCacheStreamControlParent.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 { namespace cache { auto PBoundStorageKeyParent::RecvPCacheStorageConstructor( PCacheStorageParent* actor, const Namespace& aNamespace, const PrincipalInfo& aPrincipalInfo) -> mozilla::ipc::IPCResult { return IPC_OK(); } auto PBoundStorageKeyParent::ProcessingError( Result aCode, const char* aReason) -> void { } auto PBoundStorageKeyParent::ShouldContinueFromReplyTimeout() -> bool { return true; } MOZ_IMPLICIT PBoundStorageKeyParent::PBoundStorageKeyParent() : mozilla::ipc::IToplevelProtocol("PBoundStorageKeyParent", kProtocolId, mozilla::ipc::ParentSide) { MOZ_COUNT_CTOR(PBoundStorageKeyParent); } PBoundStorageKeyParent::~PBoundStorageKeyParent() { MOZ_COUNT_DTOR(PBoundStorageKeyParent); } auto PBoundStorageKeyParent::ActorAlloc() -> void { MOZ_RELEASE_ASSERT(XRE_IsParentProcess(), "Invalid process for `PBoundStorageKeyParent'"); AddRef(); } auto PBoundStorageKeyParent::ActorDealloc() -> void { Release(); } auto PBoundStorageKeyParent::ManagedPCacheStorageParent(nsTArray& aArr) const -> void { mManagedPCacheStorageParent.ToArray(aArr); } auto PBoundStorageKeyParent::ManagedPCacheStorageParent() const -> const ManagedContainer& { return mManagedPCacheStorageParent; } auto PBoundStorageKeyParent::ManagedPCacheParent(nsTArray& aArr) const -> void { mManagedPCacheParent.ToArray(aArr); } auto PBoundStorageKeyParent::ManagedPCacheParent() const -> const ManagedContainer& { return mManagedPCacheParent; } auto PBoundStorageKeyParent::ManagedPCacheStreamControlParent(nsTArray& aArr) const -> void { mManagedPCacheStreamControlParent.ToArray(aArr); } auto PBoundStorageKeyParent::ManagedPCacheStreamControlParent() const -> const ManagedContainer& { return mManagedPCacheStreamControlParent; } auto PBoundStorageKeyParent::ManagedProtocolIds() const -> mozilla::Span { static constexpr ::mozilla::ipc::ProtocolId sIds[] = { PCacheStorageMsgStart, PCacheMsgStart, PCacheStreamControlMsgStart }; return sIds; } auto PBoundStorageKeyParent::GetManagedActors(mozilla::ipc::ProtocolId aProtocol) -> UntypedManagedContainer* { switch (aProtocol) { case PCacheStorageMsgStart: return (&(mManagedPCacheStorageParent)); case PCacheMsgStart: return (&(mManagedPCacheParent)); case PCacheStreamControlMsgStart: return (&(mManagedPCacheStreamControlParent)); default: return nullptr; } } auto PBoundStorageKeyParent::OpenPCacheStorageEndpoint(PCacheStorageParent* aActor) -> ManagedEndpoint { if (!aActor) { NS_WARNING("Cannot bind null PCacheStorageParent actor"); return ManagedEndpoint(); } if (!aActor->SetManagerAndRegister(this)) { NS_WARNING("Failed to bind PCacheStorageParent 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 PBoundStorageKeyParent::BindPCacheStorageEndpoint( ManagedEndpoint aEndpoint, PCacheStorageParent* aActor) -> bool { return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this); } auto PBoundStorageKeyParent::OpenPCacheEndpoint(PCacheParent* aActor) -> ManagedEndpoint { if (!aActor) { NS_WARNING("Cannot bind null PCacheParent actor"); return ManagedEndpoint(); } if (!aActor->SetManagerAndRegister(this)) { NS_WARNING("Failed to bind PCacheParent 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 PBoundStorageKeyParent::BindPCacheEndpoint( ManagedEndpoint aEndpoint, PCacheParent* aActor) -> bool { return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this); } auto PBoundStorageKeyParent::OpenPCacheStreamControlEndpoint(PCacheStreamControlParent* aActor) -> ManagedEndpoint { if (!aActor) { NS_WARNING("Cannot bind null PCacheStreamControlParent actor"); return ManagedEndpoint(); } if (!aActor->SetManagerAndRegister(this)) { NS_WARNING("Failed to bind PCacheStreamControlParent 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 PBoundStorageKeyParent::BindPCacheStreamControlEndpoint( ManagedEndpoint aEndpoint, PCacheStreamControlParent* aActor) -> bool { return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this); } auto PBoundStorageKeyParent::SendPCacheConstructor(PCacheParent* actor) -> PCacheParent* { if (!actor) { NS_WARNING("Cannot bind null PCacheParent actor"); return nullptr; } if (!actor->SetManagerAndRegister(this)) { NS_WARNING("Failed to bind PCacheParent actor"); return nullptr; } // Build our constructor message. UniquePtr msg__ = PBoundStorageKey::Msg_PCacheConstructor(MSG_ROUTING_CONTROL); IPC::MessageWriter writer__{ (*(msg__)), this}; IPC::WriteParam((&(writer__)), (actor)->Id()); // Sentinel = 'actorid' ((&(writer__)))->WriteSentinel(193725159); // 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("PBoundStorageKey", mozilla::ipc::ParentSide)) { mozilla::ipc::LogMessageForProtocol( "PBoundStorageKeyParent", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Sending ", msg__->type(), mozilla::ipc::MessageDirection::eSending); } AUTO_PROFILER_LABEL("PBoundStorageKey::Msg_PCacheConstructor", 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 PCacheParent constructor"); actor->ActorDisconnected(FailedConstructor); return nullptr; } return actor; } auto PBoundStorageKeyParent::SendPCacheStreamControlConstructor(PCacheStreamControlParent* actor) -> PCacheStreamControlParent* { if (!actor) { NS_WARNING("Cannot bind null PCacheStreamControlParent actor"); return nullptr; } if (!actor->SetManagerAndRegister(this)) { NS_WARNING("Failed to bind PCacheStreamControlParent actor"); return nullptr; } // Build our constructor message. UniquePtr msg__ = PBoundStorageKey::Msg_PCacheStreamControlConstructor(MSG_ROUTING_CONTROL); IPC::MessageWriter writer__{ (*(msg__)), this}; IPC::WriteParam((&(writer__)), (actor)->Id()); // Sentinel = 'actorid' ((&(writer__)))->WriteSentinel(193725159); // 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("PBoundStorageKey", mozilla::ipc::ParentSide)) { mozilla::ipc::LogMessageForProtocol( "PBoundStorageKeyParent", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Sending ", msg__->type(), mozilla::ipc::MessageDirection::eSending); } AUTO_PROFILER_LABEL("PBoundStorageKey::Msg_PCacheStreamControlConstructor", 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 PCacheStreamControlParent constructor"); actor->ActorDisconnected(FailedConstructor); return nullptr; } return actor; } auto PBoundStorageKeyParent::DeallocManagee( mozilla::ipc::ProtocolId aProtocolId, IProtocol* aListener) -> void { switch (aProtocolId) { default: FatalError("unreached"); return; } } auto PBoundStorageKeyParent::OnMessageReceived(const Message& msg__) -> PBoundStorageKeyParent::Result { if (!CanSend()) { if (mozilla::ipc::LoggingEnabledFor("PBoundStorageKey", mozilla::ipc::ParentSide)) { mozilla::ipc::LogMessageForProtocol( "PBoundStorageKeyParent", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Ignored message for dead actor", (&(msg__))->type(), mozilla::ipc::MessageDirection::eSending); } return MsgProcessed; } IPC::Message::routeid_t route__ = msg__.routing_id(); if (MSG_ROUTING_CONTROL != route__) { IProtocol* routed__ = Lookup(route__); if (!routed__ || !routed__->GetLifecycleProxy()) { if (mozilla::ipc::LoggingEnabledFor("PBoundStorageKey", mozilla::ipc::ParentSide)) { mozilla::ipc::LogMessageForProtocol( "PBoundStorageKeyParent", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Ignored message for dead actor", (&(msg__))->type(), mozilla::ipc::MessageDirection::eSending); } return MsgProcessed; } RefPtr proxy__ = routed__->GetLifecycleProxy(); return proxy__->Get()->OnMessageReceived(msg__); } switch (msg__.type()) { case PBoundStorageKey::Msg_PCacheStorageConstructor__ID: { if (mozilla::ipc::LoggingEnabledFor("PBoundStorageKey", mozilla::ipc::ParentSide)) { mozilla::ipc::LogMessageForProtocol( "PBoundStorageKeyParent", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Received ", (&(msg__))->type(), mozilla::ipc::MessageDirection::eReceiving); } AUTO_PROFILER_LABEL("PBoundStorageKey::Msg_PCacheStorageConstructor", OTHER); IPC::MessageReader reader__{ msg__, this}; auto maybe__actorid__ = IPC::ReadParam((&(reader__))); if (!maybe__actorid__) { FatalError("Error deserializing 'mozilla::ipc::ActorId'"); return MsgValueError; } auto& actorid__ = *maybe__actorid__; // Sentinel = 'actorid' if ((!(((&(reader__)))->ReadSentinel(193725159)))) { mozilla::ipc::SentinelReadError("Error deserializing 'mozilla::ipc::ActorId'"); return MsgValueError; } auto maybe__aNamespace = IPC::ReadParam((&(reader__))); if (!maybe__aNamespace) { FatalError("Error deserializing 'Namespace'"); return MsgValueError; } auto& aNamespace = *maybe__aNamespace; // Sentinel = 'aNamespace' if ((!(((&(reader__)))->ReadSentinel(356516847)))) { mozilla::ipc::SentinelReadError("Error deserializing 'Namespace'"); return MsgValueError; } auto maybe__aPrincipalInfo = IPC::ReadParam((&(reader__))); if (!maybe__aPrincipalInfo) { FatalError("Error deserializing 'PrincipalInfo'"); return MsgValueError; } auto& aPrincipalInfo = *maybe__aPrincipalInfo; // Sentinel = 'aPrincipalInfo' if ((!(((&(reader__)))->ReadSentinel(695272848)))) { mozilla::ipc::SentinelReadError("Error deserializing 'PrincipalInfo'"); return MsgValueError; } reader__.EndRead(); // Ensure the ID which was sent to us is valid, and reserve a spot // in the table for the new actor before we bother to alloc it. if (!ToplevelProtocol()->TryReserve(actorid__)) { NS_WARNING("Failed to reserve ActorId for constructor"); return MsgValueError; } RefPtr actor = (static_cast<::mozilla::dom::cache::BoundStorageKeyParent*>(this))->AllocPCacheStorageParent(aNamespace, aPrincipalInfo); if (!actor) { NS_WARNING("Alloc function returned null"); // Clean up the reservation taken above if this fails, to avoid // leaving zombie entries in the map. ToplevelProtocol()->ClearReservation(actorid__); return MsgValueError; } // NOTE: SetManagerAndRegister unconditionally consumes the // reservation taken by TryReserve, so we don't need to clear it on // failure. if (!actor->SetManagerAndRegister(this, actorid__)) { NS_WARNING("Failed to set manager for constructor"); return MsgValueError; } mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::dom::cache::BoundStorageKeyParent*>(this))->RecvPCacheStorageConstructor(actor, std::move(aNamespace), std::move(aPrincipalInfo)); if ((!(__ok))) { mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!"); // Error handled in mozilla::ipc::IPCResult return MsgProcessingError; } return MsgProcessed; } case PBoundStorageKey::Reply_PCacheConstructor__ID: { return MsgProcessed; } case PBoundStorageKey::Reply_PCacheStreamControlConstructor__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 PBoundStorageKeyParent::OnMessageReceived( const Message& msg__, UniquePtr& reply__) -> PBoundStorageKeyParent::Result { if (!CanSend()) { return MsgDropped; } IPC::Message::routeid_t route__ = msg__.routing_id(); if (MSG_ROUTING_CONTROL != route__) { IProtocol* routed__ = Lookup(route__); if (!routed__ || !routed__->GetLifecycleProxy()) { return MsgDropped; } RefPtr proxy__ = routed__->GetLifecycleProxy(); return proxy__->Get()->OnMessageReceived(msg__, reply__); } MOZ_ASSERT_UNREACHABLE("message protocol not supported"); return MsgNotKnown; } } // namespace cache } // namespace dom } // namespace mozilla