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


#include "mozilla/extensions/PStreamFilterParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/extensions/StreamFilterParent.h"

#include "mozilla/ipc/PBackgroundParent.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 PStreamFilterParent::ProcessingError(
        Result aCode,
        const char* aReason) -> void
{
}

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

MOZ_IMPLICIT PStreamFilterParent::PStreamFilterParent() :
    mozilla::ipc::IToplevelProtocol("PStreamFilterParent", kProtocolId, mozilla::ipc::ParentSide)
{
    MOZ_COUNT_CTOR(PStreamFilterParent);
}

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

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

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

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

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

auto PStreamFilterParent::SendResumed() -> bool
{
    UniquePtr<IPC::Message> msg__ = PStreamFilter::Msg_Resumed(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PStreamFilterParent::SendSuspended() -> bool
{
    UniquePtr<IPC::Message> msg__ = PStreamFilter::Msg_Suspended(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PStreamFilterParent::SendClosed() -> bool
{
    UniquePtr<IPC::Message> msg__ = PStreamFilter::Msg_Closed(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PStreamFilterParent::SendError(const nsACString& error) -> bool
{
    UniquePtr<IPC::Message> msg__ = PStreamFilter::Msg_Error(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PStreamFilterParent::SendFlushData() -> bool
{
    UniquePtr<IPC::Message> msg__ = PStreamFilter::Msg_FlushData(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PStreamFilterParent::SendStartRequest() -> bool
{
    UniquePtr<IPC::Message> msg__ = PStreamFilter::Msg_StartRequest(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

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

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


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

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

auto PStreamFilterParent::SendStopRequest(const nsresult& aStatus) -> bool
{
    UniquePtr<IPC::Message> msg__ = PStreamFilter::Msg_StopRequest(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

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

auto PStreamFilterParent::OnMessageReceived(const Message& msg__) -> PStreamFilterParent::Result
{
    switch (msg__.type()) {
    case PStreamFilter::Msg_Write__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStreamFilter", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStreamFilterParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStreamFilter::Msg_Write", 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<StreamFilterParent*>(this))->RecvWrite(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_FlushedData__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStreamFilter", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStreamFilterParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStreamFilter::Msg_FlushedData", OTHER);

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

            return MsgProcessed;
        }
    case PStreamFilter::Msg_Suspend__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStreamFilter", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStreamFilterParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStreamFilter::Msg_Suspend", OTHER);

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

            return MsgProcessed;
        }
    case PStreamFilter::Msg_Resume__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStreamFilter", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStreamFilterParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStreamFilter::Msg_Resume", OTHER);

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

            return MsgProcessed;
        }
    case PStreamFilter::Msg_Close__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStreamFilter", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStreamFilterParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStreamFilter::Msg_Close", OTHER);

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

            return MsgProcessed;
        }
    case PStreamFilter::Msg_Disconnect__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStreamFilter", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStreamFilterParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStreamFilter::Msg_Disconnect", OTHER);

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

            return MsgProcessed;
        }
    case PStreamFilter::Msg_Destroy__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStreamFilter", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStreamFilterParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStreamFilter::Msg_Destroy", OTHER);

            mozilla::ipc::IPCResult __ok = (static_cast<StreamFilterParent*>(this))->RecvDestroy();
            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 PStreamFilterParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PStreamFilterParent::Result
{
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
    return MsgNotKnown;
}



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

} // namespace IPC
