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


#include "mozilla/dom/PContentParent.h"
#include "mozilla/dom/PContentChild.h"
#include "mozilla/devtools/PHeapSnapshotTempFileHelper.h"
#include "mozilla/devtools/PHeapSnapshotTempFileHelperParent.h"
#include "mozilla/devtools/PHeapSnapshotTempFileHelperChild.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 devtools {
namespace PHeapSnapshotTempFileHelper {

nsresult
CreateEndpoints(
        mozilla::ipc::EndpointProcInfo aParentDestInfo,
        mozilla::ipc::EndpointProcInfo aChildDestInfo,
        mozilla::ipc::Endpoint<::mozilla::devtools::PHeapSnapshotTempFileHelperParent>* aParent,
        mozilla::ipc::Endpoint<::mozilla::devtools::PHeapSnapshotTempFileHelperChild>* aChild)
{
    return mozilla::ipc::CreateEndpoints(
        mozilla::ipc::PrivateIPDLInterface(),
        aParentDestInfo, aChildDestInfo, aParent, aChild);
}
mozilla::UniquePtr<IPC::Message>
Msg_OpenHeapSnapshotTempFile(IPC::Message::routeid_t routingId)
{
    return IPC::Message::IPDLMessage(routingId, Msg_OpenHeapSnapshotTempFile__ID, 0, IPC::Message::HeaderFlags(IPC::Message::NOT_NESTED, IPC::Message::NORMAL_PRIORITY, IPC::Message::COMPRESSION_NONE, IPC::Message::EAGER_SEND, IPC::Message::NOT_CONSTRUCTOR, IPC::Message::SYNC, IPC::Message::NOT_REPLY));
}
mozilla::UniquePtr<IPC::Message>
Reply_OpenHeapSnapshotTempFile(IPC::Message::routeid_t routingId)
{
    return IPC::Message::IPDLMessage(routingId, Reply_OpenHeapSnapshotTempFile__ID, 0, IPC::Message::HeaderFlags(IPC::Message::NOT_NESTED, IPC::Message::NORMAL_PRIORITY, IPC::Message::COMPRESSION_NONE, IPC::Message::EAGER_SEND, IPC::Message::NOT_CONSTRUCTOR, IPC::Message::SYNC, IPC::Message::REPLY));
}
mozilla::UniquePtr<IPC::Message>
Msg___delete__(IPC::Message::routeid_t routingId)
{
    return IPC::Message::IPDLMessage(routingId, Msg___delete____ID, 0, IPC::Message::HeaderFlags(IPC::Message::NOT_NESTED, IPC::Message::NORMAL_PRIORITY, IPC::Message::COMPRESSION_NONE, IPC::Message::EAGER_SEND, IPC::Message::NOT_CONSTRUCTOR, IPC::Message::ASYNC, IPC::Message::NOT_REPLY));
}
mozilla::UniquePtr<IPC::Message>
Reply___delete__(IPC::Message::routeid_t routingId)
{
    return IPC::Message::IPDLMessage(routingId, Reply___delete____ID, 0, IPC::Message::HeaderFlags(IPC::Message::NOT_NESTED, IPC::Message::NORMAL_PRIORITY, IPC::Message::COMPRESSION_NONE, IPC::Message::EAGER_SEND, IPC::Message::NOT_CONSTRUCTOR, IPC::Message::ASYNC, IPC::Message::REPLY));
}

} // namespace PHeapSnapshotTempFileHelper
} // namespace devtools
} // namespace mozilla

//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |struct OpenedFile|
//
namespace mozilla {
namespace devtools {
} // namespace devtools
} // namespace mozilla

namespace IPC {
auto ParamTraits<::mozilla::devtools::OpenedFile>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, (aVar).path());
    // Sentinel = 'path'
    (aWriter)->WriteSentinel(70713774);
    IPC::WriteParam(aWriter, (aVar).snapshotId());
    // Sentinel = 'snapshotId'
    (aWriter)->WriteSentinel(390464542);
    IPC::WriteParam(aWriter, (aVar).descriptor());
    // Sentinel = 'descriptor'
    (aWriter)->WriteSentinel(384894016);
}

auto ParamTraits<::mozilla::devtools::OpenedFile>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    auto maybe___path = IPC::ReadParam<::nsString>(aReader);
    if (!maybe___path) {
        aReader->FatalError("Error deserializing 'path' (nsString) member of 'OpenedFile'");
        return {};

    }
    auto& _path = *maybe___path;
    // Sentinel = 'path'
    if ((!((aReader)->ReadSentinel(70713774)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'path' (nsString) member of 'OpenedFile'");
        return {};
    }
    auto maybe___snapshotId = IPC::ReadParam<::nsString>(aReader);
    if (!maybe___snapshotId) {
        aReader->FatalError("Error deserializing 'snapshotId' (nsString) member of 'OpenedFile'");
        return {};

    }
    auto& _snapshotId = *maybe___snapshotId;
    // Sentinel = 'snapshotId'
    if ((!((aReader)->ReadSentinel(390464542)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'snapshotId' (nsString) member of 'OpenedFile'");
        return {};
    }
    auto maybe___descriptor = IPC::ReadParam<::mozilla::ipc::FileDescriptor>(aReader);
    if (!maybe___descriptor) {
        aReader->FatalError("Error deserializing 'descriptor' (FileDescriptor) member of 'OpenedFile'");
        return {};

    }
    auto& _descriptor = *maybe___descriptor;
    // Sentinel = 'descriptor'
    if ((!((aReader)->ReadSentinel(384894016)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'descriptor' (FileDescriptor) member of 'OpenedFile'");
        return {};
    }
    IPC::ReadResult<paramType> result__{
            std::in_place,
            std::move(_path),
            std::move(_snapshotId),
            std::move(_descriptor)};
    return result__;
}

} // namespace IPC

//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |union OpenHeapSnapshotTempFileResponse|
//
namespace mozilla {
namespace devtools {
auto OpenHeapSnapshotTempFileResponse::MaybeDestroy() -> void
{
    if ((mType) == (T__None)) {
        return;
    }
    switch (mType) {
    case Tnsresult:
        {
            (ptr_nsresult())->~nsresult__tdef();
            break;
        }
    case TOpenedFile:
        {
            (ptr_OpenedFile())->~OpenedFile__tdef();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("not reached");
            break;
        }
    }
}

MOZ_IMPLICIT OpenHeapSnapshotTempFileResponse::OpenHeapSnapshotTempFileResponse(const nsresult& aOther)
{
    new (mozilla::KnownNotNull, ptr_nsresult()) nsresult(aOther);
    mType = Tnsresult;
}

MOZ_IMPLICIT OpenHeapSnapshotTempFileResponse::OpenHeapSnapshotTempFileResponse(nsresult&& aOther)
{
    new (mozilla::KnownNotNull, ptr_nsresult()) nsresult(std::move(aOther));
    mType = Tnsresult;
}

MOZ_IMPLICIT OpenHeapSnapshotTempFileResponse::OpenHeapSnapshotTempFileResponse(const OpenedFile& aOther)
{
    new (mozilla::KnownNotNull, ptr_OpenedFile()) OpenedFile(aOther);
    mType = TOpenedFile;
}

MOZ_IMPLICIT OpenHeapSnapshotTempFileResponse::OpenHeapSnapshotTempFileResponse(OpenedFile&& aOther)
{
    new (mozilla::KnownNotNull, ptr_OpenedFile()) OpenedFile(std::move(aOther));
    mType = TOpenedFile;
}

MOZ_IMPLICIT OpenHeapSnapshotTempFileResponse::OpenHeapSnapshotTempFileResponse(const OpenHeapSnapshotTempFileResponse& aOther)
{
    (aOther).AssertSanity();
    switch ((aOther).type()) {
    case Tnsresult:
        {
            new (mozilla::KnownNotNull, ptr_nsresult()) nsresult((aOther).get_nsresult());
            break;
        }
    case TOpenedFile:
        {
            new (mozilla::KnownNotNull, ptr_OpenedFile()) OpenedFile((aOther).get_OpenedFile());
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    mType = (aOther).type();
}

MOZ_IMPLICIT OpenHeapSnapshotTempFileResponse::OpenHeapSnapshotTempFileResponse(OpenHeapSnapshotTempFileResponse&& aOther)
{
    (aOther).AssertSanity();
    Type t = (aOther).type();
    switch (t) {
    case Tnsresult:
        {
            new (mozilla::KnownNotNull, ptr_nsresult()) nsresult(std::move((aOther).get_nsresult()));
            (aOther).MaybeDestroy();
            break;
        }
    case TOpenedFile:
        {
            new (mozilla::KnownNotNull, ptr_OpenedFile()) OpenedFile(std::move((aOther).get_OpenedFile()));
            (aOther).MaybeDestroy();
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    (aOther).mType = T__None;
    mType = t;
}

OpenHeapSnapshotTempFileResponse::~OpenHeapSnapshotTempFileResponse()
{
    MaybeDestroy();
}

auto OpenHeapSnapshotTempFileResponse::operator=(const nsresult& aRhs) -> OpenHeapSnapshotTempFileResponse&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_nsresult()) nsresult(aRhs);
    mType = Tnsresult;
    return (*(this));
}

auto OpenHeapSnapshotTempFileResponse::operator=(nsresult&& aRhs) -> OpenHeapSnapshotTempFileResponse&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_nsresult()) nsresult(std::move(aRhs));
    mType = Tnsresult;
    return (*(this));
}

auto OpenHeapSnapshotTempFileResponse::operator=(const OpenedFile& aRhs) -> OpenHeapSnapshotTempFileResponse&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_OpenedFile()) OpenedFile(aRhs);
    mType = TOpenedFile;
    return (*(this));
}

auto OpenHeapSnapshotTempFileResponse::operator=(OpenedFile&& aRhs) -> OpenHeapSnapshotTempFileResponse&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_OpenedFile()) OpenedFile(std::move(aRhs));
    mType = TOpenedFile;
    return (*(this));
}

auto OpenHeapSnapshotTempFileResponse::operator=(const OpenHeapSnapshotTempFileResponse& aRhs) -> OpenHeapSnapshotTempFileResponse&
{
    (aRhs).AssertSanity();
    Type t = (aRhs).type();
    switch (t) {
    case Tnsresult:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_nsresult()) nsresult((aRhs).get_nsresult());
            break;
        }
    case TOpenedFile:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_OpenedFile()) OpenedFile((aRhs).get_OpenedFile());
            break;
        }
    case T__None:
        {
            MaybeDestroy();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            break;
        }
    }
    mType = t;
    return (*(this));
}

auto OpenHeapSnapshotTempFileResponse::operator=(OpenHeapSnapshotTempFileResponse&& aRhs) -> OpenHeapSnapshotTempFileResponse&
{
    (aRhs).AssertSanity();
    Type t = (aRhs).type();
    switch (t) {
    case Tnsresult:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_nsresult()) nsresult(std::move((aRhs).get_nsresult()));
            (aRhs).MaybeDestroy();
            break;
        }
    case TOpenedFile:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_OpenedFile()) OpenedFile(std::move((aRhs).get_OpenedFile()));
            (aRhs).MaybeDestroy();
            break;
        }
    case T__None:
        {
            MaybeDestroy();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            break;
        }
    }
    (aRhs).mType = T__None;
    mType = t;
    return (*(this));
}

} // namespace devtools
} // namespace mozilla

namespace IPC {
auto ParamTraits<::mozilla::devtools::OpenHeapSnapshotTempFileResponse>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    typedef ::mozilla::devtools::OpenHeapSnapshotTempFileResponse union__;
    int type = (aVar).type();
    IPC::WriteParam(aWriter, type);
    // Sentinel = 'OpenHeapSnapshotTempFileResponse'
    (aWriter)->WriteSentinel(3480882374);

    switch (type) {
    case union__::Tnsresult:
        {
            IPC::WriteParam(aWriter, (aVar).get_nsresult());
            // Sentinel = 'Tnsresult'
            (aWriter)->WriteSentinel(313394133);
            return;
        }
    case union__::TOpenedFile:
        {
            IPC::WriteParam(aWriter, (aVar).get_OpenedFile());
            // Sentinel = 'TOpenedFile'
            (aWriter)->WriteSentinel(414778416);
            return;
        }
    default:
        {
            aWriter->FatalError("unknown variant of union OpenHeapSnapshotTempFileResponse");
            return;
        }
    }
}

auto ParamTraits<::mozilla::devtools::OpenHeapSnapshotTempFileResponse>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    typedef ::mozilla::devtools::OpenHeapSnapshotTempFileResponse union__;
    auto maybe__type = IPC::ReadParam<int>(aReader);
    if (!maybe__type) {
        aReader->FatalError("Error deserializing type of union OpenHeapSnapshotTempFileResponse");
        return {};

    }
    auto& type = *maybe__type;
    // Sentinel = 'OpenHeapSnapshotTempFileResponse'
    if ((!((aReader)->ReadSentinel(3480882374)))) {
        mozilla::ipc::SentinelReadError("Error deserializing type of union OpenHeapSnapshotTempFileResponse");
        return {};
    }

    switch (type) {
    case union__::Tnsresult:
        {
            auto maybe__tmp = IPC::ReadParam<::nsresult>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant Tnsresult of union OpenHeapSnapshotTempFileResponse");
                return {};

            }
            auto& tmp = *maybe__tmp;
            // Sentinel = 'Tnsresult'
            if ((!((aReader)->ReadSentinel(313394133)))) {
                mozilla::ipc::SentinelReadError("Error deserializing variant Tnsresult of union OpenHeapSnapshotTempFileResponse");
                return {};
            }
            return std::move(tmp);
        }
    case union__::TOpenedFile:
        {
            auto maybe__tmp = IPC::ReadParam<::mozilla::devtools::OpenedFile>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant TOpenedFile of union OpenHeapSnapshotTempFileResponse");
                return {};

            }
            auto& tmp = *maybe__tmp;
            // Sentinel = 'TOpenedFile'
            if ((!((aReader)->ReadSentinel(414778416)))) {
                mozilla::ipc::SentinelReadError("Error deserializing variant TOpenedFile of union OpenHeapSnapshotTempFileResponse");
                return {};
            }
            return std::move(tmp);
        }
    default:
        {
            aReader->FatalError("unknown variant of union OpenHeapSnapshotTempFileResponse");
            return {};
        }
    }
}

} // namespace IPC
