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


#include "mozilla/dom/locks/PLockRequestChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/dom/locks/IPCUtils.h"
#include "mozilla/dom/locks/LockRequestChild.h"

#include "mozilla/dom/locks/PLockManagerChild.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 {
namespace locks {


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

auto PLockRequestChild::OnMessageReceived(const Message& msg__) -> PLockRequestChild::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 PLockRequest::Msg_Resolve__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PLockRequest", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PLockRequestChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PLockRequest::Msg_Resolve", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aMode = *maybe__aMode;
            // Sentinel = 'aMode'
            if ((!(((&(reader__)))->ReadSentinel(93848039)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'LockMode'");
                return MsgValueError;
            }
            auto maybe__aIsAvailable = IPC::ReadParam<bool>((&(reader__)));
            if (!maybe__aIsAvailable) {
                FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& aIsAvailable = *maybe__aIsAvailable;
            // Sentinel = 'aIsAvailable'
            if ((!(((&(reader__)))->ReadSentinel(491914399)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<LockRequestChild*>(this))->RecvResolve(std::move(aMode), std::move(aIsAvailable));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aAborted = *maybe__aAborted;
            // Sentinel = 'aAborted'
            if ((!(((&(reader__)))->ReadSentinel(228590371)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<LockRequestChild*>(this))->Recv__delete__(std::move(aAborted));
            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 PLockRequestChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PLockRequestChild::Result
{
    return MsgNotKnown;
}



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

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

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

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

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

} // namespace IPC
