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


#include "mozilla/dom/PTemporaryIPCBlobParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/RemoteLazyInputStream.h"
#include "mozilla/dom/TemporaryIPCBlobParent.h"
#include "mozilla/ipc/IPCCore.h"

#include "mozilla/ipc/PBackgroundParent.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 PTemporaryIPCBlobParent::PTemporaryIPCBlobParent() :
    mozilla::ipc::IProtocol(kProtocolId, mozilla::ipc::ParentSide)
{
    MOZ_COUNT_CTOR(PTemporaryIPCBlobParent);
}

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

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

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

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

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

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

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

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

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

auto PTemporaryIPCBlobParent::SendFileDesc(const FileDescriptor& aFD) -> bool
{
    UniquePtr<IPC::Message> msg__ = PTemporaryIPCBlob::Msg_FileDesc(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


    if (mozilla::ipc::LoggingEnabledFor("PTemporaryIPCBlob", mozilla::ipc::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PTemporaryIPCBlobParent",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PTemporaryIPCBlob::Msg_FileDesc", OTHER);

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

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

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

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

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

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

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

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

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

            return MsgProcessed;
        }
    case PTemporaryIPCBlob::Msg_OperationDone__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PTemporaryIPCBlob", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PTemporaryIPCBlobParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PTemporaryIPCBlob::Msg_OperationDone", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aContentType = *maybe__aContentType;
            // Sentinel = 'aContentType'
            if ((!(((&(reader__)))->ReadSentinel(518522079)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            auto maybe__aFD = IPC::ReadParam<FileDescriptor>((&(reader__)));
            if (!maybe__aFD) {
                FatalError("Error deserializing 'FileDescriptor'");
                return MsgValueError;

            }
            auto& aFD = *maybe__aFD;
            // Sentinel = 'aFD'
            if ((!(((&(reader__)))->ReadSentinel(32899308)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'FileDescriptor'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<TemporaryIPCBlobParent*>(this))->RecvOperationDone(std::move(aContentType), std::move(aFD));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}

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



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

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

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

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

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

} // namespace IPC
