Bug 2056357 - Part 1: Unify IPDL actor devirutalization logic, and require types to be fully qualified, r=ipc-reviewers,necko-reviewers,dom-storage-reviewers,jesup,mccr8
The devirtualization logic which was previously used was imprecise, and previously didn't require the type name to be fully qualified. This patch updates the logic to require full qualification of the type from IPDL, which will be necessary for later parts. Differential Revision: https://phabricator.services.mozilla.com/D316602
This commit is contained in:
committed by
nlayzell@mozilla.com
parent
21c2372e31
commit
bba02ee0e4
@@ -62,7 +62,7 @@ union FileSystemResponseValue
|
||||
FileSystemErrorResponse;
|
||||
};
|
||||
|
||||
[ChildImpl="FileSystemTaskChildBase"]
|
||||
[ChildImpl="mozilla::dom::FileSystemTaskChildBase"]
|
||||
protocol PFileSystemRequest
|
||||
{
|
||||
manager PBackground;
|
||||
|
||||
@@ -79,7 +79,7 @@ union CursorResponse
|
||||
IndexKeyCursorResponse[];
|
||||
};
|
||||
|
||||
[ChildImpl="indexedDB::BackgroundCursorChildBase", ParentImpl=virtual]
|
||||
[ChildImpl="mozilla::dom::indexedDB::BackgroundCursorChildBase", ParentImpl=virtual]
|
||||
protocol PBackgroundIDBCursor
|
||||
{
|
||||
manager PBackgroundIDBTransaction or PBackgroundIDBVersionChangeTransaction;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
namespace indexedDB {
|
||||
|
||||
[ChildImpl="indexedDB::BackgroundDatabaseChild", ParentImpl=virtual]
|
||||
[ChildImpl="mozilla::dom::indexedDB::BackgroundDatabaseChild", ParentImpl=virtual]
|
||||
sync protocol PBackgroundIDBDatabase
|
||||
{
|
||||
manager PBackgroundIDBFactory;
|
||||
|
||||
@@ -46,7 +46,7 @@ union GetDatabasesResponse
|
||||
DatabaseMetadata[];
|
||||
};
|
||||
|
||||
[ChildImpl="indexedDB::BackgroundFactoryChild", ParentImpl=virtual]
|
||||
[ChildImpl="mozilla::dom::indexedDB::BackgroundFactoryChild", ParentImpl=virtual]
|
||||
sync protocol PBackgroundIDBFactory
|
||||
{
|
||||
manager PBackground;
|
||||
|
||||
@@ -30,7 +30,7 @@ union FactoryRequestResponse
|
||||
DeleteDatabaseRequestResponse;
|
||||
};
|
||||
|
||||
[ManualDealloc, ChildImpl="indexedDB::BackgroundFactoryRequestChild", ParentImpl=virtual]
|
||||
[ManualDealloc, ChildImpl="mozilla::dom::indexedDB::BackgroundFactoryRequestChild", ParentImpl=virtual]
|
||||
protocol PBackgroundIDBFactoryRequest
|
||||
{
|
||||
manager PBackgroundIDBFactory;
|
||||
|
||||
@@ -160,7 +160,7 @@ union PreprocessResponse
|
||||
ObjectStoreGetAllPreprocessResponse;
|
||||
};
|
||||
|
||||
[ManualDealloc, ChildImpl="indexedDB::BackgroundRequestChild", ParentImpl=virtual]
|
||||
[ManualDealloc, ChildImpl="mozilla::dom::indexedDB::BackgroundRequestChild", ParentImpl=virtual]
|
||||
protocol PBackgroundIDBRequest
|
||||
{
|
||||
manager PBackgroundIDBTransaction or PBackgroundIDBVersionChangeTransaction;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
namespace indexedDB {
|
||||
|
||||
[ChildImpl="indexedDB::BackgroundTransactionChild", ParentImpl=virtual]
|
||||
[ChildImpl="mozilla::dom::indexedDB::BackgroundTransactionChild", ParentImpl=virtual]
|
||||
protocol PBackgroundIDBTransaction {
|
||||
manager PBackgroundIDBDatabase;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
namespace indexedDB {
|
||||
|
||||
[ChildImpl="indexedDB::BackgroundVersionChangeTransactionChild", ParentImpl=virtual]
|
||||
[ChildImpl="mozilla::dom::indexedDB::BackgroundVersionChangeTransactionChild", ParentImpl=virtual]
|
||||
protocol PBackgroundIDBVersionChangeTransaction {
|
||||
manager PBackgroundIDBDatabase;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
namespace indexedDB {
|
||||
|
||||
[ManualDealloc, ChildImpl="indexedDB::BackgroundUtilsChild", ParentImpl=virtual]
|
||||
[ManualDealloc, ChildImpl="mozilla::dom::indexedDB::BackgroundUtilsChild", ParentImpl=virtual]
|
||||
sync protocol PBackgroundIndexedDBUtils
|
||||
{
|
||||
manager PBackground;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
||||
[ManualDealloc, ChildImpl="URLClassifierLocalChild", ParentImpl="URLClassifierLocalParent"]
|
||||
[ManualDealloc, ChildImpl="mozilla::dom::URLClassifierLocalChild", ParentImpl="mozilla::dom::URLClassifierLocalParent"]
|
||||
protocol PURLClassifierLocal
|
||||
{
|
||||
manager PContent;
|
||||
|
||||
@@ -14,7 +14,7 @@ include "mozilla/dom/URLClassifierChild.h";
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
[ManualDealloc, ChildImpl="URLClassifierLocalByNameChild", ParentImpl="URLClassifierLocalByNameParent"]
|
||||
[ManualDealloc, ChildImpl="mozilla::dom::URLClassifierLocalByNameChild", ParentImpl="mozilla::dom::URLClassifierLocalByNameParent"]
|
||||
protocol PURLClassifierLocalByName
|
||||
{
|
||||
manager PContent;
|
||||
|
||||
@@ -19,7 +19,7 @@ using cdm::Status from "GMPSanitizedExports.h";
|
||||
namespace mozilla {
|
||||
namespace gmp {
|
||||
|
||||
[ChildImpl=virtual, ParentImpl="ChromiumCDMParent"]
|
||||
[ChildImpl=virtual, ParentImpl="mozilla::gmp::ChromiumCDMParent"]
|
||||
async protocol PChromiumCDM
|
||||
{
|
||||
manager PGMPContent;
|
||||
|
||||
@@ -25,7 +25,7 @@ using mozilla::dom::NativeThreadId from "mozilla/dom/NativeThreadId.h";
|
||||
namespace mozilla {
|
||||
namespace gmp {
|
||||
|
||||
[NeedsOtherPid, NestedUpTo=inside_sync, ChildImpl="GMPChild", ParentImpl="GMPParent", ChildProc=GMPlugin]
|
||||
[NeedsOtherPid, NestedUpTo=inside_sync, ChildImpl="mozilla::gmp::GMPChild", ParentImpl="mozilla::gmp::GMPParent", ChildProc=GMPlugin]
|
||||
sync protocol PGMP
|
||||
{
|
||||
manages PGMPTimer;
|
||||
|
||||
@@ -15,7 +15,7 @@ include "GMPContentChild.h";
|
||||
namespace mozilla {
|
||||
namespace gmp {
|
||||
|
||||
[NeedsOtherPid, ChildImpl="GMPContentChild", ParentImpl=virtual, ParentProc=anydom, ChildProc=GMPlugin]
|
||||
[NeedsOtherPid, ChildImpl="mozilla::gmp::GMPContentChild", ParentImpl=virtual, ParentProc=anydom, ChildProc=GMPlugin]
|
||||
sync protocol PGMPContent
|
||||
{
|
||||
manages PGMPVideoDecoder;
|
||||
|
||||
@@ -12,7 +12,7 @@ using GMPErr from "gmp-errors.h";
|
||||
namespace mozilla {
|
||||
namespace gmp {
|
||||
|
||||
[ChildImpl="GMPStorageChild", ParentImpl=virtual]
|
||||
[ChildImpl="mozilla::gmp::GMPStorageChild", ParentImpl=virtual]
|
||||
async protocol PGMPStorage
|
||||
{
|
||||
manager PGMP;
|
||||
|
||||
@@ -10,7 +10,7 @@ include "GMPTimerChild.h";
|
||||
namespace mozilla {
|
||||
namespace gmp {
|
||||
|
||||
[ChildImpl="GMPTimerChild", ParentImpl="GMPTimerParent"]
|
||||
[ChildImpl="mozilla::gmp::GMPTimerChild", ParentImpl="mozilla::gmp::GMPTimerParent"]
|
||||
async protocol PGMPTimer
|
||||
{
|
||||
manager PGMP;
|
||||
|
||||
@@ -14,7 +14,7 @@ include "GMPVideoDecoderChild.h";
|
||||
namespace mozilla {
|
||||
namespace gmp {
|
||||
|
||||
[ChildImpl="GMPVideoDecoderChild", ParentImpl=virtual]
|
||||
[ChildImpl="mozilla::gmp::GMPVideoDecoderChild", ParentImpl=virtual]
|
||||
async protocol PGMPVideoDecoder
|
||||
{
|
||||
manager PGMPContent;
|
||||
|
||||
@@ -15,7 +15,7 @@ include "GMPVideoEncoderChild.h";
|
||||
namespace mozilla {
|
||||
namespace gmp {
|
||||
|
||||
[ChildImpl="GMPVideoEncoderChild", ParentImpl=virtual]
|
||||
[ChildImpl="mozilla::gmp::GMPVideoEncoderChild", ParentImpl=virtual]
|
||||
async protocol PGMPVideoEncoder
|
||||
{
|
||||
manager PGMPContent;
|
||||
|
||||
@@ -54,7 +54,7 @@ union EncodeResultIPDL
|
||||
// The child side runs in the content process, and the parent side runs
|
||||
// in the RDD/utility/GPU processes. We run a separate IPDL thread for both
|
||||
// sides.
|
||||
[ChildImpl="RemoteMediaDataEncoderChild", ParentImpl="RemoteMediaDataEncoderParent"]
|
||||
[ChildImpl="mozilla::RemoteMediaDataEncoderChild", ParentImpl="mozilla::RemoteMediaDataEncoderParent"]
|
||||
async protocol PRemoteEncoder
|
||||
{
|
||||
manager PRemoteMediaManager;
|
||||
|
||||
@@ -11,7 +11,7 @@ include "mozilla/media/MediaChild.h";
|
||||
namespace mozilla {
|
||||
namespace media {
|
||||
|
||||
[ManualDealloc, ChildImpl="Child", ParentImpl=virtual]
|
||||
[ManualDealloc, ChildImpl="mozilla::media::Child", ParentImpl=virtual]
|
||||
protocol PMedia
|
||||
{
|
||||
manager PContent;
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
include protocol PBackground;
|
||||
|
||||
include "mozilla/dom/MediaTransportChild.h";
|
||||
include "mozilla/dom/MediaTransportParent.h";
|
||||
|
||||
#ifdef MOZ_WEBRTC
|
||||
include WebrtcProxyConfig;
|
||||
|
||||
@@ -50,7 +53,7 @@ struct IceCandidateAttributePair {
|
||||
};
|
||||
#endif // MOZ_WEBRTC
|
||||
|
||||
[ParentProc=Socket, ChildProc=Content]
|
||||
[ParentProc=Socket, ChildProc=Content, ParentImpl="mozilla::MediaTransportParent", ChildImpl="mozilla::MediaTransportChild"]
|
||||
async protocol PMediaTransport {
|
||||
#ifdef MOZ_WEBRTC
|
||||
parent:
|
||||
|
||||
@@ -7,7 +7,7 @@ include protocol PBackground;
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
[ChildImpl="SessionStorageService"]
|
||||
[ChildImpl="mozilla::dom::SessionStorageService"]
|
||||
protocol PBackgroundSessionStorageService
|
||||
{
|
||||
manager PBackground;
|
||||
|
||||
@@ -9,7 +9,7 @@ include "mozilla/RemoteSpellCheckEngineChild.h";
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
[ManualDealloc, ChildImpl="RemoteSpellcheckEngineChild", ParentImpl="RemoteSpellcheckEngineParent"]
|
||||
[ManualDealloc, ChildImpl="mozilla::RemoteSpellcheckEngineChild", ParentImpl="mozilla::RemoteSpellcheckEngineParent"]
|
||||
sync protocol PRemoteSpellcheckEngine {
|
||||
manager PContent;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace layers {
|
||||
* are implemented. If a new method is needed then PAPZ, APZChild, and RemoteContentController
|
||||
* must be updated to handle it.
|
||||
*/
|
||||
[ParentImpl="RemoteContentController"]
|
||||
[ParentImpl="mozilla::layers::RemoteContentController"]
|
||||
sync protocol PAPZ
|
||||
{
|
||||
manager PCompositorBridge;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace layers {
|
||||
/**
|
||||
* PCanvas is the IPDL for recorded Canvas drawing.
|
||||
*/
|
||||
[ParentImpl="CanvasTranslator"]
|
||||
[ParentImpl="mozilla::layers::CanvasTranslator"]
|
||||
async protocol PCanvas {
|
||||
manager PCanvasManager;
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ struct FrameStats {
|
||||
* protocol, which is per-browser. A lot of the functions in the protocol are
|
||||
* basically multiplexing/demultiplexing stuff in PLayerTransaction.
|
||||
*/
|
||||
[ParentImpl="CompositorBridgeParentBase"]
|
||||
[ParentImpl="mozilla::layers::CompositorBridgeParentBase"]
|
||||
sync protocol PCompositorBridge
|
||||
{
|
||||
manager PCompositorManager;
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ include protocol PVRGPU;
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
[NeedsOtherPid, ChildImpl="VRChild", ParentImpl="VRParent", ParentProc=VR, ChildProc=Parent]
|
||||
[NeedsOtherPid, ChildImpl="mozilla::gfx::VRChild", ParentImpl="mozilla::gfx::VRParent", ParentProc=VR, ChildProc=Parent]
|
||||
async protocol PVR
|
||||
{
|
||||
parent:
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace gfx {
|
||||
|
||||
// The parent process is the VR process.
|
||||
// The child process is the GPU process.
|
||||
[NeedsOtherPid, ChildImpl="VRGPUChild", ParentImpl="VRGPUParent", ParentProc=VR, ChildProc=GPU]
|
||||
[NeedsOtherPid, ChildImpl="mozilla::gfx::VRGPUChild", ParentImpl="mozilla::gfx::VRGPUParent", ParentProc=VR, ChildProc=GPU]
|
||||
async protocol PVRGPU
|
||||
{
|
||||
parent:
|
||||
@@ -24,4 +24,4 @@ child:
|
||||
};
|
||||
|
||||
} // gfx
|
||||
} // mozilla
|
||||
} // mozilla
|
||||
|
||||
@@ -13,7 +13,7 @@ using mozilla::gfx::Rect from "mozilla/gfx/Rect.h";
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
[ChildImpl="VRLayerChild", ParentImpl=virtual]
|
||||
[ChildImpl="mozilla::gfx::VRLayerChild", ParentImpl=virtual]
|
||||
async protocol PVRLayer
|
||||
{
|
||||
manager PVRManager;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace gfx {
|
||||
* enumeration and sensor state between the compositor thread and
|
||||
* content threads/processes.
|
||||
*/
|
||||
[NeedsOtherPid, ChildImpl="VRManagerChild", ParentImpl="VRManagerParent", ParentProc=compositor, ChildProc=anydom]
|
||||
[NeedsOtherPid, ChildImpl="mozilla::gfx::VRManagerChild", ParentImpl="mozilla::gfx::VRManagerParent", ParentProc=compositor, ChildProc=anydom]
|
||||
sync protocol PVRManager
|
||||
{
|
||||
manages PVRLayer;
|
||||
|
||||
+31
-25
@@ -3246,6 +3246,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
self.cppfile = None
|
||||
self.ns = None
|
||||
self.cls = None
|
||||
self.concreteActorType = None
|
||||
self.protocolCxxIncludes = []
|
||||
self.actorForwardDecls = []
|
||||
self.usingDecls = []
|
||||
@@ -3356,18 +3357,6 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
|
||||
self.hdrfile.addthings([traitsdecl, Whitespace.NL] + _includeGuardEnd(hf))
|
||||
|
||||
# If the implementation type is not overridden, add an implicit import
|
||||
# for the default implementation header file. Explicit implementation
|
||||
# types will specify their headers manually with `include`.
|
||||
if self.protocol.implAttribute(self.side) is None:
|
||||
assert self.protocol.name.startswith("P")
|
||||
self.externalIncludes.add(
|
||||
"".join(n.name + "/" for n in self.protocol.namespaces)
|
||||
+ self.protocol.name[1:]
|
||||
+ self.side.capitalize()
|
||||
+ ".h"
|
||||
)
|
||||
|
||||
# make the .cpp file
|
||||
cf.addthings(
|
||||
[
|
||||
@@ -3520,6 +3509,30 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
Whitespace.NL,
|
||||
])
|
||||
|
||||
implAttr = self.protocol.implAttribute(self.side)
|
||||
if implAttr is None:
|
||||
assert self.protocol.name.startswith("P")
|
||||
pqname = self.protocol.qname()
|
||||
self.concreteActorType = ipdl.ast.QualifiedId(
|
||||
pqname.loc, pqname.baseid[1:] + self.side.title(), pqname.quals
|
||||
)
|
||||
|
||||
# If the implementation type is not overridden, add an implicit
|
||||
# import for the default implementation header file. Explicit
|
||||
# implementation types will specify their headers manually with
|
||||
# `include`.
|
||||
self.externalIncludes.add(
|
||||
"/".join(
|
||||
self.concreteActorType.quals
|
||||
+ [self.concreteActorType.baseid + ".h"]
|
||||
)
|
||||
)
|
||||
elif implAttr != "virtual":
|
||||
parts = implAttr.value.split("::")
|
||||
self.concreteActorType = ipdl.ast.QualifiedId(
|
||||
implAttr.loc, parts[-1], parts[:-1]
|
||||
)
|
||||
|
||||
self.cls = Class(self.clsname, inherits=inherits, abstract=True)
|
||||
|
||||
self.cls.addstmt(Label.PRIVATE)
|
||||
@@ -3604,7 +3617,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
defaultRecv = MethodDefn(recvDecl)
|
||||
defaultRecv.addcode("return IPC_OK();\n")
|
||||
self.cls.addstmt(defaultRecv)
|
||||
elif self.protocol.implAttribute(self.side) == "virtual":
|
||||
elif self.concreteActorType is None:
|
||||
# If we're using virtual calls, we need the methods to be
|
||||
# declared on the base class.
|
||||
recvDecl.methodspec = MethodSpec.PURE
|
||||
@@ -3612,7 +3625,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
|
||||
# If we're using virtual calls, we need the methods to be declared on
|
||||
# the base class.
|
||||
if self.protocol.implAttribute(self.side) == "virtual":
|
||||
if self.concreteActorType is None:
|
||||
for md in p.messageDecls:
|
||||
managed = md.decl.type.constructedType()
|
||||
if not ptype.isManagerOf(managed) or md.decl.type.isDtor():
|
||||
@@ -4287,18 +4300,11 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
##
|
||||
|
||||
def concreteThis(self):
|
||||
implAttr = self.protocol.implAttribute(self.side)
|
||||
if implAttr == "virtual":
|
||||
if self.concreteActorType is None:
|
||||
return ExprVar.THIS
|
||||
|
||||
if implAttr is None:
|
||||
assert self.protocol.name.startswith("P")
|
||||
className = self.protocol.name[1:] + self.side.capitalize()
|
||||
else:
|
||||
assert isinstance(implAttr, ipdl.ast.StringLiteral)
|
||||
className = implAttr.value
|
||||
|
||||
return ExprCode("static_cast<${className}*>(this)", className=className)
|
||||
return ExprCast(
|
||||
ExprVar.THIS, Type(str(self.concreteActorType), ptr=True), static=True
|
||||
)
|
||||
|
||||
def thisCall(self, function, args):
|
||||
return ExprCall(ExprSelect(self.concreteThis(), "->", function), args=args)
|
||||
|
||||
@@ -9,7 +9,7 @@ include "mozilla/ipc/TestShellParent.h";
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
[ManualDealloc, ChildImpl=virtual, ParentImpl="TestShellCommandParent"]
|
||||
[ManualDealloc, ChildImpl=virtual, ParentImpl="mozilla::ipc::TestShellCommandParent"]
|
||||
protocol PTestShellCommand
|
||||
{
|
||||
manager PTestShell;
|
||||
|
||||
@@ -21,7 +21,7 @@ struct ScriptData {
|
||||
uint8_t[] xdrData;
|
||||
};
|
||||
|
||||
[ManualDealloc, ChildImpl="ScriptCacheChild", ParentImpl="ScriptCacheParent"]
|
||||
[ManualDealloc, ChildImpl="mozilla::loader::ScriptCacheChild", ParentImpl="mozilla::loader::ScriptCacheParent"]
|
||||
protocol PScriptCache
|
||||
{
|
||||
manager PContent;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace net {
|
||||
* again. Hence there's no need for any messages on the protocol itself.
|
||||
*/
|
||||
|
||||
[ManualDealloc, ChildImpl="TransportProviderChild", ParentImpl="TransportProviderParent"]
|
||||
[ManualDealloc, ChildImpl="mozilla::net::TransportProviderChild", ParentImpl="mozilla::net::TransportProviderParent"]
|
||||
async protocol PTransportProvider
|
||||
{
|
||||
manager PNecko;
|
||||
|
||||
@@ -17,7 +17,7 @@ using class IPC::SerializedLoadContext from "SerializedLoadContext.h";
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
[ManualDealloc, ChildImpl="WebSocketChannelChild", ParentImpl="WebSocketChannelParent"]
|
||||
[ManualDealloc, ChildImpl="mozilla::net::WebSocketChannelChild", ParentImpl="mozilla::net::WebSocketChannelParent"]
|
||||
async protocol PWebSocket
|
||||
{
|
||||
manager PNecko;
|
||||
|
||||
Reference in New Issue
Block a user