Bug 540097: Add a ProcessingError(what) notification interface for top-level actors. r=bent

This commit is contained in:
Chris Jones 2010-08-20 18:24:40 -05:00
parent 0a3ef826a6
commit d3a9ff236c
7 changed files with 50 additions and 1 deletions

View File

@ -401,6 +401,9 @@ AsyncChannel::MaybeHandleError(Result code, const char* channelName)
}
PrintErrorMessage(channelName, errorMsg);
mListener->OnProcessingError(code);
return false;
}
@ -430,6 +433,8 @@ AsyncChannel::ReportConnectionError(const char* channelName) const
}
PrintErrorMessage(channelName, errorMsg);
mListener->OnProcessingError(MsgDropped);
}
//

View File

@ -57,6 +57,7 @@ struct HasResultCodes
{
enum Result {
MsgProcessed,
MsgDropped,
MsgNotKnown,
MsgNotAllowed,
MsgPayloadError,
@ -93,6 +94,7 @@ public:
virtual void OnChannelClose() = 0;
virtual void OnChannelError() = 0;
virtual Result OnMessageReceived(const Message& aMessage) = 0;
virtual void OnProcessingError(Result aError) = 0;
};
public:

View File

@ -78,6 +78,7 @@ public:
virtual void OnChannelClose() = 0;
virtual void OnChannelError() = 0;
virtual Result OnMessageReceived(const Message& aMessage) = 0;
virtual void OnProcessingError(Result aError) = 0;
virtual bool OnReplyTimeout() = 0;
virtual Result OnMessageReceived(const Message& aMessage,
Message*& aReply) = 0;

View File

@ -63,6 +63,7 @@ public:
virtual void OnChannelClose() = 0;
virtual void OnChannelError() = 0;
virtual Result OnMessageReceived(const Message& aMessage) = 0;
virtual void OnProcessingError(Result aError) = 0;
virtual bool OnReplyTimeout() = 0;
virtual Result OnMessageReceived(const Message& aMessage,
Message*& aReply) = 0;

View File

@ -1042,6 +1042,10 @@ class Protocol(ipdl.ast.Protocol):
def otherProcessMethod(self):
return ExprVar('OtherProcess')
def processingErrorVar(self):
assert self.decl.type.isToplevel()
return ExprVar('ProcessingError')
def shouldContinueFromTimeoutVar(self):
assert self.decl.type.isToplevel()
return ExprVar('ShouldContinueFromReplyTimeout')
@ -2464,6 +2468,12 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
])
if ptype.isToplevel():
# void ProcessingError(code); default to no-op
processingerror = MethodDefn(
MethodDecl(p.processingErrorVar().name,
params=[ Param(_Result.Type(), 'code') ],
virtual=1))
# bool ShouldContinueFromReplyTimeout(); default to |true|
shouldcontinue = MethodDefn(
MethodDecl(p.shouldContinueFromTimeoutVar().name,
@ -2480,7 +2490,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
exitedcall = MethodDefn(
MethodDecl(p.exitedCallVar().name, virtual=1))
self.cls.addstmts([ shouldcontinue,
self.cls.addstmts([ processingerror,
shouldcontinue,
entered, exited,
enteredcall, exitedcall,
Whitespace.NL ])
@ -2708,6 +2719,19 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
deallocsubtreevar = ExprVar('DeallocSubtree')
deallocshmemvar = ExprVar('DeallocShmems')
# OnProcesingError(code)
codevar = ExprVar('code')
onprocessingerror = MethodDefn(
MethodDecl('OnProcessingError',
params=[ Param(_Result.Type(), codevar.name) ]))
if ptype.isToplevel():
onprocessingerror.addstmt(StmtReturn(
ExprCall(p.processingErrorVar(), args=[ codevar ])))
else:
onprocessingerror.addstmt(
_runtimeAbort("`OnProcessingError' called on non-toplevel actor"))
self.cls.addstmts([ onprocessingerror, Whitespace.NL ])
# OnReplyTimeout()
if toplevel.talksSync() or toplevel.talksRpc():
ontimeout = MethodDefn(

View File

@ -62,6 +62,7 @@ void Done()
} // namespace <anon>
TestRPCErrorCleanupParent::TestRPCErrorCleanupParent()
: mGotProcessingError(false)
{
MOZ_COUNT_CTOR(TestRPCErrorCleanupParent);
}
@ -106,6 +107,9 @@ TestRPCErrorCleanupParent::Main()
if (CallError())
fail("expected an error!");
if (!mGotProcessingError)
fail("expected a ProcessingError() notification");
// it's OK to Close() a channel after an error, because nsNPAPI*
// wants to do this
Close();
@ -117,6 +121,13 @@ TestRPCErrorCleanupParent::Main()
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction(Done));
}
void
TestRPCErrorCleanupParent::ProcessingError(Result what)
{
if (what != MsgDropped)
fail("unexpected processing error");
mGotProcessingError = true;
}
//-----------------------------------------------------------------------------
// child

View File

@ -26,6 +26,11 @@ protected:
if (AbnormalShutdown != why)
fail("unexpected destruction!");
}
NS_OVERRIDE
virtual void ProcessingError(Result what);
bool mGotProcessingError;
};