ipc/ipdl/test/cxx/TestRaceDeadlock.h
author Kan-Ru Chen <kanru@kanru.info>
Tue, 15 Nov 2016 04:26:00 +0100
changeset 322595 39ac4382a2c019178604b90acd816753fe142908
parent 295206 b05438670c104f1064158114abb36667be66ae13
child 450554 09c71a7cf75aeaf2963050e315276fb9a866fd62
permissions -rw-r--r--
Bug 1314254 - Add mozilla::ipc::IPCResult type and convert IPDL handlers to use new return type. r=billm We will use the new type for the generated IPDL message handler prototype to make sure correct error handling method is called. MozReview-Commit-ID: AzVbApxFGZ0

#ifndef mozilla__ipdltest_TestRaceDeadlock_h
#define mozilla__ipdltest_TestRaceDeadlock_h 1

#include "mozilla/_ipdltest/IPDLUnitTests.h"

#include "mozilla/_ipdltest/PTestRaceDeadlockParent.h"
#include "mozilla/_ipdltest/PTestRaceDeadlockChild.h"

namespace mozilla {
namespace _ipdltest {

class TestRaceDeadlockParent :
    public PTestRaceDeadlockParent
{
public:
    TestRaceDeadlockParent();
    virtual ~TestRaceDeadlockParent();

    static bool RunTestInProcesses() { return true; }
    static bool RunTestInThreads() { return true; }

    void Main();

protected:
    virtual bool ShouldContinueFromReplyTimeout() override;

    void Test1();

    virtual mozilla::ipc::IPCResult RecvStartRace() override;
    virtual mozilla::ipc::IPCResult AnswerLose() override;

    virtual mozilla::ipc::RacyInterruptPolicy
    MediateInterruptRace(const MessageInfo& parent,
                         const MessageInfo& child) override;

    virtual void ActorDestroy(ActorDestroyReason why) override
    {
        if (NormalShutdown != why)
            fail("unexpected destruction!");
        passed("ok");
        QuitParent();
    }
};


class TestRaceDeadlockChild :
    public PTestRaceDeadlockChild
{
public:
    TestRaceDeadlockChild();
    virtual ~TestRaceDeadlockChild();

protected:
    virtual mozilla::ipc::IPCResult RecvStartRace() override;

    virtual mozilla::ipc::IPCResult AnswerWin() override;

    virtual mozilla::ipc::IPCResult AnswerRpc() override;

    virtual mozilla::ipc::RacyInterruptPolicy
    MediateInterruptRace(const MessageInfo& parent,
                         const MessageInfo& child) override;

    virtual void ActorDestroy(ActorDestroyReason why) override
    {
        if (NormalShutdown != why)
            fail("unexpected destruction!");
        QuitChild();
    }
};


} // namespace _ipdltest
} // namespace mozilla


#endif // ifndef mozilla__ipdltest_TestRaceDeadlock_h