Bug 792652 - Remove pointless OnFoo methods (r=dvander)
☠☠ backed out by d2098e1d1f2d ☠ ☠
authorBill McCloskey <billm@mozilla.com>
Tue, 01 Nov 2016 16:50:07 -0700
changeset 348422 94fcd3bf3f34dc20e2b2fbe7ff44ecfa47371f28
parent 348421 cf9c4164eb435ebf23cb3056eb1830861e8e8087
child 348423 2ba36b8ac60c01b555ee7311706720458739f7c2
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs792652
milestone52.0a1
Bug 792652 - Remove pointless OnFoo methods (r=dvander) A bunch of these methods just delegate from OnFoo to Foo. Not sure why we have OnFoo.
ipc/glue/MessageChannel.cpp
ipc/glue/ProtocolUtils.cpp
ipc/glue/ProtocolUtils.h
ipc/ipdl/ipdl/lower.py
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -1854,41 +1854,41 @@ MessageChannel::MaybeUndeferIncall()
     RefPtr<MessageTask> task = new MessageTask(this, Move(call));
     mPending.insertBack(task);
     task->Post();
 }
 
 void
 MessageChannel::EnteredCxxStack()
 {
-    mListener->OnEnteredCxxStack();
+    mListener->EnteredCxxStack();
 }
 
 void
 MessageChannel::ExitedCxxStack()
 {
-    mListener->OnExitedCxxStack();
+    mListener->ExitedCxxStack();
     if (mSawInterruptOutMsg) {
         MonitorAutoLock lock(*mMonitor);
         // see long comment in OnMaybeDequeueOne()
         EnqueuePendingMessages();
         mSawInterruptOutMsg = false;
     }
 }
 
 void
 MessageChannel::EnteredCall()
 {
-    mListener->OnEnteredCall();
+    mListener->EnteredCall();
 }
 
 void
 MessageChannel::ExitedCall()
 {
-    mListener->OnExitedCall();
+    mListener->ExitedCall();
 }
 
 void
 MessageChannel::EnteredSyncSend()
 {
     mListener->OnEnteredSyncSend();
 }
 
@@ -1978,17 +1978,17 @@ bool
 MessageChannel::ShouldContinueFromTimeout()
 {
     AssertWorkerThread();
     mMonitor->AssertCurrentThreadOwns();
 
     bool cont;
     {
         MonitorAutoUnlock unlock(*mMonitor);
-        cont = mListener->OnReplyTimeout();
+        cont = mListener->ShouldContinueFromReplyTimeout();
         mListener->ArtificialSleep();
     }
 
     static enum { UNKNOWN, NOT_DEBUGGING, DEBUGGING } sDebuggingChildren = UNKNOWN;
 
     if (sDebuggingChildren == UNKNOWN) {
         sDebuggingChildren = getenv("MOZ_DEBUG_CHILD_PROCESS") ? DEBUGGING : NOT_DEBUGGING;
     }
@@ -2027,17 +2027,17 @@ MessageChannel::DispatchOnChannelConnect
     MOZ_RELEASE_ASSERT(mPeerPidSet);
     mListener->OnChannelConnected(mPeerPid);
 }
 
 void
 MessageChannel::ReportMessageRouteError(const char* channelName) const
 {
     PrintErrorMessage(mSide, channelName, "Need a route");
-    mListener->OnProcessingError(MsgRouteError, "MsgRouteError");
+    mListener->ProcessingError(MsgRouteError, "MsgRouteError");
 }
 
 void
 MessageChannel::ReportConnectionError(const char* aChannelName, Message* aMsg) const
 {
     AssertWorkerThread();
     mMonitor->AssertCurrentThreadOwns();
 
@@ -2069,17 +2069,17 @@ MessageChannel::ReportConnectionError(co
                        aMsg->type(), aMsg->name(), errorMsg);
 
         PrintErrorMessage(mSide, aChannelName, reason);
     } else {
         PrintErrorMessage(mSide, aChannelName, errorMsg);
     }
 
     MonitorAutoUnlock unlock(*mMonitor);
-    mListener->OnProcessingError(MsgDropped, errorMsg);
+    mListener->ProcessingError(MsgDropped, errorMsg);
 }
 
 bool
 MessageChannel::MaybeHandleError(Result code, const Message& aMsg, const char* channelName)
 {
     if (MsgProcessed == code)
         return true;
 
@@ -2114,17 +2114,17 @@ MessageChannel::MaybeHandleError(Result 
     if (msgname[0] == '?') {
         SprintfLiteral(reason,"(msgtype=0x%X) %s", aMsg.type(), errorMsg);
     } else {
         SprintfLiteral(reason,"%s %s", msgname, errorMsg);
     }
 
     PrintErrorMessage(mSide, channelName, reason);
 
-    mListener->OnProcessingError(code, reason);
+    mListener->ProcessingError(code, reason);
 
     return false;
 }
 
 void
 MessageChannel::OnChannelErrorFromLink()
 {
     AssertLinkThread();
--- a/ipc/glue/ProtocolUtils.cpp
+++ b/ipc/glue/ProtocolUtils.cpp
@@ -516,10 +516,16 @@ IProtocol::DeallocShmem(Shmem& aMem)
     }
     return false;
   }
 #endif // DEBUG
   aMem.forget(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead());
   return ok;
 }
 
+bool
+IToplevelProtocol::IsOnCxxStack() const
+{
+  return GetIPCChannel()->IsOnCxxStack();
+}
+
 } // namespace ipc
 } // namespace mozilla
--- a/ipc/glue/ProtocolUtils.h
+++ b/ipc/glue/ProtocolUtils.h
@@ -60,16 +60,18 @@ class ContentParent;
 } // namespace dom
 
 namespace net {
 class NeckoParent;
 } // namespace net
 
 namespace ipc {
 
+class MessageChannel;
+
 #ifdef XP_WIN
 const base::ProcessHandle kInvalidProcessHandle = INVALID_HANDLE_VALUE;
 
 // In theory, on Windows, this is a valid process ID, but in practice they are
 // currently divisible by four. Process IDs share the kernel handle allocation
 // code and they are guaranteed to be divisible by four.
 // As this could change for process IDs we shouldn't generally rely on this
 // property, however even if that were to change, it seems safe to rely on this
@@ -226,19 +228,20 @@ public:
     }
 
     Transport* GetTransport() const { return mTrans.get(); }
 
     ProtocolId GetProtocolId() const { return mProtocolId; }
 
     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;
     }
 
     // WARNING: This function is called with the MessageChannel monitor held.
     virtual void IntentionalCrash() {
         MOZ_CRASH("Intentional IPDL crash");
     }
 
@@ -264,28 +267,23 @@ public:
     // true.
     virtual void ArtificialSleep() {}
 #else
     bool ArtificialTimeout() { return false; }
     bool NeedArtificialSleep() { return false; }
     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)
     {
         return RIPChildWins;
     }
 
     /**
      * Return true if windows messages can be handled while waiting for a reply
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -3216,72 +3216,23 @@ class _GenerateProtocolActorCode(ipdl.as
             Whitespace.NL
         ])
 
         destroysubtreevar = ExprVar('DestroySubtree')
         deallocsubtreevar = ExprVar('DeallocSubtree')
         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'))
             onclose.addstmts([
                 StmtExpr(ExprCall(destroysubtreevar,
                                   args=[ _DestroyReason.NormalShutdown ])),
                 StmtExpr(ExprCall(deallocsubtreevar)),
                 StmtExpr(ExprCall(deallocshmemvar)),
                 StmtExpr(ExprCall(deallocselfvar))