Bug 1133748 - Fix ipdl code for bridged protocols that are also opened. r=billm.
authorPeter Van der Beken <peterv@propagandism.org>
Mon, 09 Feb 2015 21:54:12 +0100
changeset 246970 4ef647d61d1f919a8258f0130be7ef133e624cbb
parent 246969 3816bf636b009aa61549ebea25972900c9c57223
child 246971 765a823e848aa576875462aae6c616075fdf446c
push id884
push userdburns@mozilla.com
push dateTue, 03 Mar 2015 15:29:12 +0000
reviewersbillm
bugs1133748
milestone39.0a1
Bug 1133748 - Fix ipdl code for bridged protocols that are also opened. r=billm.
ipc/ipdl/ipdl/lower.py
ipc/ipdl/test/cxx/PTestBridgeMain.ipdl
ipc/ipdl/test/cxx/TestBridgeMain.h
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -1,14 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import os, re, sys
 from copy import deepcopy
+from collections import OrderedDict
 
 import ipdl.ast
 import ipdl.builtin
 from ipdl.cxx.ast import *
 from ipdl.type import Actor, ActorType, ProcessGraph, TypeVisitor, builtinHeaderIncludes
 
 # FIXME/cjones: the chromium Message logging code doesn't work on
 # gcc/POSIX, because it wprintf()s across the chromium/mozilla
@@ -2775,17 +2776,17 @@ class _GenerateProtocolActorCode(ipdl.as
             self.clsname,
             inherits=[ Inherit(Type(p.fqBaseClass()), viz='public'),
                        Inherit(p.managerInterfaceType(), viz='protected') ] +
             optinherits,
             abstract=True)
 
         bridgeActorsCreated = ProcessGraph.bridgeEndpointsOf(ptype, self.side)
         opensActorsCreated = ProcessGraph.opensEndpointsOf(ptype, self.side)
-        channelOpenedActors = bridgeActorsCreated + opensActorsCreated
+        channelOpenedActors = OrderedDict.fromkeys(bridgeActorsCreated + opensActorsCreated, None)
 
         friends = _FindFriends().findFriends(ptype)
         if ptype.isManaged():
             friends.update(ptype.managers)
 
         # |friend| managed actors so that they can call our Dealloc*()
         friends.update(ptype.manages)
 
--- a/ipc/ipdl/test/cxx/PTestBridgeMain.ipdl
+++ b/ipc/ipdl/test/cxx/PTestBridgeMain.ipdl
@@ -2,16 +2,17 @@ include protocol PTestBridgeMainSub;
 include protocol PTestBridgeSub;
 
 namespace mozilla {
 namespace _ipdltest {
 
 
 protocol PTestBridgeMain {
     child spawns PTestBridgeSub;
+    child opens PTestBridgeMainSub;
 
 child:
     Start();
 
 parent:
     __delete__();
 
 state START:
--- a/ipc/ipdl/test/cxx/TestBridgeMain.h
+++ b/ipc/ipdl/test/cxx/TestBridgeMain.h
@@ -67,16 +67,26 @@ class TestBridgeMainChild :
 {
 public:
     TestBridgeMainChild();
     virtual ~TestBridgeMainChild() {}
 
 protected:
     virtual bool RecvStart() MOZ_OVERRIDE;
 
+    virtual PTestBridgeMainSubChild*
+    AllocPTestBridgeMainSubChild(Transport* transport,
+                                 ProcessId otherProcess) MOZ_OVERRIDE
+    {
+        // This shouldn't be called. It's just a byproduct of testing that
+        // the right code is generated for a bridged protocol that's also
+        // opened, but we only test bridging here.
+        MOZ_CRASH();
+    }
+
     virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
 
     IPDLUnitTestSubprocess* mSubprocess;
 };
 
 class TestBridgeSubParent :
     public PTestBridgeSubParent
 {