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


#include "mozilla/extensions/PStreamFilterChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/extensions/StreamFilterChild.h"

#include "mozilla/ipc/PBackgroundChild.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 extensions {


auto PStreamFilterChild::ProcessingError(
        Result aCode,
        const char* aReason) -> void
{
}

auto PStreamFilterChild::ShouldContinueFromReplyTimeout() -> bool
{
    return true;
}

MOZ_IMPLICIT PStreamFilterChild::PStreamFilterChild() :
    mozilla::ipc::IToplevelProtocol("PStreamFilterChild", kProtocolId, mozilla::ipc::ChildSide)
{
    MOZ_COUNT_CTOR(PStreamFilterChild);
}

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

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

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

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

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

auto PStreamFilterChild::SendWrite(mozilla::Span<uint8_t const> data) -> bool
{
    UniquePtr<IPC::Message> msg__ = PStreamFilter::Msg_Write(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PStreamFilterChild::SendFlushedData() -> bool
{
    UniquePtr<IPC::Message> msg__ = PStreamFilter::Msg_FlushedData(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PStreamFilterChild::SendSuspend() -> bool
{
    UniquePtr<IPC::Message> msg__ = PStreamFilter::Msg_Suspend(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PStreamFilterChild::SendResume() -> bool
{
    UniquePtr<IPC::Message> msg__ = PStreamFilter::Msg_Resume(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PStreamFilterChild::SendClose() -> bool
{
    UniquePtr<IPC::Message> msg__ = PStreamFilter::Msg_Close(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PStreamFilterChild::SendDisconnect() -> bool
{
    UniquePtr<IPC::Message> msg__ = PStreamFilter::Msg_Disconnect(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PStreamFilterChild::SendDestroy() -> bool
{
    UniquePtr<IPC::Message> msg__ = PStreamFilter::Msg_Destroy(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

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

auto PStreamFilterChild::OnMessageReceived(const Message& msg__) -> PStreamFilterChild::Result
{
    switch (msg__.type()) {
    case PStreamFilter::Msg_Resumed__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStreamFilter", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStreamFilterChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStreamFilter::Msg_Resumed", OTHER);

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

            return MsgProcessed;
        }
    case PStreamFilter::Msg_Suspended__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStreamFilter", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStreamFilterChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStreamFilter::Msg_Suspended", OTHER);

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

            return MsgProcessed;
        }
    case PStreamFilter::Msg_Closed__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStreamFilter", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStreamFilterChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStreamFilter::Msg_Closed", OTHER);

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

            return MsgProcessed;
        }
    case PStreamFilter::Msg_Error__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStreamFilter", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStreamFilterChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStreamFilter::Msg_Error", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& error = *maybe__error;
            // Sentinel = 'error'
            if ((!(((&(reader__)))->ReadSentinel(107741739)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<StreamFilterChild*>(this))->RecvError(std::move(error));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PStreamFilter::Msg_FlushData__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStreamFilter", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStreamFilterChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStreamFilter::Msg_FlushData", OTHER);

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

            return MsgProcessed;
        }
    case PStreamFilter::Msg_StartRequest__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStreamFilter", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStreamFilterChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStreamFilter::Msg_StartRequest", OTHER);

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

            return MsgProcessed;
        }
    case PStreamFilter::Msg_Data__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStreamFilter", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStreamFilterChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStreamFilter::Msg_Data", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& data = *maybe__data;
            // Sentinel = 'data'
            if ((!(((&(reader__)))->ReadSentinel(67109275)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint8_t[]'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<StreamFilterChild*>(this))->RecvData(std::move(data));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PStreamFilter::Msg_StopRequest__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStreamFilter", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStreamFilterChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStreamFilter::Msg_StopRequest", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aStatus = *maybe__aStatus;
            // Sentinel = 'aStatus'
            if ((!(((&(reader__)))->ReadSentinel(186712806)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsresult'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<StreamFilterChild*>(this))->RecvStopRequest(std::move(aStatus));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    case SHMEM_CREATED_MESSAGE_TYPE:
        {
            if (!ShmemCreated(msg__)) {
                return MsgPayloadError;
            }
            return MsgProcessed;
        }
    case SHMEM_DESTROYED_MESSAGE_TYPE:
        {
            if (!ShmemDestroyed(msg__)) {
                return MsgPayloadError;
            }
            return MsgProcessed;
        }
    }
}

auto PStreamFilterChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PStreamFilterChild::Result
{
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
    return MsgNotKnown;
}



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

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

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

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

        return {};
    }
    return static_cast<::mozilla::extensions::PStreamFilterChild*>(actor);
}

} // namespace IPC
