Bug 545455, part 2: Expose override-able hooks for top-level IPDL actors to be notified on stack entrance/exit. r=bent

This commit is contained in:
Chris Jones 2010-02-16 12:44:22 -06:00
parent 40044ab29b
commit 557d0a7e78
2 changed files with 39 additions and 5 deletions

View File

@ -68,6 +68,16 @@ public:
Message*& aReply) = 0;
virtual Result OnCallReceived(const Message& aMessage,
Message*& aReply) = 0;
virtual void OnEnteredCxxStack()
{
NS_RUNTIMEABORT("default impl shouldn't be invoked");
}
virtual void OnExitedCxxStack()
{
NS_RUNTIMEABORT("default impl shouldn't be invoked");
}
};
// What happens if RPC calls race?
@ -166,14 +176,12 @@ protected:
// for when the depth goes from non-zero to zero;
void EnteredCxxStack()
{
// FIXME/bug 545455: call mListener hook
printf("[%s] +++ CXX STACK\n", mChild ? "child" : "parent");
static_cast<RPCListener*>(mListener)->OnEnteredCxxStack();
}
void ExitedCxxStack()
{
// FIXME/bug 545455: call mListener hook
printf("[%s] --- CXX STACK\n", mChild ? "child" : "parent");
static_cast<RPCListener*>(mListener)->OnExitedCxxStack();
}
class NS_STACK_CLASS CxxStackFrame

View File

@ -1348,6 +1348,14 @@ class Protocol(ipdl.ast.Protocol):
assert self.decl.type.isToplevel()
return ExprVar('ShouldContinueFromReplyTimeout')
def enteredCxxStackVar(self):
assert self.decl.type.isToplevel()
return ExprVar('EnteredCxxStack')
def exitedCxxStackVar(self):
assert self.decl.type.isToplevel()
return ExprVar('ExitedCxxStack')
def nextActorIdExpr(self, side):
assert self.decl.type.isToplevel()
if side is 'parent': op = '++'
@ -2639,7 +2647,15 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
MethodDecl(p.shouldContinueFromTimeoutVar().name,
ret=Type.BOOL, virtual=1))
shouldcontinue.addstmt(StmtReturn(ExprLiteral.TRUE))
self.cls.addstmts([ shouldcontinue, Whitespace.NL ])
# void EnteredCxxStack(); default to no-op
entered = MethodDefn(
MethodDecl(p.enteredCxxStackVar().name, virtual=1))
exited = MethodDefn(
MethodDecl(p.exitedCxxStackVar().name, virtual=1))
self.cls.addstmts([ shouldcontinue, entered, exited,
Whitespace.NL ])
self.cls.addstmts((
[ Label.PRIVATE ]
@ -2860,6 +2876,16 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
self.cls.addstmts([ ontimeout, Whitespace.NL ])
# On[Entered/Exited]CxxStack()
if ptype.isToplevel() and toplevel.talksRpc():
onentered = MethodDefn(MethodDecl('OnEnteredCxxStack'))
onentered.addstmt(StmtReturn(ExprCall(p.enteredCxxStackVar())))
onexited = MethodDefn(MethodDecl('OnExitedCxxStack'))
onexited.addstmt(StmtReturn(ExprCall(p.exitedCxxStackVar())))
self.cls.addstmts([ onentered, onexited, Whitespace.NL ])
# OnChannelClose()
onclose = MethodDefn(MethodDecl('OnChannelClose'))
if ptype.isToplevel():