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:
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
for a refcounted type, specialize on the bare type:
static void Write(Message* aMsg, nsIPrincipal* aParam);
static bool Read(const Message* aMsg, PickleIterator* aIter,
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.