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


#include "mozilla/PClipboardContentAnalysisChild.h"
#include "mozilla/ClipboardContentAnalysisChild.h"
#include "mozilla/GfxMessageUtils.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/dom/PermissionMessageUtils.h"
#include "mozilla/ipc/BigBuffer.h"
#include "mozilla/widget/WidgetMessageUtils.h"
#include "nsIPrincipal.h"
#include "nsIReferrerInfo.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 {


auto PClipboardContentAnalysisChild::ProcessingError(
        Result aCode,
        const char* aReason) -> void
{
}

auto PClipboardContentAnalysisChild::ShouldContinueFromReplyTimeout() -> bool
{
    return true;
}

MOZ_IMPLICIT PClipboardContentAnalysisChild::PClipboardContentAnalysisChild() :
    mozilla::ipc::IToplevelProtocol("PClipboardContentAnalysisChild", kProtocolId, mozilla::ipc::ChildSide)
{
    MOZ_COUNT_CTOR(PClipboardContentAnalysisChild);
}

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

auto PClipboardContentAnalysisChild::ActorAlloc() -> void
{
    MOZ_RELEASE_ASSERT(XRE_IsContentProcess(), "Invalid process for `PClipboardContentAnalysisChild'");
    AddRef();
}

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

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

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

auto PClipboardContentAnalysisChild::RejectPendingResponses(ResponseRejectReason aReason) -> void
{
    mAsyncCallbacks.RejectPendingResponses(aReason);
}

auto PClipboardContentAnalysisChild::SendGetClipboard(
        mozilla::Span<nsCString const> aTypes,
        const ClipboardType& aWhichClipboard,
        const uint64_t& aRequestingWindowContextId,
        IPCTransferableDataOrError* transferableDataOrError) -> bool
{
    UniquePtr<IPC::Message> msg__ = PClipboardContentAnalysis::Msg_GetClipboard(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aTypes);
    // Sentinel = 'aTypes'
    ((&(writer__)))->WriteSentinel(140575351);
    IPC::WriteParam((&(writer__)), aWhichClipboard);
    // Sentinel = 'aWhichClipboard'
    ((&(writer__)))->WriteSentinel(776996325);
    IPC::WriteParam((&(writer__)), aRequestingWindowContextId);
    // Sentinel = 'aRequestingWindowContextId'
    ((&(writer__)))->WriteSentinel(2397309587);

    UniquePtr<Message> reply__;

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

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

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

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

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

    }
    auto& transferableDataOrError__reply = *maybe__transferableDataOrError__reply;
    // Sentinel = 'transferableDataOrError'
    if ((!(((&(reader__)))->ReadSentinel(1880557887)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'IPCTransferableDataOrError'");
        return false;
    }
    (*(transferableDataOrError)) = std::move(transferableDataOrError__reply);
    reader__.EndRead();

    return true;
}

auto PClipboardContentAnalysisChild::SendGetClipboardDataIfSmallerThan(
        mozilla::Span<nsCString const> aTypes,
        const uint64_t& aThreshold,
        const ClipboardType& aWhichClipboard,
        const uint64_t& aRequestingWindowContextId,
        mozilla::ipc::ResolveCallback<IPCTransferableDataOrError>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PClipboardContentAnalysis::Msg_GetClipboardDataIfSmallerThan(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aTypes);
    // Sentinel = 'aTypes'
    ((&(writer__)))->WriteSentinel(140575351);
    IPC::WriteParam((&(writer__)), aThreshold);
    // Sentinel = 'aThreshold'
    ((&(writer__)))->WriteSentinel(367789071);
    IPC::WriteParam((&(writer__)), aWhichClipboard);
    // Sentinel = 'aWhichClipboard'
    ((&(writer__)))->WriteSentinel(776996325);
    IPC::WriteParam((&(writer__)), aRequestingWindowContextId);
    // Sentinel = 'aRequestingWindowContextId'
    ((&(writer__)))->WriteSentinel(2397309587);


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

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PClipboardContentAnalysis::Reply_GetClipboardDataIfSmallerThan__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__transferableDataOrError = IPC::ReadParam<IPCTransferableDataOrError>(aReader);
            if (!maybe__transferableDataOrError) {
                (aReader)->FatalError("Error deserializing 'IPCTransferableDataOrError'");
                return MsgValueError;

            }
            auto& transferableDataOrError = *maybe__transferableDataOrError;
            // Sentinel = 'transferableDataOrError'
            if ((!((aReader)->ReadSentinel(1880557887)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'IPCTransferableDataOrError'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::move(transferableDataOrError));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PClipboardContentAnalysisChild::SendGetClipboardDataIfSmallerThan(
        mozilla::Span<nsCString const> aTypes,
        const uint64_t& aThreshold,
        const ClipboardType& aWhichClipboard,
        const uint64_t& aRequestingWindowContextId) -> RefPtr<GetClipboardDataIfSmallerThanPromise>
{
    RefPtr<MozPromise<IPCTransferableDataOrError, ResponseRejectReason, true>::Private> promise__ = new MozPromise<IPCTransferableDataOrError, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendGetClipboardDataIfSmallerThan(std::forward<mozilla::Span<nsCString const>>(aTypes), std::forward<const uint64_t&>(aThreshold), std::forward<const ClipboardType&>(aWhichClipboard), std::forward<const uint64_t&>(aRequestingWindowContextId), [promise__](IPCTransferableDataOrError&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

auto PClipboardContentAnalysisChild::SendGetAllClipboardDataSync(
        mozilla::Span<nsCString const> aTypes,
        const ClipboardType& aWhichClipboard,
        const uint64_t& aRequestingWindowContextId,
        IPCTransferableDataOrError* transferableDataOrError) -> bool
{
    UniquePtr<IPC::Message> msg__ = PClipboardContentAnalysis::Msg_GetAllClipboardDataSync(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aTypes);
    // Sentinel = 'aTypes'
    ((&(writer__)))->WriteSentinel(140575351);
    IPC::WriteParam((&(writer__)), aWhichClipboard);
    // Sentinel = 'aWhichClipboard'
    ((&(writer__)))->WriteSentinel(776996325);
    IPC::WriteParam((&(writer__)), aRequestingWindowContextId);
    // Sentinel = 'aRequestingWindowContextId'
    ((&(writer__)))->WriteSentinel(2397309587);

    UniquePtr<Message> reply__;

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

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

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

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

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

    }
    auto& transferableDataOrError__reply = *maybe__transferableDataOrError__reply;
    // Sentinel = 'transferableDataOrError'
    if ((!(((&(reader__)))->ReadSentinel(1880557887)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'IPCTransferableDataOrError'");
        return false;
    }
    (*(transferableDataOrError)) = std::move(transferableDataOrError__reply);
    reader__.EndRead();

    return true;
}

auto PClipboardContentAnalysisChild::SendSetClipboard(
        IPCTransferable&& aTransferable,
        const ClipboardType& aWhichClipboard,
        const uint64_t& aSettingWindowContextId,
        nsresult* rv) -> bool
{
    UniquePtr<IPC::Message> msg__ = PClipboardContentAnalysis::Msg_SetClipboard(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), std::move(aTransferable));
    // Sentinel = 'aTransferable'
    ((&(writer__)))->WriteSentinel(609813819);
    IPC::WriteParam((&(writer__)), aWhichClipboard);
    // Sentinel = 'aWhichClipboard'
    ((&(writer__)))->WriteSentinel(776996325);
    IPC::WriteParam((&(writer__)), aSettingWindowContextId);
    // Sentinel = 'aSettingWindowContextId'
    ((&(writer__)))->WriteSentinel(1866795338);

    UniquePtr<Message> reply__;

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

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

    if (mozilla::ipc::LoggingEnabledFor("PClipboardContentAnalysis", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PClipboardContentAnalysisChild",
            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;
    }
    (*(rv)) = std::move(rv__reply);
    reader__.EndRead();

    return true;
}

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

auto PClipboardContentAnalysisChild::OnMessageReceived(const Message& msg__) -> PClipboardContentAnalysisChild::Result
{
    if (!CanSend()) {
        if (mozilla::ipc::LoggingEnabledFor("PClipboardContentAnalysis", mozilla::ipc::ChildSide)) {
            mozilla::ipc::LogMessageForProtocol(
                "PClipboardContentAnalysisChild",
                this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                "Ignored message for dead actor",
                (&(msg__))->type(),
                mozilla::ipc::MessageDirection::eSending);
        }
        return MsgProcessed;

    }
    switch (msg__.type()) {
    case PClipboardContentAnalysis::Reply_GetClipboardDataIfSmallerThan__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PClipboardContentAnalysis", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PClipboardContentAnalysisChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PClipboardContentAnalysis::Msg_GetClipboardDataIfSmallerThan", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    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 PClipboardContentAnalysisChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PClipboardContentAnalysisChild::Result
{
    if (!CanSend()) {
        return MsgDropped;

    }
    return MsgNotKnown;
}



} // namespace mozilla
