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


#include "mozilla/dom/PSerialManagerParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/dom/SerialManagerParent.h"
#include "mozilla/dom/SerialPortIPCTypes.h"

#include "mozilla/dom/PWindowGlobalParent.h"
#include "mozilla/dom/PSerialPortParent.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 PSerialManagerParent::PSerialManagerParent() :
    mozilla::ipc::IRefCountedProtocol(kProtocolId, mozilla::ipc::ParentSide)
{
    MOZ_COUNT_CTOR(PSerialManagerParent);
}

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

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

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

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

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

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

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

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


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

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

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

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

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

    }
    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 PSerialManager::Msg_RequestPort__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PSerialManager", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PSerialManagerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PSerialManager::Msg_RequestPort", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__filters = IPC::ReadParam<nsTArray<IPCSerialPortFilter>>((&(reader__)));
            if (!maybe__filters) {
                FatalError("Error deserializing 'IPCSerialPortFilter[]'");
                return MsgValueError;

            }
            auto& filters = *maybe__filters;
            // Sentinel = 'filters'
            if ((!(((&(reader__)))->ReadSentinel(196674298)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'IPCSerialPortFilter[]'");
                return MsgValueError;
            }
            auto maybe__allowedBluetoothServiceClassIds = IPC::ReadParam<nsTArray<nsString>>((&(reader__)));
            if (!maybe__allowedBluetoothServiceClassIds) {
                FatalError("Error deserializing 'nsString[]'");
                return MsgValueError;

            }
            auto& allowedBluetoothServiceClassIds = *maybe__allowedBluetoothServiceClassIds;
            // Sentinel = 'allowedBluetoothServiceClassIds'
            if ((!(((&(reader__)))->ReadSentinel(3390639238)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString[]'");
                return MsgValueError;
            }
            auto maybe__autoselect = IPC::ReadParam<bool>((&(reader__)));
            if (!maybe__autoselect) {
                FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& autoselect = *maybe__autoselect;
            // Sentinel = 'autoselect'
            if ((!(((&(reader__)))->ReadSentinel(392037434)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::ActorId id__ = Id();
            UniquePtr<IPC::Message> reply__(PSerialManager::Reply_RequestPort(id__));
            reply__->set_seqno(msg__.seqno());

            RefPtr<mozilla::ipc::IPDLResolverInner> resolver__ =
                new mozilla::ipc::IPDLResolverInner(std::move(reply__), this);

            RequestPortResolver resolver = [resolver__ = std::move(resolver__)](std::tuple<const IPCRequestPortResult&, Endpoint<::mozilla::dom::PSerialPortChild>&&> aParam) {
                resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) {
                    IPC::MessageWriter writer__(*reply__, self__);
                    IPC::WriteParam((&(writer__)), std::get<0>(aParam));
                    // Sentinel = 'result'
                    ((&(writer__)))->WriteSentinel(153223840);
                    IPC::WriteParam((&(writer__)), std::move(std::get<1>(aParam)));
                    // Sentinel = 'childEndpoint'
                    ((&(writer__)))->WriteSentinel(606864710);

                    if (mozilla::ipc::LoggingEnabledFor("PSerialManager", mozilla::ipc::ParentSide)) {
                        mozilla::ipc::LogMessageForProtocol(
                            "PSerialManagerParent",
                            self__->ToplevelProtocol()->OtherPidMaybeInvalid(),
                            "Sending reply ",
                            reply__->type(),
                            mozilla::ipc::MessageDirection::eSending);
                    }

                });
            };
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::dom::SerialManagerParent*>(this))->RecvRequestPort(std::move(filters), std::move(allowedBluetoothServiceClassIds), std::move(autoselect), std::move(resolver));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PSerialManager::Msg_SimulateDeviceConnection__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PSerialManager", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PSerialManagerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PSerialManager::Msg_SimulateDeviceConnection", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& deviceId = *maybe__deviceId;
            // Sentinel = 'deviceId'
            if ((!(((&(reader__)))->ReadSentinel(242025246)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__devicePath = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__devicePath) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& devicePath = *maybe__devicePath;
            // Sentinel = 'devicePath'
            if ((!(((&(reader__)))->ReadSentinel(369886206)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__vendorId = IPC::ReadParam<uint16_t>((&(reader__)));
            if (!maybe__vendorId) {
                FatalError("Error deserializing 'uint16_t'");
                return MsgValueError;

            }
            auto& vendorId = *maybe__vendorId;
            // Sentinel = 'vendorId'
            if ((!(((&(reader__)))->ReadSentinel(252379964)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint16_t'");
                return MsgValueError;
            }
            auto maybe__productId = IPC::ReadParam<uint16_t>((&(reader__)));
            if (!maybe__productId) {
                FatalError("Error deserializing 'uint16_t'");
                return MsgValueError;

            }
            auto& productId = *maybe__productId;
            // Sentinel = 'productId'
            if ((!(((&(reader__)))->ReadSentinel(319882159)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint16_t'");
                return MsgValueError;
            }
            auto maybe__bluetoothServiceClassId = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__bluetoothServiceClassId) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& bluetoothServiceClassId = *maybe__bluetoothServiceClassId;
            // Sentinel = 'bluetoothServiceClassId'
            if ((!(((&(reader__)))->ReadSentinel(1912211787)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::ActorId id__ = Id();
            UniquePtr<IPC::Message> reply__(PSerialManager::Reply_SimulateDeviceConnection(id__));
            reply__->set_seqno(msg__.seqno());

            RefPtr<mozilla::ipc::IPDLResolverInner> resolver__ =
                new mozilla::ipc::IPDLResolverInner(std::move(reply__), this);

            SimulateDeviceConnectionResolver resolver = [resolver__ = std::move(resolver__)](const nsresult& aParam) {
                resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) {
                    IPC::MessageWriter writer__(*reply__, self__);
                    IPC::WriteParam((&(writer__)), aParam);
                    // Sentinel = 'rv'
                    ((&(writer__)))->WriteSentinel(22806761);

                    if (mozilla::ipc::LoggingEnabledFor("PSerialManager", mozilla::ipc::ParentSide)) {
                        mozilla::ipc::LogMessageForProtocol(
                            "PSerialManagerParent",
                            self__->ToplevelProtocol()->OtherPidMaybeInvalid(),
                            "Sending reply ",
                            reply__->type(),
                            mozilla::ipc::MessageDirection::eSending);
                    }

                });
            };
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::dom::SerialManagerParent*>(this))->RecvSimulateDeviceConnection(std::move(deviceId), std::move(devicePath), std::move(vendorId), std::move(productId), std::move(bluetoothServiceClassId), std::move(resolver));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PSerialManager::Msg_SimulateDeviceDisconnection__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PSerialManager", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PSerialManagerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PSerialManager::Msg_SimulateDeviceDisconnection", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& deviceId = *maybe__deviceId;
            // Sentinel = 'deviceId'
            if ((!(((&(reader__)))->ReadSentinel(242025246)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::ActorId id__ = Id();
            UniquePtr<IPC::Message> reply__(PSerialManager::Reply_SimulateDeviceDisconnection(id__));
            reply__->set_seqno(msg__.seqno());

            RefPtr<mozilla::ipc::IPDLResolverInner> resolver__ =
                new mozilla::ipc::IPDLResolverInner(std::move(reply__), this);

            SimulateDeviceDisconnectionResolver resolver = [resolver__ = std::move(resolver__)](const nsresult& aParam) {
                resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) {
                    IPC::MessageWriter writer__(*reply__, self__);
                    IPC::WriteParam((&(writer__)), aParam);
                    // Sentinel = 'rv'
                    ((&(writer__)))->WriteSentinel(22806761);

                    if (mozilla::ipc::LoggingEnabledFor("PSerialManager", mozilla::ipc::ParentSide)) {
                        mozilla::ipc::LogMessageForProtocol(
                            "PSerialManagerParent",
                            self__->ToplevelProtocol()->OtherPidMaybeInvalid(),
                            "Sending reply ",
                            reply__->type(),
                            mozilla::ipc::MessageDirection::eSending);
                    }

                });
            };
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::dom::SerialManagerParent*>(this))->RecvSimulateDeviceDisconnection(std::move(deviceId), std::move(resolver));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PSerialManager::Msg_RemoveAllMockDevices__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PSerialManager", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PSerialManagerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PSerialManager::Msg_RemoveAllMockDevices", OTHER);

            mozilla::ipc::ActorId id__ = Id();
            UniquePtr<IPC::Message> reply__(PSerialManager::Reply_RemoveAllMockDevices(id__));
            reply__->set_seqno(msg__.seqno());

            RefPtr<mozilla::ipc::IPDLResolverInner> resolver__ =
                new mozilla::ipc::IPDLResolverInner(std::move(reply__), this);

            RemoveAllMockDevicesResolver resolver = [resolver__ = std::move(resolver__)](const nsresult& aParam) {
                resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) {
                    IPC::MessageWriter writer__(*reply__, self__);
                    IPC::WriteParam((&(writer__)), aParam);
                    // Sentinel = 'rv'
                    ((&(writer__)))->WriteSentinel(22806761);

                    if (mozilla::ipc::LoggingEnabledFor("PSerialManager", mozilla::ipc::ParentSide)) {
                        mozilla::ipc::LogMessageForProtocol(
                            "PSerialManagerParent",
                            self__->ToplevelProtocol()->OtherPidMaybeInvalid(),
                            "Sending reply ",
                            reply__->type(),
                            mozilla::ipc::MessageDirection::eSending);
                    }

                });
            };
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::dom::SerialManagerParent*>(this))->RecvRemoveAllMockDevices(std::move(resolver));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PSerialManager::Msg_ResetToDefaultMockDevices__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PSerialManager", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PSerialManagerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PSerialManager::Msg_ResetToDefaultMockDevices", OTHER);

            mozilla::ipc::ActorId id__ = Id();
            UniquePtr<IPC::Message> reply__(PSerialManager::Reply_ResetToDefaultMockDevices(id__));
            reply__->set_seqno(msg__.seqno());

            RefPtr<mozilla::ipc::IPDLResolverInner> resolver__ =
                new mozilla::ipc::IPDLResolverInner(std::move(reply__), this);

            ResetToDefaultMockDevicesResolver resolver = [resolver__ = std::move(resolver__)](const nsresult& aParam) {
                resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) {
                    IPC::MessageWriter writer__(*reply__, self__);
                    IPC::WriteParam((&(writer__)), aParam);
                    // Sentinel = 'rv'
                    ((&(writer__)))->WriteSentinel(22806761);

                    if (mozilla::ipc::LoggingEnabledFor("PSerialManager", mozilla::ipc::ParentSide)) {
                        mozilla::ipc::LogMessageForProtocol(
                            "PSerialManagerParent",
                            self__->ToplevelProtocol()->OtherPidMaybeInvalid(),
                            "Sending reply ",
                            reply__->type(),
                            mozilla::ipc::MessageDirection::eSending);
                    }

                });
            };
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::dom::SerialManagerParent*>(this))->RecvResetToDefaultMockDevices(std::move(resolver));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PSerialManager::Reply___delete____ID:
        {
            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}

auto PSerialManagerParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PSerialManagerParent::Result
{
    if (!CanSend()) {
        return MsgDropped;

    }
    return MsgNotKnown;
}



} // namespace dom
} // namespace mozilla
