diff --git a/dom/media/ipc/VideoDecoderManagerParent.h b/dom/media/ipc/VideoDecoderManagerParent.h index 27886810fdf7..a85681e07053 100644 --- a/dom/media/ipc/VideoDecoderManagerParent.h +++ b/dom/media/ipc/VideoDecoderManagerParent.h @@ -33,7 +33,7 @@ protected: bool RecvReadback(const SurfaceDescriptorGPUVideo& aSD, SurfaceDescriptor* aResult) override; bool RecvDeallocateSurfaceDescriptorGPUVideo(const SurfaceDescriptorGPUVideo& aSD) override; - void ActorDestroy(mozilla::ipc::IProtocolManager::ActorDestroyReason) override {} + void ActorDestroy(mozilla::ipc::IProtocol::ActorDestroyReason) override {} void DeallocPVideoDecoderManagerParent() override; diff --git a/dom/media/systemservices/MediaParent.h b/dom/media/systemservices/MediaParent.h index bf944f6b0f1e..b5dcd84ad248 100644 --- a/dom/media/systemservices/MediaParent.h +++ b/dom/media/systemservices/MediaParent.h @@ -22,7 +22,7 @@ class OriginKeyStore; class NonE10s { - typedef mozilla::ipc::IProtocolManager::ActorDestroyReason + typedef mozilla::ipc::IProtocol::ActorDestroyReason ActorDestroyReason; public: virtual ~NonE10s() {} @@ -45,7 +45,7 @@ protected: template class Parent : public Super { - typedef mozilla::ipc::IProtocolManager::ActorDestroyReason + typedef mozilla::ipc::IProtocol::ActorDestroyReason ActorDestroyReason; public: NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Parent) diff --git a/gfx/layers/IPDLActor.h b/gfx/layers/IPDLActor.h index 4698d16c4a5b..c94a67f5247c 100644 --- a/gfx/layers/IPDLActor.h +++ b/gfx/layers/IPDLActor.h @@ -38,7 +38,7 @@ public: return true; } - typedef ipc::IProtocolManager::ActorDestroyReason Why; + typedef ipc::IProtocol::ActorDestroyReason Why; virtual void ActorDestroy(Why) override { DestroyIfNeeded(); diff --git a/ipc/glue/ProtocolUtils.cpp b/ipc/glue/ProtocolUtils.cpp index a3bf8f0df5b5..e2bacf492ec9 100644 --- a/ipc/glue/ProtocolUtils.cpp +++ b/ipc/glue/ProtocolUtils.cpp @@ -365,5 +365,38 @@ TableToArray(const nsTHashtable>& aTable, } } +Maybe +IProtocol::ReadActor(const IPC::Message* aMessage, PickleIterator* aIter, bool aNullable, + const char* aActorDescription, int32_t aProtocolTypeId) +{ + int32_t id; + if (!IPC::ReadParam(aMessage, aIter, &id)) { + ActorIdReadError(aActorDescription); + return Nothing(); + } + + if (id == 1 || (id == 0 && !aNullable)) { + BadActorIdError(aActorDescription); + return Nothing(); + } + + if (id == 0) { + return Some(static_cast(nullptr)); + } + + IProtocol* listener = this->Lookup(id); + if (!listener) { + ActorLookupError(aActorDescription); + return Nothing(); + } + + if (listener->GetProtocolTypeId() != aProtocolTypeId) { + MismatchedActorTypeError(aActorDescription); + return Nothing(); + } + + return Some(listener); +} + } // namespace ipc } // namespace mozilla diff --git a/ipc/glue/ProtocolUtils.h b/ipc/glue/ProtocolUtils.h index 59f88da933ec..6290b016b87a 100644 --- a/ipc/glue/ProtocolUtils.h +++ b/ipc/glue/ProtocolUtils.h @@ -130,8 +130,7 @@ struct Trigger uint32_t mMessage : 31; }; -template -class IProtocolManager +class IProtocol : public MessageListener { public: enum ActorDestroyReason { @@ -144,11 +143,11 @@ public: typedef base::ProcessId ProcessId; - virtual int32_t Register(ListenerT*) = 0; - virtual int32_t RegisterID(ListenerT*, int32_t) = 0; - virtual ListenerT* Lookup(int32_t) = 0; + virtual int32_t Register(IProtocol*) = 0; + virtual int32_t RegisterID(IProtocol*, int32_t) = 0; + virtual IProtocol* Lookup(int32_t) = 0; virtual void Unregister(int32_t) = 0; - virtual void RemoveManagee(int32_t, ListenerT*) = 0; + virtual void RemoveManagee(int32_t, IProtocol*) = 0; virtual Shmem::SharedMemory* CreateSharedMemory( size_t, SharedMemory::SharedMemoryType, bool, int32_t*) = 0; @@ -162,19 +161,12 @@ public: virtual void FatalError(const char* const aProtocolName, const char* const aErrorMsg) const = 0; - Maybe ReadActor(const IPC::Message* aMessage, PickleIterator* aIter, bool aNullable, + Maybe ReadActor(const IPC::Message* aMessage, PickleIterator* aIter, bool aNullable, const char* aActorDescription, int32_t aProtocolTypeId); }; typedef IPCMessageStart ProtocolId; -/** - * All RPC protocols should implement this interface. - */ -class IProtocol : public MessageListener -{ -}; - template class Endpoint; @@ -319,40 +311,6 @@ UnpackChannelOpened(const PrivateIPDLInterface&, const IPC::Message&, TransportDescriptor*, base::ProcessId*, ProtocolId*); -template -Maybe -IProtocolManager::ReadActor(const IPC::Message* aMessage, PickleIterator* aIter, bool aNullable, - const char* aActorDescription, int32_t aProtocolTypeId) -{ - int32_t id; - if (!IPC::ReadParam(aMessage, aIter, &id)) { - ActorIdReadError(aActorDescription); - return Nothing(); - } - - if (id == 1 || (id == 0 && !aNullable)) { - BadActorIdError(aActorDescription); - return Nothing(); - } - - if (id == 0) { - return Some(static_cast(nullptr)); - } - - ListenerT* listener = this->Lookup(id); - if (!listener) { - ActorLookupError(aActorDescription); - return Nothing(); - } - - if (static_cast(listener)->GetProtocolTypeId() != aProtocolTypeId) { - MismatchedActorTypeError(aActorDescription); - return Nothing(); - } - - return Some(listener); -} - #if defined(XP_WIN) // This is a restricted version of Windows' DuplicateHandle() function // that works inside the sandbox and can send handles but not retrieve diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index 5043171d2f50..1a8cf3399db2 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -1093,13 +1093,8 @@ class Protocol(ipdl.ast.Protocol): def fqListenerName(self): return 'mozilla::ipc::MessageListener' - def fqBaseClass(self): - return 'mozilla::ipc::IProtocol' - def managerInterfaceType(self, ptr=0): - return Type('mozilla::ipc::IProtocolManager', - ptr=ptr, - T=Type(self.fqBaseClass())) + return Type('mozilla::ipc::IProtocol', ptr=ptr) def openedProtocolInterfaceType(self, ptr=0): return Type('mozilla::ipc::IToplevelProtocol', @@ -2625,7 +2620,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): def standardTypedefs(self): return [ - Typedef(Type(self.protocol.fqBaseClass()), 'ProtocolBase'), + Typedef(Type('mozilla::ipc::IProtocol'), 'ProtocolBase'), Typedef(Type('IPC::Message'), 'Message'), Typedef(Type(self.protocol.channelName()), 'Channel'), Typedef(Type(self.protocol.fqListenerName()), 'ChannelListener'), @@ -2826,8 +2821,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): self.cls = Class( self.clsname, - inherits=[ Inherit(Type(p.fqBaseClass()), viz='public'), - Inherit(p.managerInterfaceType(), viz='protected') ] + + inherits=[ Inherit(p.managerInterfaceType(), viz='public') ] + optinherits, abstract=True) diff --git a/js/ipc/WrapperOwner.h b/js/ipc/WrapperOwner.h index f2f1cb9ce150..79088b5be7ab 100644 --- a/js/ipc/WrapperOwner.h +++ b/js/ipc/WrapperOwner.h @@ -20,8 +20,7 @@ namespace jsipc { class WrapperOwner : public virtual JavaScriptShared { public: - typedef mozilla::ipc::IProtocolManager< - mozilla::ipc::IProtocol>::ActorDestroyReason + typedef mozilla::ipc::IProtocol::ActorDestroyReason ActorDestroyReason; WrapperOwner();