IPDL/Five minute example: Difference between revisions

Line 132: Line 132:


== Create the child process's main thread ==
== Create the child process's main thread ==
The child process's main thread will hook up the TestChild actor to an IPC channel.


Create the files <code>ipc/test-harness/TestThreadChild.h</code> and <code>ipc/test-harness/TestThreadChild.cpp</code> with the following content.
Create the files <code>ipc/test-harness/TestThreadChild.h</code> and <code>ipc/test-harness/TestThreadChild.cpp</code> with the following content.
// TestThreadChild.h
#ifndef mozilla_test_TestThreadChild_h
#define mozilla_test_TestThreadChild_h
#include "mozilla/ipc/GeckoThread.h"
#include "mozilla/test/TestChild.h"
namespace mozilla {
namespace test {
class TestThreadChild : public mozilla::ipc::GeckoThread
{
public:
    TestThreadChild();
    ~TestThreadChild();
protected:
    virtual void Init();
    virtual void CleanUp();
private:
    TestChild mChild;
};
} // namespace test
} // namespace mozilla
#endif // ifndef mozilla_test_TestThreadChild_h
// TestThreadChild.cpp
#include "mozilla/test/TestThreadChild.h"
using mozilla::test::TestThreadChild;
using mozilla::ipc::GeckoThread;
TestThreadChild::TestThreadChild() :
    GeckoThread()
{
}
TestThreadChild::~TestThreadChild()
{
}
void
TestThreadChild::Init()
{
    GeckoThread::Init();
    mChild.Open(channel(), owner_loop());
}
void
TestThreadChild::CleanUp()
{
    GeckoThread::CleanUp();
    mChild.Close();
}
Hook these into your build and check that everything still compiles.
Confirmed users
699

edits