diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index 8e3776b8a4c9..b684bd342c01 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -1859,13 +1859,13 @@ MessageChannel::MaybeUndeferIncall() void MessageChannel::EnteredCxxStack() { - mListener->OnEnteredCxxStack(); + mListener->EnteredCxxStack(); } void MessageChannel::ExitedCxxStack() { - mListener->OnExitedCxxStack(); + mListener->ExitedCxxStack(); if (mSawInterruptOutMsg) { MonitorAutoLock lock(*mMonitor); // see long comment in OnMaybeDequeueOne() @@ -1877,13 +1877,13 @@ MessageChannel::ExitedCxxStack() void MessageChannel::EnteredCall() { - mListener->OnEnteredCall(); + mListener->EnteredCall(); } void MessageChannel::ExitedCall() { - mListener->OnExitedCall(); + mListener->ExitedCall(); } void @@ -1983,7 +1983,7 @@ MessageChannel::ShouldContinueFromTimeout() bool cont; { MonitorAutoUnlock unlock(*mMonitor); - cont = mListener->OnReplyTimeout(); + cont = mListener->ShouldContinueFromReplyTimeout(); mListener->ArtificialSleep(); } @@ -2032,7 +2032,7 @@ void MessageChannel::ReportMessageRouteError(const char* channelName) const { PrintErrorMessage(mSide, channelName, "Need a route"); - mListener->OnProcessingError(MsgRouteError, "MsgRouteError"); + mListener->ProcessingError(MsgRouteError, "MsgRouteError"); } void @@ -2074,7 +2074,7 @@ MessageChannel::ReportConnectionError(const char* aChannelName, Message* aMsg) c } MonitorAutoUnlock unlock(*mMonitor); - mListener->OnProcessingError(MsgDropped, errorMsg); + mListener->ProcessingError(MsgDropped, errorMsg); } bool @@ -2119,7 +2119,7 @@ MessageChannel::MaybeHandleError(Result code, const Message& aMsg, const char* c PrintErrorMessage(mSide, channelName, reason); - mListener->OnProcessingError(code, reason); + mListener->ProcessingError(code, reason); return false; } diff --git a/ipc/glue/ProtocolUtils.cpp b/ipc/glue/ProtocolUtils.cpp index 3857b6dc06b8..b096bf68ae36 100644 --- a/ipc/glue/ProtocolUtils.cpp +++ b/ipc/glue/ProtocolUtils.cpp @@ -521,5 +521,11 @@ IProtocol::DeallocShmem(Shmem& aMem) return ok; } +bool +IToplevelProtocol::IsOnCxxStack() const +{ + return GetIPCChannel()->IsOnCxxStack(); +} + } // namespace ipc } // namespace mozilla diff --git a/ipc/glue/ProtocolUtils.h b/ipc/glue/ProtocolUtils.h index ea926b2a9e78..31ab03ef4cd8 100644 --- a/ipc/glue/ProtocolUtils.h +++ b/ipc/glue/ProtocolUtils.h @@ -65,6 +65,8 @@ class NeckoParent; namespace ipc { +class MessageChannel; + #ifdef XP_WIN const base::ProcessHandle kInvalidProcessHandle = INVALID_HANDLE_VALUE; @@ -231,9 +233,10 @@ public: virtual void OnChannelClose() = 0; virtual void OnChannelError() = 0; - virtual void OnProcessingError(Result aError, const char* aMsgName) = 0; + virtual void ProcessingError(Result aError, const char* aMsgName) {} virtual void OnChannelConnected(int32_t peer_pid) {} - virtual bool OnReplyTimeout() { + + virtual bool ShouldContinueFromReplyTimeout() { return false; } @@ -269,18 +272,13 @@ public: void ArtificialSleep() {} #endif - virtual void OnEnteredCxxStack() { - NS_RUNTIMEABORT("default impl shouldn't be invoked"); - } - virtual void OnExitedCxxStack() { - NS_RUNTIMEABORT("default impl shouldn't be invoked"); - } - virtual void OnEnteredCall() { - NS_RUNTIMEABORT("default impl shouldn't be invoked"); - } - virtual void OnExitedCall() { - NS_RUNTIMEABORT("default impl shouldn't be invoked"); - } + virtual void EnteredCxxStack() {} + virtual void ExitedCxxStack() {} + virtual void EnteredCall() {} + virtual void ExitedCall() {} + + bool IsOnCxxStack() const; + virtual RacyInterruptPolicy MediateInterruptRace(const MessageInfo& parent, const MessageInfo& child) { diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index 45602d389559..eb3e25bed31a 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -3221,61 +3221,12 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): deallocshmemvar = ExprVar('DeallocShmems') deallocselfvar = ExprVar('Dealloc' + _actorName(ptype.name(), self.side)) - if ptype.isToplevel(): - # OnProcesingError(code) - codevar = ExprVar('aCode') - reasonvar = ExprVar('aReason') - onprocessingerror = MethodDefn( - MethodDecl('OnProcessingError', - params=[ Param(_Result.Type(), codevar.name), - Param(Type('char', const=1, ptr=1), reasonvar.name) ])) - onprocessingerror.addstmt(StmtReturn( - ExprCall(p.processingErrorVar(), args=[ codevar, reasonvar ]))) - self.cls.addstmts([ onprocessingerror, Whitespace.NL ]) - # int32_t GetProtocolTypeId() { return PFoo; } gettypetag = MethodDefn( MethodDecl('GetProtocolTypeId', ret=_actorTypeTagType())) gettypetag.addstmt(StmtReturn(_protocolId(ptype))) self.cls.addstmts([ gettypetag, Whitespace.NL ]) - if ptype.isToplevel(): - # OnReplyTimeout() - if toplevel.isSync() or toplevel.isInterrupt(): - ontimeout = MethodDefn( - MethodDecl('OnReplyTimeout', ret=Type.BOOL)) - ontimeout.addstmt(StmtReturn( - ExprCall(p.shouldContinueFromTimeoutVar()))) - self.cls.addstmts([ ontimeout, Whitespace.NL ]) - - # C++-stack-related methods - if ptype.isToplevel(): - # OnEnteredCxxStack() - onentered = MethodDefn(MethodDecl('OnEnteredCxxStack')) - onentered.addstmt(StmtReturn(ExprCall(p.enteredCxxStackVar()))) - - # OnExitedCxxStack() - onexited = MethodDefn(MethodDecl('OnExitedCxxStack')) - onexited.addstmt(StmtReturn(ExprCall(p.exitedCxxStackVar()))) - - # OnEnteredCxxStack() - onenteredcall = MethodDefn(MethodDecl('OnEnteredCall')) - onenteredcall.addstmt(StmtReturn(ExprCall(p.enteredCallVar()))) - - # OnExitedCxxStack() - onexitedcall = MethodDefn(MethodDecl('OnExitedCall')) - onexitedcall.addstmt(StmtReturn(ExprCall(p.exitedCallVar()))) - - # bool IsOnCxxStack() - onstack = MethodDefn( - MethodDecl(p.onCxxStackVar().name, ret=Type.BOOL, const=1)) - onstack.addstmt(StmtReturn(ExprCall( - ExprSelect(p.channelVar(), '.', p.onCxxStackVar().name)))) - - self.cls.addstmts([ onentered, onexited, - onenteredcall, onexitedcall, - onstack, Whitespace.NL ]) - if ptype.isToplevel(): # OnChannelClose() onclose = MethodDefn(MethodDecl('OnChannelClose'))