ipc/ipdl/test/cxx/TestBadActor.h
author Nathan Froyd <froydnj@mozilla.com>
Mon, 23 Apr 2018 14:13:36 -0400
changeset 415151 52f24d629711a20bf2f9717a41ae406bc6489f94
parent 324530 739730a68de6025571735067a1f956fa28939a2d
child 450554 09c71a7cf75aeaf2963050e315276fb9a866fd62
permissions -rw-r--r--
Bug 1451363 - part 5 - remove ProtocolName virtual function; r=mccr8 ProtocolName() is only used for producing error messages and annotating crash reports. But examining actual crash reports that would have used the result of ProtocolName() indicates that we can always tell what the erroring protocol is due to the stack backtrace. So having this virtual function around just provides duplicate information, and it takes up too much space in the vtable besides. Let's get rid of it.

#ifndef mozilla__ipdltest_TestBadActor_h
#define mozilla__ipdltest_TestBadActor_h

#include "mozilla/_ipdltest/IPDLUnitTests.h"

#include "mozilla/_ipdltest/PTestBadActorParent.h"
#include "mozilla/_ipdltest/PTestBadActorChild.h"

#include "mozilla/_ipdltest/PTestBadActorSubParent.h"
#include "mozilla/_ipdltest/PTestBadActorSubChild.h"

namespace mozilla {
namespace _ipdltest {

class TestBadActorParent
  : public PTestBadActorParent
{
public:
  TestBadActorParent() { }
  virtual ~TestBadActorParent() { }

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

  void Main();

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

  virtual void HandleFatalError(const char* aErrorMsg) const override;

  virtual PTestBadActorSubParent*
  AllocPTestBadActorSubParent() override;

  virtual bool
  DeallocPTestBadActorSubParent(PTestBadActorSubParent* actor) override {
    delete actor;
    return true;
  }
};

class TestBadActorSubParent
  : public PTestBadActorSubParent
{
public:
  TestBadActorSubParent() { }
  virtual ~TestBadActorSubParent() { }

protected:
  virtual void ActorDestroy(ActorDestroyReason why) override {}
  virtual mozilla::ipc::IPCResult RecvPing() override;
};

class TestBadActorChild
  : public PTestBadActorChild
{
public:
  TestBadActorChild() { }
  virtual ~TestBadActorChild() { }

protected:
  virtual PTestBadActorSubChild*
  AllocPTestBadActorSubChild();

  virtual bool
  DeallocPTestBadActorSubChild(PTestBadActorSubChild* actor)
  {
    delete actor;
    return true;
  }

  virtual mozilla::ipc::IPCResult
  RecvPTestBadActorSubConstructor(PTestBadActorSubChild* actor);
};

class TestBadActorSubChild
  : public PTestBadActorSubChild
{
public:
  TestBadActorSubChild() { }
  virtual ~TestBadActorSubChild() { }
};

} // namespace _ipdltest
} // namespace mozilla

#endif // mozilla__ipdltest_TestBadActor_h