Bug 792652 - Move mChannel to IProtocol (r=dvander)

This moves the mChannel field to IProtocol. The toplevel protocol still keeps
its own mChannel field that's a MessageChannel (no pointer).
This commit is contained in:
Bill McCloskey 2016-10-31 15:18:35 -07:00
Родитель 4b9d7f03a5
Коммит a99edd3404
2 изменённых файлов: 28 добавлений и 30 удалений

Просмотреть файл

@ -152,7 +152,7 @@ public:
typedef IPC::Message Message;
typedef IPC::MessageInfo MessageInfo;
IProtocol() : mManager(nullptr) {}
IProtocol() : mManager(nullptr), mChannel(nullptr) {}
virtual int32_t Register(IProtocol*);
virtual int32_t RegisterID(IProtocol*, int32_t);
@ -168,7 +168,6 @@ public:
// XXX odd ducks, acknowledged
virtual ProcessId OtherPid() const;
virtual MessageChannel* GetIPCChannel() = 0;
virtual void FatalError(const char* const aProtocolName, const char* const aErrorMsg) const = 0;
@ -182,12 +181,16 @@ public:
virtual int32_t GetProtocolTypeId() = 0;
IProtocol* Manager() const { return mManager; }
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:
IProtocol* mManager;
MessageChannel* mChannel;
};
typedef IPCMessageStart ProtocolId;
@ -219,8 +222,6 @@ public:
ProtocolId GetProtocolId() const { return mProtocolId; }
virtual MessageChannel* GetIPCChannel() = 0;
virtual void OnChannelClose() = 0;
virtual void OnChannelError() = 0;
virtual void OnProcessingError(Result aError, const char* aMsgName) = 0;

Просмотреть файл

@ -126,9 +126,6 @@ def _actorId(actor=None):
def _actorHId(actorhandle):
return ExprSelect(actorhandle, '.', 'mId')
def _actorChannel(actor):
return ExprSelect(actor, '->', 'mChannel')
def _actorManager(actor):
return ExprCall(ExprSelect(actor, '->', 'Manager'), args=[])
@ -1212,11 +1209,6 @@ class Protocol(ipdl.ast.Protocol):
return ExprSelect(actorThis, '->', 'mChannel')
return ExprVar('mChannel')
def channelForSubactor(self):
if self.decl.type.isToplevel():
return ExprAddrOf(self.channelVar())
return self.channelVar()
def routingId(self, actorThis=None):
if self.decl.type.isToplevel():
return ExprVar('MSG_ROUTING_CONTROL')
@ -3574,8 +3566,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
self.implementPickling()
## private members
self.cls.addstmt(StmtDecl(Decl(p.channelType(), 'mChannel')))
if ptype.isToplevel():
self.cls.addstmt(StmtDecl(Decl(p.channelType(), 'mChannel')))
self.cls.addstmts([
StmtDecl(Decl(Type('IDMap', T=Type('ProtocolBase')),
p.actorMapVar().name)),
@ -3667,6 +3659,17 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
ret=Type('base::ProcessId'),
const=1,
virtual=1))
getchannel = MethodDefn(MethodDecl(
p.getChannelMethod().name,
ret=Type('MessageChannel', ptr=1),
virtual=1))
getchannel.addstmt(StmtReturn(ExprAddrOf(p.channelVar())))
getchannelconst = MethodDefn(MethodDecl(
p.getChannelMethod().name,
ret=Type('MessageChannel', ptr=1, const=1),
virtual=1, const=1))
getchannelconst.addstmt(StmtReturn(ExprAddrOf(p.channelVar())))
methods += [ register,
registerid,
@ -3676,12 +3679,9 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
lookupshmem,
istracking,
destroyshmem,
otherpid ]
getchannel = MethodDefn(MethodDecl(
p.getChannelMethod().name,
ret=Type('MessageChannel', ptr=1),
virtual=1))
otherpid,
getchannel,
getchannelconst ]
if p.decl.type.isToplevel():
tmpvar = ExprVar('tmp')
@ -3744,7 +3744,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
createshmem.addstmt(failif)
failif = StmtIf(ExprNot(ExprCall(
ExprSelect(p.channelVar(), p.channelSel(), 'Send'),
ExprSelect(p.callGetChannel(), '->', 'Send'),
args=[ descriptorvar ])))
createshmem.addstmt(failif)
@ -3839,9 +3839,6 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
CaseLabel('SHMEM_DESTROYED_MESSAGE_TYPE'), abort)
otherpid.addstmt(StmtReturn(p.otherPidVar()))
getchannel.addstmt(StmtReturn(ExprAddrOf(p.channelVar())))
else:
getchannel.addstmt(StmtReturn(p.channelVar()))
othervar = ExprVar('other')
managertype = Type(_actorName(p.name, self.side), ptr=1)
@ -3901,7 +3898,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
switchontype.addcase(DefaultLabel(), default)
removemanagee.addstmt(switchontype)
return methods + [removemanagee, getchannel, Whitespace.NL]
return methods + [removemanagee, Whitespace.NL]
def makeShmemIface(self):
p = self.protocol
@ -4774,8 +4771,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
self.failIfNullActor(actorvar, errfn, msg="Error constructing actor %s" % actortype.name() + self.side.capitalize()),
StmtExpr(ExprAssn(_actorId(actorvar), idexpr)),
StmtExpr(ExprCall(ExprSelect(actorvar, '->', 'SetManager'), args=[ExprVar.THIS])),
StmtExpr(ExprAssn(_actorChannel(actorvar),
self.protocol.channelForSubactor())),
StmtExpr(ExprCall(ExprSelect(actorvar, '->', 'SetIPCChannel'),
args=[self.protocol.callGetChannel()])),
StmtExpr(_callInsertManagedActor(
self.protocol.managedVar(md.decl.type.constructedType(),
self.side),
@ -5199,8 +5196,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
+ [ Whitespace.NL,
StmtDecl(Decl(Type.BOOL, sendok.name),
init=ExprCall(
ExprSelect(self.protocol.channelVar(actor),
self.protocol.channelSel(), 'Send'),
ExprSelect(self.protocol.callGetChannel(actor),
'->', 'Send'),
args=[ msgexpr ]))
])
)
@ -5216,8 +5213,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
+ [ Whitespace.NL,
StmtDecl(
Decl(Type.BOOL, sendok.name),
init=ExprCall(ExprSelect(self.protocol.channelVar(actor),
self.protocol.channelSel(),
init=ExprCall(ExprSelect(self.protocol.callGetChannel(actor),
'->',
_sendPrefix(md.decl.type)),
args=[ msgexpr, ExprAddrOf(replyexpr) ]))
])