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


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

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

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

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

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

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

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

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

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

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

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

auto PFilePickerChild::SendOpen(
        const int16_t& selectedType,
        const bool& addToRecentDocs,
        const nsAString& defaultFile,
        const nsAString& defaultExtension,
        mozilla::Span<nsString const> filters,
        mozilla::Span<nsString const> filterNames,
        mozilla::Span<nsString const> rawFilters,
        const nsAString& displayDirectory,
        const nsAString& displaySpecialDirectory,
        const nsAString& okButtonLabel,
        const CaptureTarget& capture) -> bool
{
    UniquePtr<IPC::Message> msg__ = PFilePicker::Msg_Open(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), selectedType);
    // Sentinel = 'selectedType'
    ((&(writer__)))->WriteSentinel(539100396);
    IPC::WriteParam((&(writer__)), addToRecentDocs);
    // Sentinel = 'addToRecentDocs'
    ((&(writer__)))->WriteSentinel(772343255);
    IPC::WriteParam((&(writer__)), defaultFile);
    // Sentinel = 'defaultFile'
    ((&(writer__)))->WriteSentinel(443941990);
    IPC::WriteParam((&(writer__)), defaultExtension);
    // Sentinel = 'defaultExtension'
    ((&(writer__)))->WriteSentinel(932447907);
    IPC::WriteParam((&(writer__)), filters);
    // Sentinel = 'filters'
    ((&(writer__)))->WriteSentinel(196674298);
    IPC::WriteParam((&(writer__)), filterNames);
    // Sentinel = 'filterNames'
    ((&(writer__)))->WriteSentinel(451937403);
    IPC::WriteParam((&(writer__)), rawFilters);
    // Sentinel = 'rawFilters'
    ((&(writer__)))->WriteSentinel(376505380);
    IPC::WriteParam((&(writer__)), displayDirectory);
    // Sentinel = 'displayDirectory'
    ((&(writer__)))->WriteSentinel(938935980);
    IPC::WriteParam((&(writer__)), displaySpecialDirectory);
    // Sentinel = 'displaySpecialDirectory'
    ((&(writer__)))->WriteSentinel(1884555629);
    IPC::WriteParam((&(writer__)), okButtonLabel);
    // Sentinel = 'okButtonLabel'
    ((&(writer__)))->WriteSentinel(617153847);
    IPC::WriteParam((&(writer__)), capture);
    // Sentinel = 'capture'
    ((&(writer__)))->WriteSentinel(195691253);


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

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

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

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& data = *maybe__data;
            // Sentinel = 'data'
            if ((!(((&(reader__)))->ReadSentinel(67109275)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'MaybeInputData'");
                return MsgValueError;
            }
            auto maybe__result = IPC::ReadParam<ResultCode>((&(reader__)));
            if (!maybe__result) {
                FatalError("Error deserializing 'ResultCode'");
                return MsgValueError;

            }
            auto& result = *maybe__result;
            // Sentinel = 'result'
            if ((!(((&(reader__)))->ReadSentinel(153223840)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'ResultCode'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (this)->Recv__delete__(std::move(data), std::move(result));
            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 PFilePickerChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PFilePickerChild::Result
{
    return MsgNotKnown;
}



} // namespace dom
} // namespace mozilla
namespace IPC {
auto ParamTraits<::mozilla::dom::PFilePickerChild*>::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::PFilePickerChild*>::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::PFilePickerChild*>(actor);
}

} // namespace IPC
