зеркало из https://github.com/mozilla/gecko-dev.git
Bug 792652 - Simplify IPDL type hierarchy (r=dvander)
Currently all our protocols inherit from IProtocolManager<IProtocol>. I have no idea why. This patch switches everything over to IProtocol, without any templates. I had to move ReadActor to the .cpp file to avoid redefinition errors.
This commit is contained in:
Родитель
1a00da8679
Коммит
2dc5f495db
|
@ -33,7 +33,7 @@ protected:
|
|||
bool RecvReadback(const SurfaceDescriptorGPUVideo& aSD, SurfaceDescriptor* aResult) override;
|
||||
bool RecvDeallocateSurfaceDescriptorGPUVideo(const SurfaceDescriptorGPUVideo& aSD) override;
|
||||
|
||||
void ActorDestroy(mozilla::ipc::IProtocolManager<mozilla::ipc::IProtocol>::ActorDestroyReason) override {}
|
||||
void ActorDestroy(mozilla::ipc::IProtocol::ActorDestroyReason) override {}
|
||||
|
||||
void DeallocPVideoDecoderManagerParent() override;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class OriginKeyStore;
|
|||
|
||||
class NonE10s
|
||||
{
|
||||
typedef mozilla::ipc::IProtocolManager<mozilla::ipc::IProtocol>::ActorDestroyReason
|
||||
typedef mozilla::ipc::IProtocol::ActorDestroyReason
|
||||
ActorDestroyReason;
|
||||
public:
|
||||
virtual ~NonE10s() {}
|
||||
|
@ -45,7 +45,7 @@ protected:
|
|||
template<class Super>
|
||||
class Parent : public Super
|
||||
{
|
||||
typedef mozilla::ipc::IProtocolManager<mozilla::ipc::IProtocol>::ActorDestroyReason
|
||||
typedef mozilla::ipc::IProtocol::ActorDestroyReason
|
||||
ActorDestroyReason;
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Parent<Super>)
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
typedef ipc::IProtocolManager<ipc::IProtocol>::ActorDestroyReason Why;
|
||||
typedef ipc::IProtocol::ActorDestroyReason Why;
|
||||
|
||||
virtual void ActorDestroy(Why) override {
|
||||
DestroyIfNeeded();
|
||||
|
|
|
@ -365,5 +365,38 @@ TableToArray(const nsTHashtable<nsPtrHashKey<void>>& aTable,
|
|||
}
|
||||
}
|
||||
|
||||
Maybe<IProtocol*>
|
||||
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<IProtocol*>(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
|
||||
|
|
|
@ -130,8 +130,7 @@ struct Trigger
|
|||
uint32_t mMessage : 31;
|
||||
};
|
||||
|
||||
template<class ListenerT>
|
||||
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<ListenerT*> ReadActor(const IPC::Message* aMessage, PickleIterator* aIter, bool aNullable,
|
||||
Maybe<IProtocol*> 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 PFooSide>
|
||||
class Endpoint;
|
||||
|
||||
|
@ -319,40 +311,6 @@ UnpackChannelOpened(const PrivateIPDLInterface&,
|
|||
const IPC::Message&,
|
||||
TransportDescriptor*, base::ProcessId*, ProtocolId*);
|
||||
|
||||
template<typename ListenerT>
|
||||
Maybe<ListenerT*>
|
||||
IProtocolManager<ListenerT>::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<ListenerT*>(nullptr));
|
||||
}
|
||||
|
||||
ListenerT* listener = this->Lookup(id);
|
||||
if (!listener) {
|
||||
ActorLookupError(aActorDescription);
|
||||
return Nothing();
|
||||
}
|
||||
|
||||
if (static_cast<MessageListener*>(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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Загрузка…
Ссылка в новой задаче