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


#include "mozilla/dom/PBackgroundFileHandleParent.h"

#include "mozilla/dom/PBackgroundFileRequestParent.h"
#include "mozilla/dom/PBackgroundMutableFileParent.h"
#include "mozilla/dom/PBlobParent.h"

#include "nsIFile.h"
#include "GeckoProfiler.h"

namespace mozilla {
namespace dom {


auto PBackgroundFileHandleParent::RecvPBackgroundFileRequestConstructor(
        PBackgroundFileRequestParent* actor,
        const FileRequestParams& params) -> bool
{
    return true;
}


MOZ_IMPLICIT PBackgroundFileHandleParent::PBackgroundFileHandleParent() :
    mozilla::ipc::IProtocol(mozilla::ipc::ParentSide),
    mState(PBackgroundFileHandle::__Dead)
{
    MOZ_COUNT_CTOR(PBackgroundFileHandleParent);
}

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

auto PBackgroundFileHandleParent::Manager() const -> PBackgroundMutableFileParent*
{
    return static_cast<PBackgroundMutableFileParent*>(IProtocol::Manager());
}

auto PBackgroundFileHandleParent::ManagedPBackgroundFileRequestParent(nsTArray<PBackgroundFileRequestParent*>& aArr) const -> void
{
    (mManagedPBackgroundFileRequestParent).ToArray(aArr);
}

auto PBackgroundFileHandleParent::ManagedPBackgroundFileRequestParent() const -> const ManagedContainer<PBackgroundFileRequestParent>&
{
    return mManagedPBackgroundFileRequestParent;
}

auto PBackgroundFileHandleParent::state() -> PBackgroundFileHandle::State
{
    return mState;
}

auto PBackgroundFileHandleParent::Send__delete__(PBackgroundFileHandleParent* actor) -> bool
{
    if ((!(actor))) {
        return false;
    }

    IPC::Message* msg__ = PBackgroundFileHandle::Msg___delete__((actor)->Id());

    (actor)->Write(actor, msg__, false);
    // Sentinel = 'actor'
    (msg__)->WriteSentinel(875202478);



    if (mozilla::ipc::LoggingEnabledFor("PBackgroundFileHandleParent")) {
        mozilla::ipc::LogMessageForProtocol("PBackgroundFileHandleParent", (actor)->OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
    }
    PROFILER_LABEL("PBackgroundFileHandle", "Msg___delete__", js::ProfileEntry::Category::OTHER);
    if ((!(PBackgroundFileHandle::Transition(Trigger(Trigger::Send, PBackgroundFileHandle::Msg___delete____ID), (&((actor)->mState)))))) {
        NS_WARNING("bad state transition!");
    }

    bool sendok__ = ((actor)->GetIPCChannel())->Send(msg__);

    (actor)->DestroySubtree(Deletion);
    (actor)->DeallocSubtree();
    ((actor)->Manager())->RemoveManagee(PBackgroundFileHandleMsgStart, actor);
    return sendok__;
}

auto PBackgroundFileHandleParent::SendComplete(const bool& aborted) -> bool
{
    IPC::Message* msg__ = PBackgroundFileHandle::Msg_Complete(Id());

    Write(aborted, msg__);
    // Sentinel = 'aborted'
    (msg__)->WriteSentinel(3877028438);




    if (mozilla::ipc::LoggingEnabledFor("PBackgroundFileHandleParent")) {
        mozilla::ipc::LogMessageForProtocol("PBackgroundFileHandleParent", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
    }
    PROFILER_LABEL("PBackgroundFileHandle", "Msg_Complete", js::ProfileEntry::Category::OTHER);
    if ((!(PBackgroundFileHandle::Transition(Trigger(Trigger::Send, PBackgroundFileHandle::Msg_Complete__ID), (&(mState)))))) {
        NS_WARNING("bad state transition!");
    }

    bool sendok__ = (GetIPCChannel())->Send(msg__);
    return sendok__;
}

auto PBackgroundFileHandleParent::RemoveManagee(
        int32_t aProtocolId,
        ProtocolBase* aListener) -> void
{
    switch (aProtocolId) {
    case PBackgroundFileRequestMsgStart:
        {
            PBackgroundFileRequestParent* actor = static_cast<PBackgroundFileRequestParent*>(aListener);
            auto& container = mManagedPBackgroundFileRequestParent;
            MOZ_RELEASE_ASSERT((container).Contains(actor), "actor not managed by this!");

            (container).RemoveEntry(actor);
            DeallocPBackgroundFileRequestParent(actor);
            return;
        }
    default:
        {
            FatalError("unreached");
            return;
        }
    }
}

auto PBackgroundFileHandleParent::OnMessageReceived(const Message& msg__) -> PBackgroundFileHandleParent::Result
{
    switch ((msg__).type()) {
    case PBackgroundFileHandle::Msg_DeleteMe__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PBackgroundFileHandleParent")) {
                mozilla::ipc::LogMessageForProtocol("PBackgroundFileHandleParent", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
            }
            PROFILER_LABEL("PBackgroundFileHandle", "Msg_DeleteMe", js::ProfileEntry::Category::OTHER);

            if ((!(PBackgroundFileHandle::Transition(Trigger(Trigger::Recv, PBackgroundFileHandle::Msg_DeleteMe__ID), (&(mState)))))) {
                NS_WARNING("bad state transition!");
            }
            if ((!(RecvDeleteMe()))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PBackgroundFileHandle::Msg_Finish__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PBackgroundFileHandleParent")) {
                mozilla::ipc::LogMessageForProtocol("PBackgroundFileHandleParent", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
            }
            PROFILER_LABEL("PBackgroundFileHandle", "Msg_Finish", js::ProfileEntry::Category::OTHER);

            if ((!(PBackgroundFileHandle::Transition(Trigger(Trigger::Recv, PBackgroundFileHandle::Msg_Finish__ID), (&(mState)))))) {
                NS_WARNING("bad state transition!");
            }
            if ((!(RecvFinish()))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PBackgroundFileHandle::Msg_Abort__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PBackgroundFileHandleParent")) {
                mozilla::ipc::LogMessageForProtocol("PBackgroundFileHandleParent", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
            }
            PROFILER_LABEL("PBackgroundFileHandle", "Msg_Abort", js::ProfileEntry::Category::OTHER);

            if ((!(PBackgroundFileHandle::Transition(Trigger(Trigger::Recv, PBackgroundFileHandle::Msg_Abort__ID), (&(mState)))))) {
                NS_WARNING("bad state transition!");
            }
            if ((!(RecvAbort()))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PBackgroundFileHandle::Msg_PBackgroundFileRequestConstructor__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PBackgroundFileHandleParent")) {
                mozilla::ipc::LogMessageForProtocol("PBackgroundFileHandleParent", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
            }
            PROFILER_LABEL("PBackgroundFileHandle", "Msg_PBackgroundFileRequestConstructor", js::ProfileEntry::Category::OTHER);

            PickleIterator iter__ = PickleIterator(msg__);
            ActorHandle handle__;
            PBackgroundFileRequestParent* actor;
            FileRequestParams params;

            if ((!(Read((&(handle__)), (&(msg__)), (&(iter__)))))) {
                FatalError("Error deserializing 'ActorHandle'");
                return MsgValueError;
            }
            // Sentinel = 'actor'
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 875202478)))) {
                FatalError("Error deserializing 'ActorHandle'");
                return MsgValueError;
            }
            if ((!(Read((&(params)), (&(msg__)), (&(iter__)))))) {
                FatalError("Error deserializing 'FileRequestParams'");
                return MsgValueError;
            }
            // Sentinel = 'params'
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 1677790004)))) {
                FatalError("Error deserializing 'FileRequestParams'");
                return MsgValueError;
            }
            (msg__).EndRead(iter__);
            if ((!(PBackgroundFileHandle::Transition(Trigger(Trigger::Recv, PBackgroundFileHandle::Msg_PBackgroundFileRequestConstructor__ID), (&(mState)))))) {
                NS_WARNING("bad state transition!");
            }
            actor = AllocPBackgroundFileRequestParent(params);
            if ((!(actor))) {
                NS_WARNING("Error constructing actor PBackgroundFileRequestParent");
                return MsgValueError;
            }
            (actor)->SetId(RegisterID(actor, (handle__).mId));
            (actor)->SetManager(this);
            (actor)->SetIPCChannel(GetIPCChannel());
            (mManagedPBackgroundFileRequestParent).PutEntry(actor);
            (actor)->mState = mozilla::dom::PBackgroundFileRequest::__Start;

            if ((!(RecvPBackgroundFileRequestConstructor(mozilla::Move(actor), mozilla::Move(params))))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PBackgroundFileHandle::Reply___delete____ID:
        {
            return MsgProcessed;
        }
    default:
        {
            return MsgNotKnown;
        }
    }
}

auto PBackgroundFileHandleParent::OnMessageReceived(
        const Message& msg__,
        Message*& reply__) -> PBackgroundFileHandleParent::Result
{
    return MsgNotKnown;
}

auto PBackgroundFileHandleParent::OnCallReceived(
        const Message& msg__,
        Message*& reply__) -> PBackgroundFileHandleParent::Result
{
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
    return MsgNotKnown;
}

auto PBackgroundFileHandleParent::GetProtocolTypeId() -> int32_t
{
    return PBackgroundFileHandleMsgStart;
}

auto PBackgroundFileHandleParent::ProtocolName() const -> const char*
{
    return "PBackgroundFileHandleParent";
}

auto PBackgroundFileHandleParent::DestroySubtree(ActorDestroyReason why) -> void
{
    // Unregister from our manager.
    Unregister(Id());
    SetId(1);

    ActorDestroyReason subtreewhy = (((why) == (Deletion)) || ((why) == (FailedConstructor)) ? AncestorDeletion : why);

    {
        // Recursively shutting down PBackgroundFileRequest kids
        nsTArray<PBackgroundFileRequestParent*> kids;
        // Accumulate kids into a stable structure to iterate over
        ManagedPBackgroundFileRequestParent(kids);
        for (auto& kid : kids) {
            // Guarding against a child removing a sibling from the list during the iteration.
            if ((mManagedPBackgroundFileRequestParent).Contains(kid)) {
                (kid)->DestroySubtree(subtreewhy);
            }
        }
    }

    // Finally, destroy "us".
    ActorDestroy(why);
}

auto PBackgroundFileHandleParent::DeallocSubtree() -> void
{
    {
        // Recursively deleting PBackgroundFileRequest kids
        for (auto iter = (mManagedPBackgroundFileRequestParent).Iter(); (!((iter).Done())); (iter).Next()) {
            (((iter).Get())->GetKey())->DeallocSubtree();
        }

        for (auto iter = (mManagedPBackgroundFileRequestParent).Iter(); (!((iter).Done())); (iter).Next()) {
            DeallocPBackgroundFileRequestParent(((iter).Get())->GetKey());
        }
        (mManagedPBackgroundFileRequestParent).Clear();
    }
}

auto PBackgroundFileHandleParent::Write(
        const FileRequestWriteParams& v__,
        Message* msg__) -> void
{
    Write((v__).offset(), msg__);
    // Sentinel = 'offset'
    (msg__)->WriteSentinel(1369947863);
    Write((v__).data(), msg__);
    // Sentinel = 'data'
    (msg__)->WriteSentinel(843352540);
    Write((v__).dataLength(), msg__);
    // Sentinel = 'dataLength'
    (msg__)->WriteSentinel(959713942);
}

auto PBackgroundFileHandleParent::Read(
        FileRequestWriteParams* v__,
        const Message* msg__,
        PickleIterator* iter__) -> bool
{
    if ((!(Read((&((v__)->offset())), msg__, iter__)))) {
        FatalError("Error deserializing 'offset' (uint64_t) member of 'FileRequestWriteParams'");
        return false;
    }
    // Sentinel = 'offset'
    if ((!((msg__)->ReadSentinel(iter__, 1369947863)))) {
        FatalError("Error deserializing 'offset' (uint64_t) member of 'FileRequestWriteParams'");
        return false;
    }
    if ((!(Read((&((v__)->data())), msg__, iter__)))) {
        FatalError("Error deserializing 'data' (FileRequestData) member of 'FileRequestWriteParams'");
        return false;
    }
    // Sentinel = 'data'
    if ((!((msg__)->ReadSentinel(iter__, 843352540)))) {
        FatalError("Error deserializing 'data' (FileRequestData) member of 'FileRequestWriteParams'");
        return false;
    }
    if ((!(Read((&((v__)->dataLength())), msg__, iter__)))) {
        FatalError("Error deserializing 'dataLength' (uint64_t) member of 'FileRequestWriteParams'");
        return false;
    }
    // Sentinel = 'dataLength'
    if ((!((msg__)->ReadSentinel(iter__, 959713942)))) {
        FatalError("Error deserializing 'dataLength' (uint64_t) member of 'FileRequestWriteParams'");
        return false;
    }
    return true;
}

auto PBackgroundFileHandleParent::Write(
        const FileRequestFlushParams& v__,
        Message* msg__) -> void
{
}

auto PBackgroundFileHandleParent::Read(
        FileRequestFlushParams* v__,
        const Message* msg__,
        PickleIterator* iter__) -> bool
{
    return true;
}

auto PBackgroundFileHandleParent::Write(
        const FileRequestTruncateParams& v__,
        Message* msg__) -> void
{
    Write((v__).offset(), msg__);
    // Sentinel = 'offset'
    (msg__)->WriteSentinel(1369947863);
}

auto PBackgroundFileHandleParent::Read(
        FileRequestTruncateParams* v__,
        const Message* msg__,
        PickleIterator* iter__) -> bool
{
    if ((!(Read((&((v__)->offset())), msg__, iter__)))) {
        FatalError("Error deserializing 'offset' (uint64_t) member of 'FileRequestTruncateParams'");
        return false;
    }
    // Sentinel = 'offset'
    if ((!((msg__)->ReadSentinel(iter__, 1369947863)))) {
        FatalError("Error deserializing 'offset' (uint64_t) member of 'FileRequestTruncateParams'");
        return false;
    }
    return true;
}

auto PBackgroundFileHandleParent::Write(
        const FileRequestBlobData& v__,
        Message* msg__) -> void
{
    Write((v__).blobParent(), msg__, false);
    // Sentinel = 'blob'
    (msg__)->WriteSentinel(1963585077);
    // skipping actor field that's meaningless on this side
}

auto PBackgroundFileHandleParent::Read(
        FileRequestBlobData* v__,
        const Message* msg__,
        PickleIterator* iter__) -> bool
{
    if ((!(Read((&((v__)->blobParent())), msg__, iter__, false)))) {
        FatalError("Error deserializing 'blobParent' (PBlob) member of 'FileRequestBlobData'");
        return false;
    }
    // Sentinel = 'blob'
    if ((!((msg__)->ReadSentinel(iter__, 1963585077)))) {
        FatalError("Error deserializing 'blobParent' (PBlob) member of 'FileRequestBlobData'");
        return false;
    }
    // skipping actor field that's meaningless on this side
    return true;
}

auto PBackgroundFileHandleParent::Write(
        const FileRequestGetFileParams& v__,
        Message* msg__) -> void
{
}

auto PBackgroundFileHandleParent::Read(
        FileRequestGetFileParams* v__,
        const Message* msg__,
        PickleIterator* iter__) -> bool
{
    return true;
}

auto PBackgroundFileHandleParent::Write(
        const FileRequestGetMetadataParams& v__,
        Message* msg__) -> void
{
    Write((v__).size(), msg__);
    // Sentinel = 'size'
    (msg__)->WriteSentinel(931048223);
    Write((v__).lastModified(), msg__);
    // Sentinel = 'lastModified'
    (msg__)->WriteSentinel(3456113257);
}

auto PBackgroundFileHandleParent::Read(
        FileRequestGetMetadataParams* v__,
        const Message* msg__,
        PickleIterator* iter__) -> bool
{
    if ((!(Read((&((v__)->size())), msg__, iter__)))) {
        FatalError("Error deserializing 'size' (bool) member of 'FileRequestGetMetadataParams'");
        return false;
    }
    // Sentinel = 'size'
    if ((!((msg__)->ReadSentinel(iter__, 931048223)))) {
        FatalError("Error deserializing 'size' (bool) member of 'FileRequestGetMetadataParams'");
        return false;
    }
    if ((!(Read((&((v__)->lastModified())), msg__, iter__)))) {
        FatalError("Error deserializing 'lastModified' (bool) member of 'FileRequestGetMetadataParams'");
        return false;
    }
    // Sentinel = 'lastModified'
    if ((!((msg__)->ReadSentinel(iter__, 3456113257)))) {
        FatalError("Error deserializing 'lastModified' (bool) member of 'FileRequestGetMetadataParams'");
        return false;
    }
    return true;
}

auto PBackgroundFileHandleParent::Write(
        const FileRequestStringData& v__,
        Message* msg__) -> void
{
    Write((v__).string(), msg__);
    // Sentinel = 'string'
    (msg__)->WriteSentinel(2752301125);
}

auto PBackgroundFileHandleParent::Read(
        FileRequestStringData* v__,
        const Message* msg__,
        PickleIterator* iter__) -> bool
{
    if ((!(Read((&((v__)->string())), msg__, iter__)))) {
        FatalError("Error deserializing 'string' (nsCString) member of 'FileRequestStringData'");
        return false;
    }
    // Sentinel = 'string'
    if ((!((msg__)->ReadSentinel(iter__, 2752301125)))) {
        FatalError("Error deserializing 'string' (nsCString) member of 'FileRequestStringData'");
        return false;
    }
    return true;
}

auto PBackgroundFileHandleParent::Write(
        const FileRequestData& v__,
        Message* msg__) -> void
{
    typedef FileRequestData type__;
    Write(int((v__).type()), msg__);
    // Sentinel = 'FileRequestData'
    (msg__)->WriteSentinel(2371456462);

    switch ((v__).type()) {
    case type__::TFileRequestStringData:
        {
            Write((v__).get_FileRequestStringData(), msg__);
            // Sentinel = 'TFileRequestStringData'
            (msg__)->WriteSentinel(3179014272);
            return;
        }
    case type__::TFileRequestBlobData:
        {
            Write((v__).get_FileRequestBlobData(), msg__);
            // Sentinel = 'TFileRequestBlobData'
            (msg__)->WriteSentinel(3085301148);
            return;
        }
    default:
        {
            FatalError("unknown union type");
            return;
        }
    }
}

auto PBackgroundFileHandleParent::Read(
        FileRequestData* v__,
        const Message* msg__,
        PickleIterator* iter__) -> bool
{
    typedef FileRequestData type__;
    int type;
    if ((!(Read((&(type)), msg__, iter__)))) {
        mozilla::ipc::UnionTypeReadError("FileRequestData");
        return false;
    }
    // Sentinel = 'FileRequestData'
    if ((!((msg__)->ReadSentinel(iter__, 2371456462)))) {
        mozilla::ipc::UnionTypeReadError("FileRequestData");
        return false;
    }

    switch (type) {
    case type__::TFileRequestStringData:
        {
            FileRequestStringData tmp = FileRequestStringData();
            (*(v__)) = tmp;
            if ((!(Read((&((v__)->get_FileRequestStringData())), msg__, iter__)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            // Sentinel = 'TFileRequestStringData'
            if ((!((msg__)->ReadSentinel(iter__, 3179014272)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            return true;
        }
    case type__::TFileRequestBlobData:
        {
            FileRequestBlobData tmp = FileRequestBlobData();
            (*(v__)) = tmp;
            if ((!(Read((&((v__)->get_FileRequestBlobData())), msg__, iter__)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            // Sentinel = 'TFileRequestBlobData'
            if ((!((msg__)->ReadSentinel(iter__, 3085301148)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            return true;
        }
    default:
        {
            FatalError("unknown union type");
            return false;
        }
    }
}

auto PBackgroundFileHandleParent::Write(
        const FileRequestReadParams& v__,
        Message* msg__) -> void
{
    Write((v__).offset(), msg__);
    // Sentinel = 'offset'
    (msg__)->WriteSentinel(1369947863);
    Write((v__).size(), msg__);
    // Sentinel = 'size'
    (msg__)->WriteSentinel(931048223);
}

auto PBackgroundFileHandleParent::Read(
        FileRequestReadParams* v__,
        const Message* msg__,
        PickleIterator* iter__) -> bool
{
    if ((!(Read((&((v__)->offset())), msg__, iter__)))) {
        FatalError("Error deserializing 'offset' (uint64_t) member of 'FileRequestReadParams'");
        return false;
    }
    // Sentinel = 'offset'
    if ((!((msg__)->ReadSentinel(iter__, 1369947863)))) {
        FatalError("Error deserializing 'offset' (uint64_t) member of 'FileRequestReadParams'");
        return false;
    }
    if ((!(Read((&((v__)->size())), msg__, iter__)))) {
        FatalError("Error deserializing 'size' (uint64_t) member of 'FileRequestReadParams'");
        return false;
    }
    // Sentinel = 'size'
    if ((!((msg__)->ReadSentinel(iter__, 931048223)))) {
        FatalError("Error deserializing 'size' (uint64_t) member of 'FileRequestReadParams'");
        return false;
    }
    return true;
}

auto PBackgroundFileHandleParent::Write(
        const PBackgroundFileRequestParent* v__,
        Message* msg__,
        bool nullable__) -> void
{
    int32_t id;
    if ((!(v__))) {
        if ((!(nullable__))) {
            FatalError("NULL actor value passed to non-nullable param");
        }
        id = 0;
    }
    else {
        id = (v__)->Id();
        if ((1) == (id)) {
            FatalError("actor has been |delete|d");
        }
    }

    Write(id, msg__);
}

auto PBackgroundFileHandleParent::Read(
        PBackgroundFileRequestParent** v__,
        const Message* msg__,
        PickleIterator* iter__,
        bool nullable__) -> bool
{
    Maybe<mozilla::ipc::IProtocol*> actor = ReadActor(msg__, iter__, nullable__, "PBackgroundFileRequest", PBackgroundFileRequestMsgStart);
    if ((actor).isNothing()) {
        return false;
    }

    (*(v__)) = static_cast<PBackgroundFileRequestParent*>((actor).value());
    return true;
}

auto PBackgroundFileHandleParent::Write(
        const PBlobParent* v__,
        Message* msg__,
        bool nullable__) -> void
{
    int32_t id;
    if ((!(v__))) {
        if ((!(nullable__))) {
            FatalError("NULL actor value passed to non-nullable param");
        }
        id = 0;
    }
    else {
        id = (v__)->Id();
        if ((1) == (id)) {
            FatalError("actor has been |delete|d");
        }
    }

    Write(id, msg__);
}

auto PBackgroundFileHandleParent::Read(
        PBlobParent** v__,
        const Message* msg__,
        PickleIterator* iter__,
        bool nullable__) -> bool
{
    Maybe<mozilla::ipc::IProtocol*> actor = ReadActor(msg__, iter__, nullable__, "PBlob", PBlobMsgStart);
    if ((actor).isNothing()) {
        return false;
    }

    (*(v__)) = static_cast<PBlobParent*>((actor).value());
    return true;
}

auto PBackgroundFileHandleParent::Write(
        const PBackgroundFileHandleParent* v__,
        Message* msg__,
        bool nullable__) -> void
{
    int32_t id;
    if ((!(v__))) {
        if ((!(nullable__))) {
            FatalError("NULL actor value passed to non-nullable param");
        }
        id = 0;
    }
    else {
        id = (v__)->Id();
        if ((1) == (id)) {
            FatalError("actor has been |delete|d");
        }
    }

    Write(id, msg__);
}

auto PBackgroundFileHandleParent::Read(
        PBackgroundFileHandleParent** v__,
        const Message* msg__,
        PickleIterator* iter__,
        bool nullable__) -> bool
{
    Maybe<mozilla::ipc::IProtocol*> actor = ReadActor(msg__, iter__, nullable__, "PBackgroundFileHandle", PBackgroundFileHandleMsgStart);
    if ((actor).isNothing()) {
        return false;
    }

    (*(v__)) = static_cast<PBackgroundFileHandleParent*>((actor).value());
    return true;
}

auto PBackgroundFileHandleParent::Write(
        const FileRequestParams& v__,
        Message* msg__) -> void
{
    typedef FileRequestParams type__;
    Write(int((v__).type()), msg__);
    // Sentinel = 'FileRequestParams'
    (msg__)->WriteSentinel(3744650970);

    switch ((v__).type()) {
    case type__::TFileRequestGetMetadataParams:
        {
            Write((v__).get_FileRequestGetMetadataParams(), msg__);
            // Sentinel = 'TFileRequestGetMetadataParams'
            (msg__)->WriteSentinel(1166774555);
            return;
        }
    case type__::TFileRequestReadParams:
        {
            Write((v__).get_FileRequestReadParams(), msg__);
            // Sentinel = 'TFileRequestReadParams'
            (msg__)->WriteSentinel(1685693405);
            return;
        }
    case type__::TFileRequestWriteParams:
        {
            Write((v__).get_FileRequestWriteParams(), msg__);
            // Sentinel = 'TFileRequestWriteParams'
            (msg__)->WriteSentinel(2147439215);
            return;
        }
    case type__::TFileRequestTruncateParams:
        {
            Write((v__).get_FileRequestTruncateParams(), msg__);
            // Sentinel = 'TFileRequestTruncateParams'
            (msg__)->WriteSentinel(153458995);
            return;
        }
    case type__::TFileRequestFlushParams:
        {
            Write((v__).get_FileRequestFlushParams(), msg__);
            // Sentinel = 'TFileRequestFlushParams'
            (msg__)->WriteSentinel(258874732);
            return;
        }
    case type__::TFileRequestGetFileParams:
        {
            Write((v__).get_FileRequestGetFileParams(), msg__);
            // Sentinel = 'TFileRequestGetFileParams'
            (msg__)->WriteSentinel(3815923694);
            return;
        }
    default:
        {
            FatalError("unknown union type");
            return;
        }
    }
}

auto PBackgroundFileHandleParent::Read(
        FileRequestParams* v__,
        const Message* msg__,
        PickleIterator* iter__) -> bool
{
    typedef FileRequestParams type__;
    int type;
    if ((!(Read((&(type)), msg__, iter__)))) {
        mozilla::ipc::UnionTypeReadError("FileRequestParams");
        return false;
    }
    // Sentinel = 'FileRequestParams'
    if ((!((msg__)->ReadSentinel(iter__, 3744650970)))) {
        mozilla::ipc::UnionTypeReadError("FileRequestParams");
        return false;
    }

    switch (type) {
    case type__::TFileRequestGetMetadataParams:
        {
            FileRequestGetMetadataParams tmp = FileRequestGetMetadataParams();
            (*(v__)) = tmp;
            if ((!(Read((&((v__)->get_FileRequestGetMetadataParams())), msg__, iter__)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            // Sentinel = 'TFileRequestGetMetadataParams'
            if ((!((msg__)->ReadSentinel(iter__, 1166774555)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            return true;
        }
    case type__::TFileRequestReadParams:
        {
            FileRequestReadParams tmp = FileRequestReadParams();
            (*(v__)) = tmp;
            if ((!(Read((&((v__)->get_FileRequestReadParams())), msg__, iter__)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            // Sentinel = 'TFileRequestReadParams'
            if ((!((msg__)->ReadSentinel(iter__, 1685693405)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            return true;
        }
    case type__::TFileRequestWriteParams:
        {
            FileRequestWriteParams tmp = FileRequestWriteParams();
            (*(v__)) = tmp;
            if ((!(Read((&((v__)->get_FileRequestWriteParams())), msg__, iter__)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            // Sentinel = 'TFileRequestWriteParams'
            if ((!((msg__)->ReadSentinel(iter__, 2147439215)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            return true;
        }
    case type__::TFileRequestTruncateParams:
        {
            FileRequestTruncateParams tmp = FileRequestTruncateParams();
            (*(v__)) = tmp;
            if ((!(Read((&((v__)->get_FileRequestTruncateParams())), msg__, iter__)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            // Sentinel = 'TFileRequestTruncateParams'
            if ((!((msg__)->ReadSentinel(iter__, 153458995)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            return true;
        }
    case type__::TFileRequestFlushParams:
        {
            FileRequestFlushParams tmp = FileRequestFlushParams();
            (*(v__)) = tmp;
            if ((!(Read((&((v__)->get_FileRequestFlushParams())), msg__, iter__)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            // Sentinel = 'TFileRequestFlushParams'
            if ((!((msg__)->ReadSentinel(iter__, 258874732)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            return true;
        }
    case type__::TFileRequestGetFileParams:
        {
            FileRequestGetFileParams tmp = FileRequestGetFileParams();
            (*(v__)) = tmp;
            if ((!(Read((&((v__)->get_FileRequestGetFileParams())), msg__, iter__)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            // Sentinel = 'TFileRequestGetFileParams'
            if ((!((msg__)->ReadSentinel(iter__, 3815923694)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            return true;
        }
    default:
        {
            FatalError("unknown union type");
            return false;
        }
    }
}



} // namespace dom
} // namespace mozilla
