Bug 1550560 (https://bugzilla.mozilla.org/show_bug.cgi?id=1550560) landed
recently, adding native support for declaring actors as *refcounted*. This
change improves the ergonomics for declaring and using IPDL actors, and
opens avenues for future improvements to the IPC core. *refcounted* is the
recommended way to define the lifecycle for an actor, and may become the
default in the future. The syntax currently looks as-follows:

async *refcounted* protocol PBrowserBridge {
https://searchfox.org/mozilla-central/rev/b38e3beb658b80e1ed03e0fdf64d225bd4a40327/dom/ipc/PBrowserBridge.ipdl#33

Adding this attribute has the following impacts:

   1. Generated actor classes have pure-virtual *AddRef* and *Release*
   methods to be overridden by the implementation.
   2. *AllocPFoo* methods return *already_AddRefed<PFoo>* instead of *PFoo**
   .
   3. No *DeallocPFoo* methods will be generated or called on the manager
   class.
   4. IPDL will automatically obtain a single reference to the actor when
   its underlying connection is established, and will release it when the
   actor is no longer in use by IPC.
   5. The "helper constructor" is no longer generated, so *AllocPFoo*
   methods on the constructor sender side, which are often implemented as
   *MOZ_ASSERT_UNREACHABLE()*, may be removed. This may require consumers
   of the helper constructor to slightly modify their code.

I have converted 16 actors to use this new annotation in bug 1570369 (
https://bugzilla.mozilla.org/show_bug.cgi?id=1570369). Patches on this bug,
such as https://phabricator.services.mozilla.com/D40263, can be used as a
reference when converting your actor.

Please reach out to me (:nika) on IRC or Slack if you have questions or
encounter bugs when converting your actor.

Thanks!
Nika
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to