Bug 792652 - Add mSide to IProtocol (r=dvander)
This patch adds a field to hold ParentSide/ChildSide state. Useful for
later changes.
--- a/ipc/glue/ProtocolUtils.cpp
+++ b/ipc/glue/ProtocolUtils.cpp
@@ -48,18 +48,19 @@ MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLAT
::LocalFree)
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPSecurityDescriptor, \
RemovePointer<PSECURITY_DESCRIPTOR>::Type, \
::LocalFree)
#endif
namespace ipc {
-IToplevelProtocol::IToplevelProtocol(ProtocolId aProtoId)
- : mProtocolId(aProtoId)
+IToplevelProtocol::IToplevelProtocol(ProtocolId aProtoId, Side aSide)
+ : IProtocol(aSide),
+ mProtocolId(aProtoId)
{
}
IToplevelProtocol::~IToplevelProtocol()
{
if (mTrans) {
RefPtr<DeleteTask<Transport>> task = new DeleteTask<Transport>(mTrans.release());
XRE_GetIOMessageLoop()->PostTask(task.forget());
--- a/ipc/glue/ProtocolUtils.h
+++ b/ipc/glue/ProtocolUtils.h
@@ -147,17 +147,17 @@ public:
NormalShutdown,
AbnormalShutdown
};
typedef base::ProcessId ProcessId;
typedef IPC::Message Message;
typedef IPC::MessageInfo MessageInfo;
- IProtocol() : mManager(nullptr), mChannel(nullptr) {}
+ IProtocol(Side aSide) : mSide(aSide), mManager(nullptr), mChannel(nullptr) {}
virtual int32_t Register(IProtocol*);
virtual int32_t RegisterID(IProtocol*, int32_t);
virtual IProtocol* Lookup(int32_t);
virtual void Unregister(int32_t);
virtual void RemoveManagee(int32_t, IProtocol*) = 0;
virtual Shmem::SharedMemory* CreateSharedMemory(
@@ -184,16 +184,17 @@ public:
virtual const MessageChannel* GetIPCChannel() const { return mChannel; }
virtual MessageChannel* GetIPCChannel() { return mChannel; }
protected:
void SetManager(IProtocol* aManager) { mManager = aManager; }
void SetIPCChannel(MessageChannel* aChannel) { mChannel = aChannel; }
private:
+ Side mSide;
IProtocol* mManager;
MessageChannel* mChannel;
};
typedef IPCMessageStart ProtocolId;
template<class PFooSide>
class Endpoint;
@@ -204,17 +205,17 @@ class Endpoint;
* IToplevelProtocol tracks all top-level protocol actors created from
* this protocol actor.
*/
class IToplevelProtocol : public IProtocol
{
template<class PFooSide> friend class Endpoint;
protected:
- explicit IToplevelProtocol(ProtocolId aProtoId);
+ explicit IToplevelProtocol(ProtocolId aProtoId, Side aSide);
~IToplevelProtocol();
public:
void SetTransport(UniquePtr<Transport> aTrans)
{
mTrans = Move(aTrans);
}
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -2941,36 +2941,36 @@ class _GenerateProtocolActorCode(ipdl.as
[ Label.PUBLIC ]
+ self.standardTypedefs()
+ [ Whitespace.NL ]
))
self.cls.addstmt(Label.PUBLIC)
# Actor()
ctor = ConstructorDefn(ConstructorDecl(self.clsname))
+ side = ExprVar('mozilla::ipc::' + self.side.title() + 'Side')
if ptype.isToplevel():
ctor.memberinits = [
+ ExprMemberInit(ExprVar('mozilla::ipc::IToplevelProtocol'),
+ [_protocolId(ptype), side]),
ExprMemberInit(p.channelVar(), [
ExprCall(ExprVar('ALLOW_THIS_IN_INITIALIZER_LIST'),
[ ExprVar.THIS ]) ]),
ExprMemberInit(p.lastActorIdVar(),
[ p.actorIdInit(self.side) ]),
ExprMemberInit(p.otherPidVar(),
[ ExprVar('mozilla::ipc::kInvalidProcessId') ]),
ExprMemberInit(p.lastShmemIdVar(),
[ p.shmemIdInit(self.side) ]),
ExprMemberInit(p.stateVar(),
[ p.startState() ])
]
- if ptype.isToplevel():
- ctor.memberinits = [ExprMemberInit(
- p.openedProtocolInterfaceType(),
- [ _protocolId(ptype) ])] + ctor.memberinits
else:
ctor.memberinits = [
+ ExprMemberInit(ExprVar('mozilla::ipc::IProtocol'), [side]),
ExprMemberInit(p.idVar(), [ ExprLiteral.ZERO ]),
ExprMemberInit(p.stateVar(),
[ p.deadState() ])
]
ctor.addstmt(StmtExpr(ExprCall(ExprVar('MOZ_COUNT_CTOR'),
[ ExprVar(self.clsname) ])))
self.cls.addstmts([ ctor, Whitespace.NL ])