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


#include "mozilla/dom/PPaymentRequestChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/dom/PaymentRequestChild.h"
#include "mozilla/dom/PermissionMessageUtils.h"
#include "nsIPrincipal.h"

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

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

auto PPaymentRequestChild::ActorAlloc() -> void
{
}

auto PPaymentRequestChild::ActorDealloc() -> void
{
    if (Manager()) {
        Manager()->DeallocManagee(kProtocolId, this);
    }
}

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

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

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

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

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

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

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


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

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

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

auto PPaymentRequestChild::SendRequestPayment(const IPCPaymentActionRequest& aAction) -> bool
{
    UniquePtr<IPC::Message> msg__ = PPaymentRequest::Msg_RequestPayment(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

    bool sendok__ = ChannelSend(std::move(msg__));
    return sendok__;
}

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

auto PPaymentRequestChild::OnMessageReceived(const Message& msg__) -> PPaymentRequestChild::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 PPaymentRequest::Reply___delete____ID:
        {
            return MsgProcessed;
        }
    case PPaymentRequest::Msg_RespondPayment__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PPaymentRequest", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PPaymentRequestChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PPaymentRequest::Msg_RespondPayment", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__aResponse = IPC::ReadParam<IPCPaymentActionResponse>((&(reader__)));
            if (!maybe__aResponse) {
                FatalError("Error deserializing 'IPCPaymentActionResponse'");
                return MsgValueError;

            }
            auto& aResponse = *maybe__aResponse;
            // Sentinel = 'aResponse'
            if ((!(((&(reader__)))->ReadSentinel(301466545)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'IPCPaymentActionResponse'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<PaymentRequestChild*>(this))->RecvRespondPayment(std::move(aResponse));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PPaymentRequest::Msg_ChangeShippingAddress__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PPaymentRequest", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PPaymentRequestChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PPaymentRequest::Msg_ChangeShippingAddress", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__aRequestId = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__aRequestId) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& aRequestId = *maybe__aRequestId;
            // Sentinel = 'aRequestId'
            if ((!(((&(reader__)))->ReadSentinel(365560824)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__aAddress = IPC::ReadParam<IPCPaymentAddress>((&(reader__)));
            if (!maybe__aAddress) {
                FatalError("Error deserializing 'IPCPaymentAddress'");
                return MsgValueError;

            }
            auto& aAddress = *maybe__aAddress;
            // Sentinel = 'aAddress'
            if ((!(((&(reader__)))->ReadSentinel(225641256)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'IPCPaymentAddress'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<PaymentRequestChild*>(this))->RecvChangeShippingAddress(std::move(aRequestId), std::move(aAddress));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PPaymentRequest::Msg_ChangeShippingOption__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PPaymentRequest", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PPaymentRequestChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PPaymentRequest::Msg_ChangeShippingOption", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__aRequestId = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__aRequestId) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& aRequestId = *maybe__aRequestId;
            // Sentinel = 'aRequestId'
            if ((!(((&(reader__)))->ReadSentinel(365560824)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__aOption = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__aOption) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& aOption = *maybe__aOption;
            // Sentinel = 'aOption'
            if ((!(((&(reader__)))->ReadSentinel(185533147)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<PaymentRequestChild*>(this))->RecvChangeShippingOption(std::move(aRequestId), std::move(aOption));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PPaymentRequest::Msg_ChangePayerDetail__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PPaymentRequest", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PPaymentRequestChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PPaymentRequest::Msg_ChangePayerDetail", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__aRequestId = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__aRequestId) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& aRequestId = *maybe__aRequestId;
            // Sentinel = 'aRequestId'
            if ((!(((&(reader__)))->ReadSentinel(365560824)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__aPayerName = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__aPayerName) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& aPayerName = *maybe__aPayerName;
            // Sentinel = 'aPayerName'
            if ((!(((&(reader__)))->ReadSentinel(355271652)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__aPayerEmail = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__aPayerEmail) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& aPayerEmail = *maybe__aPayerEmail;
            // Sentinel = 'aPayerEmail'
            if ((!(((&(reader__)))->ReadSentinel(425985099)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__aPayerPhone = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__aPayerPhone) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& aPayerPhone = *maybe__aPayerPhone;
            // Sentinel = 'aPayerPhone'
            if ((!(((&(reader__)))->ReadSentinel(431227997)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<PaymentRequestChild*>(this))->RecvChangePayerDetail(std::move(aRequestId), std::move(aPayerName), std::move(aPayerEmail), std::move(aPayerPhone));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PPaymentRequest::Msg_ChangePaymentMethod__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PPaymentRequest", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PPaymentRequestChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PPaymentRequest::Msg_ChangePaymentMethod", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__aRequestId = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__aRequestId) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& aRequestId = *maybe__aRequestId;
            // Sentinel = 'aRequestId'
            if ((!(((&(reader__)))->ReadSentinel(365560824)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__aMethodName = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__aMethodName) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& aMethodName = *maybe__aMethodName;
            // Sentinel = 'aMethodName'
            if ((!(((&(reader__)))->ReadSentinel(426050628)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__aMethodDetails = IPC::ReadParam<IPCMethodChangeDetails>((&(reader__)));
            if (!maybe__aMethodDetails) {
                FatalError("Error deserializing 'IPCMethodChangeDetails'");
                return MsgValueError;

            }
            auto& aMethodDetails = *maybe__aMethodDetails;
            // Sentinel = 'aMethodDetails'
            if ((!(((&(reader__)))->ReadSentinel(681313673)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'IPCMethodChangeDetails'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<PaymentRequestChild*>(this))->RecvChangePaymentMethod(std::move(aRequestId), std::move(aMethodName), std::move(aMethodDetails));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}

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



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

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

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

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

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

} // namespace IPC
