//
// Automatically generated by ipdlc.
// Edit at your own risk
//


#include "mozilla/dom/PHandlerServiceChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ProfilerMarkers.h"

#include "mozilla/dom/PContentChild.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 PHandlerServiceChild::PHandlerServiceChild() :
    mozilla::ipc::IRefCountedProtocol(kProtocolId, mozilla::ipc::ChildSide)
{
    MOZ_COUNT_CTOR(PHandlerServiceChild);
}

PHandlerServiceChild::~PHandlerServiceChild()
{
    MOZ_COUNT_DTOR(PHandlerServiceChild);
}

auto PHandlerServiceChild::ActorAlloc() -> void
{
    AddRef();
}

auto PHandlerServiceChild::ActorDealloc() -> void
{
    Release();
}

auto PHandlerServiceChild::OtherPid() const -> ::base::ProcessId
{
    ::base::ProcessId pid =
        ::mozilla::ipc::IProtocol::ToplevelProtocol()->OtherPidMaybeInvalid();
    MOZ_RELEASE_ASSERT(pid != ::base::kInvalidProcessId);
    return pid;
}

auto PHandlerServiceChild::OtherChildID() const -> ::GeckoChildID
{
    ::GeckoChildID childID =
        ::mozilla::ipc::IProtocol::ToplevelProtocol()->OtherChildIDMaybeInvalid();
    MOZ_RELEASE_ASSERT(childID != -1);
    return childID;
}

auto PHandlerServiceChild::OtherEndpointProcInfo() const -> ::mozilla::ipc::EndpointProcInfo
{
    return ::mozilla::ipc::EndpointProcInfo{OtherPid(), OtherChildID()};
}

auto PHandlerServiceChild::Manager() const -> PContentChild*
{
    return static_cast<PContentChild*>(IProtocol::Manager());
}

auto PHandlerServiceChild::ManagedProtocolIds() const -> mozilla::Span<mozilla::ipc::ProtocolId const>
{
    return {};
}

auto PHandlerServiceChild::GetManagedActors(mozilla::ipc::ProtocolId aProtocol) -> UntypedManagedContainer*
{
    switch (aProtocol) {
    default:
        return nullptr;
    }
}

auto PHandlerServiceChild::SendFillHandlerInfo(
        const HandlerInfo& aHandlerInfoData,
        const nsACString& aOverrideType,
        HandlerInfo* handlerInfoData) -> bool
{
    UniquePtr<IPC::Message> msg__ = PHandlerService::Msg_FillHandlerInfo(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aHandlerInfoData);
    // Sentinel = 'aHandlerInfoData'
    ((&(writer__)))->WriteSentinel(869860902);
    IPC::WriteParam((&(writer__)), aOverrideType);
    // Sentinel = 'aOverrideType'
    ((&(writer__)))->WriteSentinel(611583300);

    UniquePtr<Message> reply__;

    if (mozilla::ipc::LoggingEnabledFor("PHandlerService", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PHandlerServiceChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PHandlerService::Msg_FillHandlerInfo", OTHER);

    bool sendok__ = false;
    {
        AUTO_PROFILER_MARKER("PHandlerService::Msg_FillHandlerInfo", IPC);
        sendok__ = ChannelSend(std::move(msg__), (&(reply__)));
    }
    if ((!(sendok__))) {
        return false;
    }

    if (mozilla::ipc::LoggingEnabledFor("PHandlerService", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PHandlerServiceChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Received reply ",
            reply__->type(),
            mozilla::ipc::MessageDirection::eReceiving);
    }

    IPC::MessageReader reader__{
            (*(reply__)),
            this};

    auto maybe__handlerInfoData__reply = IPC::ReadParam<HandlerInfo>((&(reader__)));
    if (!maybe__handlerInfoData__reply) {
        FatalError("Error deserializing 'HandlerInfo'");
        return false;

    }
    auto& handlerInfoData__reply = *maybe__handlerInfoData__reply;
    // Sentinel = 'handlerInfoData'
    if ((!(((&(reader__)))->ReadSentinel(799540709)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'HandlerInfo'");
        return false;
    }
    (*(handlerInfoData)) = std::move(handlerInfoData__reply);
    reader__.EndRead();

    return true;
}

auto PHandlerServiceChild::SendExistsForProtocolOS(
        const nsACString& aProtocolScheme,
        bool* exists) -> bool
{
    UniquePtr<IPC::Message> msg__ = PHandlerService::Msg_ExistsForProtocolOS(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aProtocolScheme);
    // Sentinel = 'aProtocolScheme'
    ((&(writer__)))->WriteSentinel(809764361);

    UniquePtr<Message> reply__;

    if (mozilla::ipc::LoggingEnabledFor("PHandlerService", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PHandlerServiceChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PHandlerService::Msg_ExistsForProtocolOS", OTHER);

    bool sendok__ = false;
    {
        AUTO_PROFILER_MARKER("PHandlerService::Msg_ExistsForProtocolOS", IPC);
        sendok__ = ChannelSend(std::move(msg__), (&(reply__)));
    }
    if ((!(sendok__))) {
        return false;
    }

    if (mozilla::ipc::LoggingEnabledFor("PHandlerService", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PHandlerServiceChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Received reply ",
            reply__->type(),
            mozilla::ipc::MessageDirection::eReceiving);
    }

    IPC::MessageReader reader__{
            (*(reply__)),
            this};

    auto maybe__exists__reply = IPC::ReadParam<bool>((&(reader__)));
    if (!maybe__exists__reply) {
        FatalError("Error deserializing 'bool'");
        return false;

    }
    auto& exists__reply = *maybe__exists__reply;
    // Sentinel = 'exists'
    if ((!(((&(reader__)))->ReadSentinel(152306337)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
        return false;
    }
    (*(exists)) = std::move(exists__reply);
    reader__.EndRead();

    return true;
}

auto PHandlerServiceChild::SendExistsForProtocol(
        const nsACString& aProtocolScheme,
        bool* exists) -> bool
{
    UniquePtr<IPC::Message> msg__ = PHandlerService::Msg_ExistsForProtocol(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aProtocolScheme);
    // Sentinel = 'aProtocolScheme'
    ((&(writer__)))->WriteSentinel(809764361);

    UniquePtr<Message> reply__;

    if (mozilla::ipc::LoggingEnabledFor("PHandlerService", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PHandlerServiceChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PHandlerService::Msg_ExistsForProtocol", OTHER);

    bool sendok__ = false;
    {
        AUTO_PROFILER_MARKER("PHandlerService::Msg_ExistsForProtocol", IPC);
        sendok__ = ChannelSend(std::move(msg__), (&(reply__)));
    }
    if ((!(sendok__))) {
        return false;
    }

    if (mozilla::ipc::LoggingEnabledFor("PHandlerService", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PHandlerServiceChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Received reply ",
            reply__->type(),
            mozilla::ipc::MessageDirection::eReceiving);
    }

    IPC::MessageReader reader__{
            (*(reply__)),
            this};

    auto maybe__exists__reply = IPC::ReadParam<bool>((&(reader__)));
    if (!maybe__exists__reply) {
        FatalError("Error deserializing 'bool'");
        return false;

    }
    auto& exists__reply = *maybe__exists__reply;
    // Sentinel = 'exists'
    if ((!(((&(reader__)))->ReadSentinel(152306337)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
        return false;
    }
    (*(exists)) = std::move(exists__reply);
    reader__.EndRead();

    return true;
}

auto PHandlerServiceChild::SendExists(
        const HandlerInfo& aHandlerInfo,
        bool* exists) -> bool
{
    UniquePtr<IPC::Message> msg__ = PHandlerService::Msg_Exists(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aHandlerInfo);
    // Sentinel = 'aHandlerInfo'
    ((&(writer__)))->WriteSentinel(497878188);

    UniquePtr<Message> reply__;

    if (mozilla::ipc::LoggingEnabledFor("PHandlerService", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PHandlerServiceChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PHandlerService::Msg_Exists", OTHER);

    bool sendok__ = false;
    {
        AUTO_PROFILER_MARKER("PHandlerService::Msg_Exists", IPC);
        sendok__ = ChannelSend(std::move(msg__), (&(reply__)));
    }
    if ((!(sendok__))) {
        return false;
    }

    if (mozilla::ipc::LoggingEnabledFor("PHandlerService", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PHandlerServiceChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Received reply ",
            reply__->type(),
            mozilla::ipc::MessageDirection::eReceiving);
    }

    IPC::MessageReader reader__{
            (*(reply__)),
            this};

    auto maybe__exists__reply = IPC::ReadParam<bool>((&(reader__)));
    if (!maybe__exists__reply) {
        FatalError("Error deserializing 'bool'");
        return false;

    }
    auto& exists__reply = *maybe__exists__reply;
    // Sentinel = 'exists'
    if ((!(((&(reader__)))->ReadSentinel(152306337)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
        return false;
    }
    (*(exists)) = std::move(exists__reply);
    reader__.EndRead();

    return true;
}

auto PHandlerServiceChild::SendGetTypeFromExtension(
        const nsACString& aFileExtension,
        nsCString* type) -> bool
{
    UniquePtr<IPC::Message> msg__ = PHandlerService::Msg_GetTypeFromExtension(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aFileExtension);
    // Sentinel = 'aFileExtension'
    ((&(writer__)))->WriteSentinel(681313695);

    UniquePtr<Message> reply__;

    if (mozilla::ipc::LoggingEnabledFor("PHandlerService", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PHandlerServiceChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PHandlerService::Msg_GetTypeFromExtension", OTHER);

    bool sendok__ = false;
    {
        AUTO_PROFILER_MARKER("PHandlerService::Msg_GetTypeFromExtension", IPC);
        sendok__ = ChannelSend(std::move(msg__), (&(reply__)));
    }
    if ((!(sendok__))) {
        return false;
    }

    if (mozilla::ipc::LoggingEnabledFor("PHandlerService", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PHandlerServiceChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Received reply ",
            reply__->type(),
            mozilla::ipc::MessageDirection::eReceiving);
    }

    IPC::MessageReader reader__{
            (*(reply__)),
            this};

    auto maybe__type__reply = IPC::ReadParam<nsCString>((&(reader__)));
    if (!maybe__type__reply) {
        FatalError("Error deserializing 'nsCString'");
        return false;

    }
    auto& type__reply = *maybe__type__reply;
    // Sentinel = 'type'
    if ((!(((&(reader__)))->ReadSentinel(75760067)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
        return false;
    }
    (*(type)) = std::move(type__reply);
    reader__.EndRead();

    return true;
}

auto PHandlerServiceChild::SendGetMIMEInfoFromOS(
        const nsACString& aMIMEType,
        const nsACString& aExtension,
        nsresult* rv,
        HandlerInfo* handlerInfoData,
        bool* found) -> bool
{
    UniquePtr<IPC::Message> msg__ = PHandlerService::Msg_GetMIMEInfoFromOS(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aMIMEType);
    // Sentinel = 'aMIMEType'
    ((&(writer__)))->WriteSentinel(251659052);
    IPC::WriteParam((&(writer__)), aExtension);
    // Sentinel = 'aExtension'
    ((&(writer__)))->WriteSentinel(369361951);

    UniquePtr<Message> reply__;

    if (mozilla::ipc::LoggingEnabledFor("PHandlerService", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PHandlerServiceChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PHandlerService::Msg_GetMIMEInfoFromOS", OTHER);

    bool sendok__ = false;
    {
        AUTO_PROFILER_MARKER("PHandlerService::Msg_GetMIMEInfoFromOS", IPC);
        sendok__ = ChannelSend(std::move(msg__), (&(reply__)));
    }
    if ((!(sendok__))) {
        return false;
    }

    if (mozilla::ipc::LoggingEnabledFor("PHandlerService", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PHandlerServiceChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Received reply ",
            reply__->type(),
            mozilla::ipc::MessageDirection::eReceiving);
    }

    IPC::MessageReader reader__{
            (*(reply__)),
            this};

    auto maybe__rv__reply = IPC::ReadParam<nsresult>((&(reader__)));
    if (!maybe__rv__reply) {
        FatalError("Error deserializing 'nsresult'");
        return false;

    }
    auto& rv__reply = *maybe__rv__reply;
    // Sentinel = 'rv'
    if ((!(((&(reader__)))->ReadSentinel(22806761)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'nsresult'");
        return false;
    }
    auto maybe__handlerInfoData__reply = IPC::ReadParam<HandlerInfo>((&(reader__)));
    if (!maybe__handlerInfoData__reply) {
        FatalError("Error deserializing 'HandlerInfo'");
        return false;

    }
    auto& handlerInfoData__reply = *maybe__handlerInfoData__reply;
    // Sentinel = 'handlerInfoData'
    if ((!(((&(reader__)))->ReadSentinel(799540709)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'HandlerInfo'");
        return false;
    }
    auto maybe__found__reply = IPC::ReadParam<bool>((&(reader__)));
    if (!maybe__found__reply) {
        FatalError("Error deserializing 'bool'");
        return false;

    }
    auto& found__reply = *maybe__found__reply;
    // Sentinel = 'found'
    if ((!(((&(reader__)))->ReadSentinel(106824221)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
        return false;
    }
    (*(rv)) = std::move(rv__reply);
    (*(handlerInfoData)) = std::move(handlerInfoData__reply);
    (*(found)) = std::move(found__reply);
    reader__.EndRead();

    return true;
}

auto PHandlerServiceChild::SendGetApplicationDescription(
        const nsACString& aScheme,
        nsresult* rv,
        nsString* description) -> bool
{
    UniquePtr<IPC::Message> msg__ = PHandlerService::Msg_GetApplicationDescription(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aScheme);
    // Sentinel = 'aScheme'
    ((&(writer__)))->WriteSentinel(178062007);

    UniquePtr<Message> reply__;

    if (mozilla::ipc::LoggingEnabledFor("PHandlerService", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PHandlerServiceChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PHandlerService::Msg_GetApplicationDescription", OTHER);

    bool sendok__ = false;
    {
        AUTO_PROFILER_MARKER("PHandlerService::Msg_GetApplicationDescription", IPC);
        sendok__ = ChannelSend(std::move(msg__), (&(reply__)));
    }
    if ((!(sendok__))) {
        return false;
    }

    if (mozilla::ipc::LoggingEnabledFor("PHandlerService", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PHandlerServiceChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Received reply ",
            reply__->type(),
            mozilla::ipc::MessageDirection::eReceiving);
    }

    IPC::MessageReader reader__{
            (*(reply__)),
            this};

    auto maybe__rv__reply = IPC::ReadParam<nsresult>((&(reader__)));
    if (!maybe__rv__reply) {
        FatalError("Error deserializing 'nsresult'");
        return false;

    }
    auto& rv__reply = *maybe__rv__reply;
    // Sentinel = 'rv'
    if ((!(((&(reader__)))->ReadSentinel(22806761)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'nsresult'");
        return false;
    }
    auto maybe__description__reply = IPC::ReadParam<nsString>((&(reader__)));
    if (!maybe__description__reply) {
        FatalError("Error deserializing 'nsString'");
        return false;

    }
    auto& description__reply = *maybe__description__reply;
    // Sentinel = 'description'
    if ((!(((&(reader__)))->ReadSentinel(461833381)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
        return false;
    }
    (*(rv)) = std::move(rv__reply);
    (*(description)) = std::move(description__reply);
    reader__.EndRead();

    return true;
}

auto PHandlerServiceChild::Send__delete__(PHandlerServiceChild* actor) -> bool
{
    if (!actor || !actor->CanSend()) {
        NS_WARNING("Attempt to __delete__ missing or closed actor");
        return false;
    }
    UniquePtr<IPC::Message> msg__ = PHandlerService::Msg___delete__((actor)->Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            actor};


    if (mozilla::ipc::LoggingEnabledFor("PHandlerService", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PHandlerServiceChild",
            actor->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PHandlerService::Msg___delete__", OTHER);

    bool sendok__ = (actor)->ChannelSend(std::move(msg__));

    actor->ActorDisconnected(Deletion);
    return sendok__;
}

auto PHandlerServiceChild::DeallocManagee(
        mozilla::ipc::ProtocolId aProtocolId,
        IProtocol* aListener) -> void
{
    FatalError("unreached");
    return;
}

auto PHandlerServiceChild::OnMessageReceived(const Message& msg__) -> PHandlerServiceChild::Result
{
    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 PHandlerService::Reply___delete____ID:
        {
            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}

auto PHandlerServiceChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PHandlerServiceChild::Result
{
    return MsgNotKnown;
}



} // namespace dom
} // namespace mozilla
namespace IPC {
auto ParamTraits<::mozilla::dom::PHandlerServiceChild*>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, static_cast<mozilla::ipc::IProtocol*>(aVar));
    // Sentinel = 'PHandlerService'
    (aWriter)->WriteSentinel(763364832);
}

auto ParamTraits<::mozilla::dom::PHandlerServiceChild*>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    auto maybe__actor = IPC::ReadParam<mozilla::ipc::IProtocol*>(aReader);
    if (!maybe__actor) {
        aReader->FatalError("Error deserializing managed PHandlerService actor");
        return {};

    }
    auto& actor = *maybe__actor;
    // Sentinel = 'PHandlerService'
    if ((!((aReader)->ReadSentinel(763364832)))) {
        mozilla::ipc::SentinelReadError("Error deserializing managed PHandlerService actor");
        return {};
    }

    if (actor && actor->GetProtocolId() != PHandlerServiceMsgStart) {
        aReader->FatalError("Unexpected actor type (expected PHandlerService)");

        return {};
    }
    return static_cast<::mozilla::dom::PHandlerServiceChild*>(actor);
}

} // namespace IPC
