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


#include "mozilla/dom/PFilePickerParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/RemoteLazyInputStream.h"
#include "mozilla/dom/FilePickerMessageUtils.h"
#include "mozilla/dom/FilePickerParent.h"
#include "mozilla/ipc/IPCCore.h"

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

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

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

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

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

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

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

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

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

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

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

    IPC::WriteParam((&(writer__)), data);
    // Sentinel = 'data'
    ((&(writer__)))->WriteSentinel(67109275);
    IPC::WriteParam((&(writer__)), result);
    // Sentinel = 'result'
    ((&(writer__)))->WriteSentinel(153223840);

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

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

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

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

auto PFilePickerParent::OnMessageReceived(const Message& msg__) -> PFilePickerParent::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 PFilePicker::Msg_Open__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PFilePicker", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PFilePickerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PFilePicker::Msg_Open", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& selectedType = *maybe__selectedType;
            // Sentinel = 'selectedType'
            if ((!(((&(reader__)))->ReadSentinel(539100396)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'int16_t'");
                return MsgValueError;
            }
            auto maybe__addToRecentDocs = IPC::ReadParam<bool>((&(reader__)));
            if (!maybe__addToRecentDocs) {
                FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& addToRecentDocs = *maybe__addToRecentDocs;
            // Sentinel = 'addToRecentDocs'
            if ((!(((&(reader__)))->ReadSentinel(772343255)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            auto maybe__defaultFile = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__defaultFile) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

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

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

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

            }
            auto& filterNames = *maybe__filterNames;
            // Sentinel = 'filterNames'
            if ((!(((&(reader__)))->ReadSentinel(451937403)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString[]'");
                return MsgValueError;
            }
            auto maybe__rawFilters = IPC::ReadParam<nsTArray<nsString>>((&(reader__)));
            if (!maybe__rawFilters) {
                FatalError("Error deserializing 'nsString[]'");
                return MsgValueError;

            }
            auto& rawFilters = *maybe__rawFilters;
            // Sentinel = 'rawFilters'
            if ((!(((&(reader__)))->ReadSentinel(376505380)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString[]'");
                return MsgValueError;
            }
            auto maybe__displayDirectory = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__displayDirectory) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

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

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

            }
            auto& okButtonLabel = *maybe__okButtonLabel;
            // Sentinel = 'okButtonLabel'
            if ((!(((&(reader__)))->ReadSentinel(617153847)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__capture = IPC::ReadParam<CaptureTarget>((&(reader__)));
            if (!maybe__capture) {
                FatalError("Error deserializing 'CaptureTarget'");
                return MsgValueError;

            }
            auto& capture = *maybe__capture;
            // Sentinel = 'capture'
            if ((!(((&(reader__)))->ReadSentinel(195691253)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'CaptureTarget'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<FilePickerParent*>(this))->RecvOpen(std::move(selectedType), std::move(addToRecentDocs), std::move(defaultFile), std::move(defaultExtension), std::move(filters), std::move(filterNames), std::move(rawFilters), std::move(displayDirectory), std::move(displaySpecialDirectory), std::move(okButtonLabel), std::move(capture));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

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

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



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

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

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

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

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

} // namespace IPC
