Earlier this week, bug 1443954 <https://bugzilla.mozilla.org/show_bug.cgi?id=1443954> landed, which improved support in IPDL for reference counted types, making it safer and more ergonomic to directly use reference counted types (such as nsIURI, nsIPrincipal, nsIInputStream, etc.) in IPDL protocols.
To declare a dependency on a refcounted type in IPDL, use the `using refcounted` statement, for example: PContent.ipdl: <https://searchfox.org/mozilla-central/rev/9f3da81290054c5b8955bb67ff98cae66676f745/dom/ipc/PContent.ipdl#102> using refcounted class nsIInputStream from "mozilla/ipc/IPCStreamUtils.h"; The type can then be referenced by their name. These types are passed by raw pointer when used as an input, and passed by reference-to-RefPtr when used as an output. To implement ParamTraits (or IPDLParamTraits <https://searchfox.org/mozilla-central/rev/9f3da81290054c5b8955bb67ff98cae66676f745/ipc/glue/IPDLParamTraits.h#11-21>) for a refcounted type, specialize on the bare type: PermissionMessageUtils.h: <https://searchfox.org/mozilla-central/rev/9f3da81290054c5b8955bb67ff98cae66676f745/dom/ipc/PermissionMessageUtils.h#16-21> template<> struct ParamTraits<nsIPrincipal> { static void Write(Message* aMsg, nsIPrincipal* aParam); static bool Read(const Message* aMsg, PickleIterator* aIter, RefPtr<nsIPrincipal>* aResult); }; These types may also be used within IPDL unions and IPDL structs. Please prefer using these refcounted types directly over wrapper types like `IPC::Principal` when possible. - Nika _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform