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


#include "mozilla/ipc/PBackgroundParent.h"
#include "mozilla/ipc/PBackgroundChild.h"
#include "mozilla/dom/PTemporaryIPCBlob.h"
#include "mozilla/dom/PTemporaryIPCBlobParent.h"
#include "mozilla/dom/PTemporaryIPCBlobChild.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 {
namespace PTemporaryIPCBlob {

nsresult
CreateEndpoints(
        mozilla::ipc::EndpointProcInfo aParentDestInfo,
        mozilla::ipc::EndpointProcInfo aChildDestInfo,
        mozilla::ipc::Endpoint<::mozilla::dom::PTemporaryIPCBlobParent>* aParent,
        mozilla::ipc::Endpoint<::mozilla::dom::PTemporaryIPCBlobChild>* aChild)
{
    return mozilla::ipc::CreateEndpoints(
        mozilla::ipc::PrivateIPDLInterface(),
        aParentDestInfo, aChildDestInfo, aParent, aChild);
}
mozilla::UniquePtr<IPC::Message>
Msg_FileDesc(IPC::Message::routeid_t routingId)
{
    return IPC::Message::IPDLMessage(routingId, Msg_FileDesc__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>
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));
}
mozilla::UniquePtr<IPC::Message>
Msg_OperationFailed(IPC::Message::routeid_t routingId)
{
    return IPC::Message::IPDLMessage(routingId, Msg_OperationFailed__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>
Msg_OperationDone(IPC::Message::routeid_t routingId)
{
    return IPC::Message::IPDLMessage(routingId, Msg_OperationDone__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));
}

} // namespace PTemporaryIPCBlob
} // namespace dom
} // namespace mozilla

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

MOZ_IMPLICIT IPCBlobOrError::IPCBlobOrError(const IPCBlob& aOther)
{
    new (mozilla::KnownNotNull, ptr_IPCBlob()) IPCBlob(aOther);
    mType = TIPCBlob;
}

MOZ_IMPLICIT IPCBlobOrError::IPCBlobOrError(IPCBlob&& aOther)
{
    new (mozilla::KnownNotNull, ptr_IPCBlob()) IPCBlob(std::move(aOther));
    mType = TIPCBlob;
}

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

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

MOZ_IMPLICIT IPCBlobOrError::IPCBlobOrError(const IPCBlobOrError& aOther)
{
    (aOther).AssertSanity();
    switch ((aOther).type()) {
    case TIPCBlob:
        {
            new (mozilla::KnownNotNull, ptr_IPCBlob()) IPCBlob((aOther).get_IPCBlob());
            break;
        }
    case Tnsresult:
        {
            new (mozilla::KnownNotNull, ptr_nsresult()) nsresult((aOther).get_nsresult());
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    mType = (aOther).type();
}

MOZ_IMPLICIT IPCBlobOrError::IPCBlobOrError(IPCBlobOrError&& aOther)
{
    (aOther).AssertSanity();
    Type t = (aOther).type();
    switch (t) {
    case TIPCBlob:
        {
            new (mozilla::KnownNotNull, ptr_IPCBlob()) IPCBlob(std::move((aOther).get_IPCBlob()));
            (aOther).MaybeDestroy();
            break;
        }
    case Tnsresult:
        {
            new (mozilla::KnownNotNull, ptr_nsresult()) nsresult(std::move((aOther).get_nsresult()));
            (aOther).MaybeDestroy();
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    (aOther).mType = T__None;
    mType = t;
}

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

auto IPCBlobOrError::operator=(const IPCBlob& aRhs) -> IPCBlobOrError&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_IPCBlob()) IPCBlob(aRhs);
    mType = TIPCBlob;
    return (*(this));
}

auto IPCBlobOrError::operator=(IPCBlob&& aRhs) -> IPCBlobOrError&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_IPCBlob()) IPCBlob(std::move(aRhs));
    mType = TIPCBlob;
    return (*(this));
}

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

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

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

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

} // namespace dom
} // namespace mozilla

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

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

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

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

    switch (type) {
    case union__::TIPCBlob:
        {
            auto maybe__tmp = IPC::ReadParam<::mozilla::dom::IPCBlob>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant TIPCBlob of union IPCBlobOrError");
                return {};

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

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

} // namespace IPC
