PTestParent.h:
class PTestParent
{
protected:
virtual bool RecvChildToParent() = 0;
PTest.ipdl: virtual bool RecvBothDirection() = 0;
protocol PTest public:
{ bool SendParentToChild();
child: bool SendBothDirection();
ParentToChild(); };
parent: PTestChild.h:
ChildToParent(); class PTestChlid
both: {
BothDirection(); protected:
}; virtual bool RecvParentToChild() = 0;
virtual bool RecvBothDirection() = 0;
public:
bool SendChildToParent();
bool SendBothDirection();
};
what's actorTestChild.h:
#include <PTestChild.h>
class TestChild : public PTestChild
{
....
virtual bool RecvParentToChild() MOZ_OVERRIDE;
irtual bool RecvBothDirection() MOZ_OVERRIDE;
};
moz.build:
include('/ipc/chromium/chromium-config.mozbuild')
IPDL_SOURCES = [
'ipc/PTest.ipdl',
]
'int32_t' 'uint32_t' 'int64_t' 'nsresult' 'nsString' 'nsCString'
IPDL:
struct Pos
{
int x;
int y;
};
protocol PTest
{
child:
StructData(Pos pos);
};
c++:
class PTestChild
{
virtual bool RecvStructData(const Pos& pos) = 0;
};
protocol PTest
{
child:
ArrayData(int32_t[] array);
};
c++:
class PTestChild
{
virtual bool RecvArrayData(nsTArray<int32_t>&& array) = 0;
};
PTestParent.h:
PTest.ipdl: class PTestParent
sync protocol PTest {
{ protected:
child: virtual bool RecvChildToParent(const int32_t& num, int* ans, bool* result) = 0;
async ParentToChild(); };
parent: PTestChild.h:
sync ChildToParent(int32_t num) class PTestChlid
returns (int ans, bool result); {
both: public:
async BothDirection(); bool SendChildToParent(const int32_t& num, bool* result);
}; };
intr protocol PTest
{
child:
intr IntrParentToChild();
parent:
intr IntrChildToParent();
};
eg:
CallIntrChildToParent() -> AnswerIntrChildToParent()
|
|
AnswerIntrParentToChild() <- CallIntrParentToChild()
check MessageChannel.cpp for detail
prio(normal upto high) protocol PTest
{
child:
prio(high) async AsyncHighParentToChild();
parent:
sync SyncNormalChildToParent();
};
eg:
SyncNormalChildToParent() -> RecvNormalChildToParent()
|
|
RecvAsyncHighParentToChild() <- SendAsyncHighParentToChild()
!!! This is incredibly dangerous. You should make sure the sync-calling code is completely unrelated to the incoming high priority message. !!!
PBrowser.ipdl
prio(normal upto urgent) intr protocol PBrowser
{
UpdateDimensions(...) compress;
};
PTest.ipdl
include protocol PTestSubtree; PTestSubtree.ipdl
sync protocol PTest include protocol PTest;
{ protocol PTestSubtree
manages PTestSubtree; {
child: manager PTest;
async ParentToChild(); child:
parent: //delete from parent to child
//create from child to parent. __delete__();
sync PTestSubtree(int32_t data) ParentToChild();
returns (bool result); };
};
PTestParent.h
class PTestParent
{
virtual bool RecvPTestSubtreeConstructor(PTestSubtreeParent* actor, const int32_t& data, bool* result);
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
virtual PTestSubtreeParent* AllocPTestSubtreeParent(const int32_t& data, bool* result) = 0;
virtual bool DeallocPTestSubtreeParent(PTestSubtreeParent* aActor) = 0;
};
PTestChild.h
class PTestChild
{
PTestSubtreeChild* SendPTestSubtreeConstructor(onst int32_t& data, bool* result);
virtual void ActorDestroy(ActorDestroyReason why) = 0;
virtual PTestSubtreeChild* AllocPTestSubtreeChild(const int32_t& data, bool* result) = 0;
virtual bool DeallocPTestSubtreeChild(PTestSubtreeChild* aActor) = 0;
};
PTest.ipdl
include protocol PTestSubtree; PTestSubtree.ipdl
sync protocol PTest include protocol PTest;
{ protocol PTestSubtree
manages PTestSubtree; {
child: manager PTest;
async ParentToChild(); child:
parent: //delete from parent to child
//create from child to parent. __delete__();
sync PTestSubtree(int32_t data) ParentToChild();
returns (bool result); };
};
PTestSubtreeChild.h
class PTestSubtreeChild
{
virtual bool Recv__delete__();
virtual void ActorDestroy(ActorDestroyReason why) = 0;
};
PTestSubtreeParent.h
class PTestSubtreeParent
{
static bool Send__delete__(PTestSubtreeParent* actor);
virtual void ActorDestroy(ActorDestroyReason why) = 0;
};
Chrome Content
+
|
|
+---+--+----+ +-----------+ | +-----------+ +---+--+----+
|Top-level | | IO | | | IO | |Top-level |
|Protocol | <-----> |MessageLoop| <-----+-----> |MessageLoop| <----> |Protocol |
|MessageLoop| +-----------+ unix +-----------+ |MessageLoop|
+-----------+ domain +-----------+
^ socket ^
+---+--+----+ | + | +---+--+----+
|Top-Level | | | | |Top-level |
|Protocol | <----------+ + +----------> |Protocol |
|MessageLoop| |MessageLoop|
+-----------+ +-----------+