Bug 879475 - Rename the MsgStart messages to MsgStartChild for child protocols r=jlebar
authorDavid Zbarsky <dzbarsky@gmail.com>
Tue, 20 Aug 2013 15:46:41 -0400
changeset 143603 ef5322627c862593dee45760853feec972e27c4f
parent 143602 395ba08436fdc7187c73c9ae80a1b07f9ef89d92
child 143604 e6ed18f19d793df97c765ca81cb61f6018e97d3b
push idunknown
push userunknown
push dateunknown
reviewersjlebar
bugs879475
milestone26.0a1
Bug 879475 - Rename the MsgStart messages to MsgStartChild for child protocols r=jlebar
ipc/glue/ProtocolUtils.cpp
ipc/glue/ProtocolUtils.h
ipc/ipdl/ipdl.py
ipc/ipdl/ipdl/lower.py
--- a/ipc/glue/ProtocolUtils.cpp
+++ b/ipc/glue/ProtocolUtils.cpp
@@ -47,17 +47,17 @@ public:
     return true;
   }
 };
 
 bool
 Bridge(const PrivateIPDLInterface&,
        AsyncChannel* aParentChannel, ProcessHandle aParentProcess,
        AsyncChannel* aChildChannel, ProcessHandle aChildProcess,
-       ProtocolId aProtocol)
+       ProtocolId aProtocol, ProtocolId aChildProtocol)
 {
   ProcessId parentId = GetProcId(aParentProcess);
   ProcessId childId = GetProcId(aChildProcess);
   if (!parentId || !childId) {
     return false;
   }
 
   TransportDescriptor parentSide, childSide;
@@ -66,29 +66,29 @@ Bridge(const PrivateIPDLInterface&,
     return false;
   }
 
   if (!aParentChannel->Send(new ChannelOpened(parentSide,
                                               childId,
                                               aProtocol)) ||
       !aChildChannel->Send(new ChannelOpened(childSide,
                                              parentId,
-                                             aProtocol))) {
+                                             aChildProtocol))) {
     CloseDescriptor(parentSide);
     CloseDescriptor(childSide);
     return false;
   }
   return true;
 }
 
 bool
 Open(const PrivateIPDLInterface&,
      AsyncChannel* aOpenerChannel, ProcessHandle aOtherProcess,
      Transport::Mode aOpenerMode,
-     ProtocolId aProtocol)
+     ProtocolId aProtocol, ProtocolId aChildProtocol)
 {
   bool isParent = (Transport::MODE_SERVER == aOpenerMode);
   ProcessHandle thisHandle = GetCurrentProcessHandle();
   ProcessHandle parentHandle = isParent ? thisHandle : aOtherProcess;
   ProcessHandle childHandle = !isParent ? thisHandle : aOtherProcess;
   ProcessId parentId = GetProcId(parentHandle);
   ProcessId childId = GetProcId(childHandle);
   if (!parentId || !childId) {
@@ -97,17 +97,17 @@ Open(const PrivateIPDLInterface&,
 
   TransportDescriptor parentSide, childSide;
   if (!CreateTransport(parentHandle, childHandle,
                        &parentSide, &childSide)) {
     return false;
   }
 
   Message* parentMsg = new ChannelOpened(parentSide, childId, aProtocol);
-  Message* childMsg = new ChannelOpened(childSide, parentId, aProtocol);
+  Message* childMsg = new ChannelOpened(childSide, parentId, aChildProtocol);
   nsAutoPtr<Message> messageForUs(isParent ? parentMsg : childMsg);
   nsAutoPtr<Message> messageForOtherSide(!isParent ? parentMsg : childMsg);
   if (!aOpenerChannel->Echo(messageForUs.forget()) ||
       !aOpenerChannel->Send(messageForOtherSide.forget())) {
     CloseDescriptor(parentSide);
     CloseDescriptor(childSide);
     return false;
   }
--- a/ipc/glue/ProtocolUtils.h
+++ b/ipc/glue/ProtocolUtils.h
@@ -117,22 +117,22 @@ ProtocolErrorBreakpoint(const char* aMsg
 
 typedef IPCMessageStart ProtocolId;
 
 struct PrivateIPDLInterface {};
 
 bool
 Bridge(const PrivateIPDLInterface&,
        AsyncChannel*, base::ProcessHandle, AsyncChannel*, base::ProcessHandle,
-       ProtocolId);
+       ProtocolId, ProtocolId);
 
 bool
 Open(const PrivateIPDLInterface&,
      AsyncChannel*, base::ProcessHandle, Transport::Mode,
-     ProtocolId);
+     ProtocolId, ProtocolId);
 
 bool
 UnpackChannelOpened(const PrivateIPDLInterface&,
                     const IPC::Message&,
                     TransportDescriptor*, base::ProcessId*, ProtocolId*);
 
 } // namespace ipc
 } // namespace mozilla
--- a/ipc/ipdl/ipdl.py
+++ b/ipc/ipdl/ipdl.py
@@ -153,16 +153,17 @@ print >>ipcmsgstart, """
 #ifndef IPCMessageStart_h
 #define IPCMessageStart_h
 
 enum IPCMessageStart {
 """
 
 for name in allprotocols:
     print >>ipcmsgstart, "  %s," % name
+    print >>ipcmsgstart, "  %sChild," % name
 
 print >>ipcmsgstart, """
   LastMsgIndex
 };
 
 COMPILE_ASSERT(LastMsgIndex <= 65536, need_to_update_IPC_MESSAGE_MACRO);
 
 #endif // ifndef IPCMessageStart_h
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -1534,17 +1534,17 @@ class _GenerateProtocolCode(ipdl.ast.Vis
         stateenum.addId(_startState().name, startstate)
 
         ns.addstmts([ StmtDecl(Decl(stateenum,'')), Whitespace.NL ])
 
         # spit out message type enum and classes
         msgenum = TypeEnum('MessageType')
         msgstart = _messageStartName(self.protocol.decl.type) +' << 16'
         msgenum.addId(self.protocol.name + 'Start', msgstart)
-        msgenum.addId(self.protocol.name +'PreStart', '('+ msgstart +') - 1')
+        #msgenum.addId(self.protocol.name +'PreStart', '('+ msgstart +') - 1')
 
         for md in p.messageDecls:
             msgenum.addId(md.msgId())
             if md.hasReply():
                 msgenum.addId(md.replyId())
 
         msgenum.addId(self.protocol.name +'End')
         ns.addstmts([ StmtDecl(Decl(msgenum, '')), Whitespace.NL ])
@@ -1588,17 +1588,18 @@ class _GenerateProtocolCode(ipdl.ast.Vis
             params=[ Decl(parentHandleType, parentvar.name),
                      Decl(childHandleType, childvar.name) ],
             ret=Type.BOOL))
         bridgefunc.addstmt(StmtReturn(ExprCall(
             ExprVar('mozilla::ipc::Bridge'),
             args=[ _backstagePass(),
                    p.callGetChannel(parentvar), p.callOtherProcess(parentvar),
                    p.callGetChannel(childvar), p.callOtherProcess(childvar),
-                   _protocolId(p.decl.type)
+                   _protocolId(p.decl.type),
+                   ExprVar(_messageStartName(p.decl.type) + 'Child')
                    ])))
         return bridgefunc
 
 
     def genOpenFunc(self, o):
         p = self.protocol
         localside = o.opener.side
         openertype = _cxxBareType(ActorType(o.opener.ptype), o.opener.side,
@@ -1608,17 +1609,18 @@ class _GenerateProtocolCode(ipdl.ast.Vis
             'Open',
             params=[ Decl(openertype, openervar.name) ],
             ret=Type.BOOL))
         openfunc.addstmt(StmtReturn(ExprCall(
             ExprVar('mozilla::ipc::Open'),
             args=[ _backstagePass(),
                    p.callGetChannel(openervar), p.callOtherProcess(openervar),
                    _sideToTransportMode(localside),
-                   _protocolId(p.decl.type)
+                   _protocolId(p.decl.type),
+                   ExprVar(_messageStartName(p.decl.type) + 'Child')
                    ])))
         return openfunc
 
 
     def genTransitionFunc(self):
         ptype = self.protocol.decl.type
         usesend, sendvar = set(), ExprVar('__Send')
         userecv, recvvar = set(), ExprVar('__Recv')
@@ -3987,17 +3989,20 @@ class _GenerateProtocolActorCode(ipdl.as
             iffailalloc.addifstmt(StmtReturn(_Result.ProcessingError))
 
             case.addstmts([
                 StmtDecl(Decl(Type('Transport', ptr=1), tvar.name)),
                 iffailopen,
                 iffailalloc,
                 StmtBreak()
             ])
-            return CaseLabel(_protocolId(actor.ptype).name), case
+            label = _messageStartName(actor.ptype)
+            if actor.side is 'child':
+                label += 'Child'
+            return CaseLabel(label), case
 
         pswitch = StmtSwitch(pvar)
         for actor in actors:
             label, case = makeHandlerCase(actor)
             pswitch.addcase(label, case)
 
         die = Block()
         die.addstmts([ _runtimeAbort('Invalid protocol'),