//
// 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::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::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::DeallocManagee(
        mozilla::ipc::ProtocolId aProtocolId,
        IProtocol* aListener) -> void
{
    FatalError("unreached");
    return;
}

auto PClipboardContentAnalysisChild::OnMessageReceived(const Message& msg__) -> PClipboardContentAnalysisChild::Result
{
    switch (msg__.type()) {
    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
{
    return MsgNotKnown;
}



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

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

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

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

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

} // namespace IPC
