Closed Bug 1656349 Opened 4 months ago Closed 4 months ago

Refactor the IPC lifetimes for the PGamepadEventChannel object

Categories

(Core :: DOM: Device Interfaces, task)

task

Tracking

()

RESOLVED FIXED
81 Branch
Tracking Status
firefox81 --- fixed

People

(Reporter: cmartin, Assigned: cmartin)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

The logic that handles the IPC lifetimes for GamepadEventChannelParent can be simplified:

The initialization is currently done in a separate RecvGamepadListenerAdded() message, but that message is always sent directly after actor creation and so they should just be rolled together into the IPC constructor.

Likewise, destruction is handled in both ActorDestroy() and RecvGamepadListenerRemoved(), but there's no need for this - ActorDestroy() should handle all of the cleanup and the RecvGamepadListenerRemoved() should just be replaced with a Send__delete__() message in the client.

Doing this simplifies the lifetimes and gets rid of this awkward mHasGamepadListener variable that just exists to track whether or not the object is in a "zombie state". From now on, if the object exists it is valid.

Also, since we are now being deterministic about creating/deleting our object in a single location, there's no need to reference count it -- Its lifetime is predictable

Change the GamepadEventChannel so it is fully-initialized by the IPC
constuctor and needs no separate "init" message, and so its completely
destroyed by the ActorDestroy() message so it needs no "cleanup" message.

This simplifies the object lifetime, as well as unifies the IPC error vs
clean shutdown paths.

Depends on D83406

Attachment #9167139 - Attachment is obsolete: true

Change the GamepadEventChannel so it is fully-initialized by the IPC
constuctor and needs no separate "init" message, and so its completely
destroyed by the ActorDestroy() message so it needs no "cleanup" message.

This simplifies the object lifetime, as well as unifies the IPC error vs
clean shutdown paths.

Pushed by cmartin@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/562a834a3692
Refactor the IPC lifetimes for the PGamepadEventChannel object r=daoshengmu
Pushed by cmartin@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/82e451b5e01d
Refactor the IPC lifetimes for the PGamepadEventChannel object r=daoshengmu
Status: NEW → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch
Flags: needinfo?(cmartin)
You need to log in before you can comment on or make changes to this bug.