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


#include "mozilla/PClipboardReadRequestChild.h"
#include "mozilla/AntiTrackingIPCUtils.h"
#include "mozilla/ClipboardReadRequestChild.h"
#include "mozilla/GfxMessageUtils.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/RemoteLazyInputStream.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/URLClassifierIPCUtils.h"
#include "mozilla/dom/CSPMessageUtils.h"
#include "mozilla/dom/DocShellMessageUtils.h"
#include "mozilla/dom/DomSecurityIPCUtils.h"
#include "mozilla/dom/FeaturePolicyUtils.h"
#include "mozilla/dom/FetchIPCTypes.h"
#include "mozilla/dom/NavigationAPIIPCUtils.h"
#include "mozilla/dom/PermissionMessageUtils.h"
#include "mozilla/dom/PolicyContainerMessageUtils.h"
#include "mozilla/dom/PropertyBagUtils.h"
#include "mozilla/dom/ReferrerInfoUtils.h"
#include "mozilla/dom/SessionHistoryEntry.h"
#include "mozilla/dom/TabMessageUtils.h"
#include "mozilla/dom/notification/IPCUtils.h"
#include "mozilla/ipc/BigBuffer.h"
#include "mozilla/ipc/IPCCore.h"
#include "mozilla/ipc/IPCStreamUtils.h"
#include "mozilla/ipc/SerializedStructuredCloneBuffer.h"
#include "mozilla/ipc/URIUtils.h"
#include "mozilla/layers/LayersMessageUtils.h"
#include "mozilla/net/CacheInfoIPCTypes.h"
#include "mozilla/net/ClassOfService.h"
#include "mozilla/net/NeckoMessageUtils.h"
#include "nsDOMNavigationTiming.h"
#include "nsDocShellLoadState.h"
#include "nsHttp.h"
#include "nsHttpResponseHead.h"
#include "nsIPolicyContainer.h"
#include "nsIPrincipal.h"
#include "nsIPropertyBag2.h"
#include "nsIReferrerInfo.h"
#include "nsIURI.h"
#include "nsIVariant.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 PClipboardReadRequestChild::Recv__delete__() -> mozilla::ipc::IPCResult
{
    return IPC_OK();
}

MOZ_IMPLICIT PClipboardReadRequestChild::PClipboardReadRequestChild() :
    mozilla::ipc::IRefCountedProtocol(kProtocolId, mozilla::ipc::ChildSide)
{
    MOZ_COUNT_CTOR(PClipboardReadRequestChild);
}

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

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

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

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

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

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

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

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

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

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

auto PClipboardReadRequestChild::SendGetData(
        mozilla::Span<nsCString const> aFlavors,
        mozilla::ipc::ResolveCallback<IPCTransferableDataOrError>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PClipboardReadRequest::Msg_GetData(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

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


            aReader->EndRead();

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

auto PClipboardReadRequestChild::SendGetData(mozilla::Span<nsCString const> aFlavors) -> RefPtr<GetDataPromise>
{
    RefPtr<MozPromise<IPCTransferableDataOrError, ResponseRejectReason, true>::Private> promise__ = new MozPromise<IPCTransferableDataOrError, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendGetData(std::move(aFlavors), [promise__](IPCTransferableDataOrError&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

auto PClipboardReadRequestChild::SendGetDataSync(
        mozilla::Span<nsCString const> aFlavors,
        IPCTransferableDataOrError* aTransferableData) -> bool
{
    UniquePtr<IPC::Message> msg__ = PClipboardReadRequest::Msg_GetDataSync(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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

    UniquePtr<Message> reply__;

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

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

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

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

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

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

    return true;
}

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


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

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

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

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

auto PClipboardReadRequestChild::OnMessageReceived(const Message& msg__) -> PClipboardReadRequestChild::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 PClipboardReadRequest::Reply_GetData__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PClipboardReadRequest", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PClipboardReadRequestChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PClipboardReadRequest::Msg_GetData", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    case PClipboardReadRequest::Reply___delete____ID:
        {
            return MsgProcessed;
        }
    case PClipboardReadRequest::Msg___delete____ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PClipboardReadRequest", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PClipboardReadRequestChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PClipboardReadRequest::Msg___delete__", OTHER);

            mozilla::ipc::IPCResult __ok = (static_cast<ClipboardReadRequestChild*>(this))->Recv__delete__();
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }


            this->ActorDisconnected(Deletion);

            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}

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



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

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

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

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

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

} // namespace IPC
