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


#include "mozilla/net/PSocketProcessBridgeParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/net/SocketProcessBridgeParent.h"

#include "mozilla/net/PBackgroundDataBridgeParent.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 net {


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

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

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

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

auto PSocketProcessBridgeParent::ActorAlloc() -> void
{
    MOZ_RELEASE_ASSERT(XRE_IsSocketProcess(), "Invalid process for `PSocketProcessBridgeParent'");
    AddRef();
}

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

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

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

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

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

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

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

auto PSocketProcessBridgeParent::OnMessageReceived(const Message& msg__) -> PSocketProcessBridgeParent::Result
{
    switch (msg__.type()) {
    case PSocketProcessBridge::Msg_InitBackgroundDataBridge__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PSocketProcessBridge", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PSocketProcessBridgeParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PSocketProcessBridge::Msg_InitBackgroundDataBridge", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__aEndpoint = IPC::ReadParam<Endpoint<::mozilla::net::PBackgroundDataBridgeParent>>((&(reader__)));
            if (!maybe__aEndpoint) {
                FatalError("Error deserializing 'Endpoint<::mozilla::net::PBackgroundDataBridgeParent>'");
                return MsgValueError;

            }
            auto& aEndpoint = *maybe__aEndpoint;
            // Sentinel = 'aEndpoint'
            if ((!(((&(reader__)))->ReadSentinel(292225955)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'Endpoint<::mozilla::net::PBackgroundDataBridgeParent>'");
                return MsgValueError;
            }
            auto maybe__aChannelID = IPC::ReadParam<uint64_t>((&(reader__)));
            if (!maybe__aChannelID) {
                FatalError("Error deserializing 'uint64_t'");
                return MsgValueError;

            }
            auto& aChannelID = *maybe__aChannelID;
            // Sentinel = 'aChannelID'
            if ((!(((&(reader__)))->ReadSentinel(343802792)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint64_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<SocketProcessBridgeParent*>(this))->RecvInitBackgroundDataBridge(std::move(aEndpoint), std::move(aChannelID));
            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 PSocketProcessBridgeParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PSocketProcessBridgeParent::Result
{
    return MsgNotKnown;
}



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

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

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

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

        return {};
    }
    return static_cast<::mozilla::net::PSocketProcessBridgeParent*>(actor);
}

} // namespace IPC
