// // Automatically generated by ipdlc. // Edit at your own risk // #include "mozilla/dom/cache/PBoundStorageKeyChild.h" #include "mozilla/ProfilerLabels.h" #include "mozilla/dom/DomSecurityIPCUtils.h" #include "mozilla/dom/cache/BoundStorageKeyChild.h" #include "mozilla/dom/cache/IPCUtils.h" #include "mozilla/ipc/IPCCore.h" #include "mozilla/dom/cache/PCacheChild.h" #include "mozilla/dom/cache/PCacheStorageChild.h" #include "mozilla/dom/cache/PCacheStreamControlChild.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 PBoundStorageKeyChild::RecvPCacheConstructor(PCacheChild* actor) -> mozilla::ipc::IPCResult { return IPC_OK(); } auto PBoundStorageKeyChild::RecvPCacheStreamControlConstructor(PCacheStreamControlChild* actor) -> mozilla::ipc::IPCResult { return IPC_OK(); } auto PBoundStorageKeyChild::ProcessingError( Result aCode, const char* aReason) -> void { } auto PBoundStorageKeyChild::ShouldContinueFromReplyTimeout() -> bool { return true; } MOZ_IMPLICIT PBoundStorageKeyChild::PBoundStorageKeyChild() : mozilla::ipc::IToplevelProtocol("PBoundStorageKeyChild", kProtocolId, mozilla::ipc::ChildSide) { MOZ_COUNT_CTOR(PBoundStorageKeyChild); } PBoundStorageKeyChild::~PBoundStorageKeyChild() { MOZ_COUNT_DTOR(PBoundStorageKeyChild); } auto PBoundStorageKeyChild::ActorAlloc() -> void { MOZ_RELEASE_ASSERT(XRE_IsParentProcess() || XRE_IsContentProcess(), "Invalid process for `PBoundStorageKeyChild'"); AddRef(); } auto PBoundStorageKeyChild::ActorDealloc() -> void { Release(); } auto PBoundStorageKeyChild::ManagedPCacheStorageChild(nsTArray& aArr) const -> void { mManagedPCacheStorageChild.ToArray(aArr); } auto PBoundStorageKeyChild::ManagedPCacheStorageChild() const -> const ManagedContainer& { return mManagedPCacheStorageChild; } auto PBoundStorageKeyChild::ManagedPCacheChild(nsTArray& aArr) const -> void { mManagedPCacheChild.ToArray(aArr); } auto PBoundStorageKeyChild::ManagedPCacheChild() const -> const ManagedContainer& { return mManagedPCacheChild; } auto PBoundStorageKeyChild::ManagedPCacheStreamControlChild(nsTArray& aArr) const -> void { mManagedPCacheStreamControlChild.ToArray(aArr); } auto PBoundStorageKeyChild::ManagedPCacheStreamControlChild() const -> const ManagedContainer& { return mManagedPCacheStreamControlChild; } auto PBoundStorageKeyChild::ManagedProtocolIds() const -> mozilla::Span { static constexpr ::mozilla::ipc::ProtocolId sIds[] = { PCacheStorageMsgStart, PCacheMsgStart, PCacheStreamControlMsgStart }; return sIds; } auto PBoundStorageKeyChild::GetManagedActors(mozilla::ipc::ProtocolId aProtocol) -> UntypedManagedContainer* { switch (aProtocol) { case PCacheStorageMsgStart: return (&(mManagedPCacheStorageChild)); case PCacheMsgStart: return (&(mManagedPCacheChild)); case PCacheStreamControlMsgStart: return (&(mManagedPCacheStreamControlChild)); default: return nullptr; } } auto PBoundStorageKeyChild::OpenPCacheStorageEndpoint(PCacheStorageChild* aActor) -> ManagedEndpoint { if (!aActor) { NS_WARNING("Cannot bind null PCacheStorageChild actor"); return ManagedEndpoint(); } if (!aActor->SetManagerAndRegister(this)) { NS_WARNING("Failed to bind PCacheStorageChild 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 PBoundStorageKeyChild::BindPCacheStorageEndpoint( ManagedEndpoint aEndpoint, PCacheStorageChild* aActor) -> bool { return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this); } auto PBoundStorageKeyChild::OpenPCacheEndpoint(PCacheChild* aActor) -> ManagedEndpoint { if (!aActor) { NS_WARNING("Cannot bind null PCacheChild actor"); return ManagedEndpoint(); } if (!aActor->SetManagerAndRegister(this)) { NS_WARNING("Failed to bind PCacheChild 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 PBoundStorageKeyChild::BindPCacheEndpoint( ManagedEndpoint aEndpoint, PCacheChild* aActor) -> bool { return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this); } auto PBoundStorageKeyChild::OpenPCacheStreamControlEndpoint(PCacheStreamControlChild* aActor) -> ManagedEndpoint { if (!aActor) { NS_WARNING("Cannot bind null PCacheStreamControlChild actor"); return ManagedEndpoint(); } if (!aActor->SetManagerAndRegister(this)) { NS_WARNING("Failed to bind PCacheStreamControlChild 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 PBoundStorageKeyChild::BindPCacheStreamControlEndpoint( ManagedEndpoint aEndpoint, PCacheStreamControlChild* aActor) -> bool { return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this); } auto PBoundStorageKeyChild::SendPCacheStorageConstructor( PCacheStorageChild* actor, const Namespace& aNamespace, const PrincipalInfo& aPrincipalInfo) -> PCacheStorageChild* { if (!actor) { NS_WARNING("Cannot bind null PCacheStorageChild actor"); return nullptr; } if (!actor->SetManagerAndRegister(this)) { NS_WARNING("Failed to bind PCacheStorageChild actor"); return nullptr; } // Build our constructor message. UniquePtr msg__ = PBoundStorageKey::Msg_PCacheStorageConstructor(MSG_ROUTING_CONTROL); IPC::MessageWriter writer__{ (*(msg__)), this}; IPC::WriteParam((&(writer__)), (actor)->Id()); // Sentinel = 'actorid' ((&(writer__)))->WriteSentinel(193725159); IPC::WriteParam((&(writer__)), aNamespace); // Sentinel = 'aNamespace' ((&(writer__)))->WriteSentinel(356516847); IPC::WriteParam((&(writer__)), aPrincipalInfo); // Sentinel = 'aPrincipalInfo' ((&(writer__)))->WriteSentinel(695272848); // 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::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PBoundStorageKeyChild", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Sending ", msg__->type(), mozilla::ipc::MessageDirection::eSending); } AUTO_PROFILER_LABEL("PBoundStorageKey::Msg_PCacheStorageConstructor", 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 PCacheStorageChild constructor"); actor->ActorDisconnected(FailedConstructor); return nullptr; } return actor; } auto PBoundStorageKeyChild::DeallocManagee( mozilla::ipc::ProtocolId aProtocolId, IProtocol* aListener) -> void { switch (aProtocolId) { default: FatalError("unreached"); return; } } auto PBoundStorageKeyChild::OnMessageReceived(const Message& msg__) -> PBoundStorageKeyChild::Result { if (!CanSend()) { if (mozilla::ipc::LoggingEnabledFor("PBoundStorageKey", mozilla::ipc::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PBoundStorageKeyChild", 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::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PBoundStorageKeyChild", 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::Reply_PCacheStorageConstructor__ID: { return MsgProcessed; } case PBoundStorageKey::Msg_PCacheConstructor__ID: { if (mozilla::ipc::LoggingEnabledFor("PBoundStorageKey", mozilla::ipc::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PBoundStorageKeyChild", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Received ", (&(msg__))->type(), mozilla::ipc::MessageDirection::eReceiving); } AUTO_PROFILER_LABEL("PBoundStorageKey::Msg_PCacheConstructor", 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; } 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::BoundStorageKeyChild*>(this))->AllocPCacheChild(); 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::BoundStorageKeyChild*>(this))->RecvPCacheConstructor(actor); if ((!(__ok))) { mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!"); // Error handled in mozilla::ipc::IPCResult return MsgProcessingError; } return MsgProcessed; } case PBoundStorageKey::Msg_PCacheStreamControlConstructor__ID: { if (mozilla::ipc::LoggingEnabledFor("PBoundStorageKey", mozilla::ipc::ChildSide)) { mozilla::ipc::LogMessageForProtocol( "PBoundStorageKeyChild", this->ToplevelProtocol()->OtherPidMaybeInvalid(), "Received ", (&(msg__))->type(), mozilla::ipc::MessageDirection::eReceiving); } AUTO_PROFILER_LABEL("PBoundStorageKey::Msg_PCacheStreamControlConstructor", 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; } 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::BoundStorageKeyChild*>(this))->AllocPCacheStreamControlChild(); 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::BoundStorageKeyChild*>(this))->RecvPCacheStreamControlConstructor(actor); 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 PBoundStorageKeyChild::OnMessageReceived( const Message& msg__, UniquePtr& reply__) -> PBoundStorageKeyChild::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