Bug 1620248 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

Similarly to bug 1593937, which will help creating the BrowsingContextTargetActor before the document starts loading, we should do the same with ContentProcessTargetActor.
We should use the new watchTargets API on the actor side and do what is necessary on the server codebase to spawn the ContentProcessTargetActor the earliest. Then, the created targets will be notified to the frontend via the TargetList API.
Similarly to bug 1593937 and bug 1620248, which will help creating the BrowsingContextTargetActor before the process or document starts loading, we should do the same with ContentProcessTargetActor.

We should introduce a "(content) process target helper" over here:
https://searchfox.org/mozilla-central/source/devtools/server/actors/descriptors/watcher/target-helpers/
Which exposes 4 methods:
* createTargets
* destroyTargets
* watchResources
* unwatchResources
The `createTargets` and `destroyTargets` should create and destroy the Content Process Targets for the processes that already exist.
`watchResources` and `unwatchResources` should communicate the new watched/unwatched resources for all existing content process targets.

In parallel to that, we should have some code, which would watch all:
* new content process being created and call [WatcherActor.notifyTargetCreated](https://searchfox.org/mozilla-central/rev/21f2b48e01f2e14a94e8d39a665b56fcc08ecbdb/devtools/server/actors/descriptors/watcher/watcher.js#138)
* content process that have been destroyed and call [WatcherActor.notifyTargetDestroyed](https://searchfox.org/mozilla-central/rev/21f2b48e01f2e14a94e8d39a665b56fcc08ecbdb/devtools/server/actors/descriptors/watcher/watcher.js#142-147)
We might have to hook up into [WatcherRegistry](https://searchfox.org/mozilla-central/source/devtools/server/actors/descriptors/watcher/WatcherRegistry.jsm) in order to register/unregister this "content process watching" code. Similarly to how we register/unregister the DevToolsFrame JSWindow Actor. (Or see my other approach `maybeRegisterMessageListeners` in [the current prototype patch](https://phabricator.services.mozilla.com/D65529?vs=on&id=290273#toc))

While working on this, we might want to use the existing TargetList test in order to ensure it keeps working the same way as LegacyListener:
https://searchfox.org/mozilla-central/source/devtools/shared/resources/tests/browser_target_list_processes.js
The test looks quite complete but we might improve its coverage.

We might want to first start by migrating the existing codebase to JSProcessActor, but I'm not sure that is a good call.
I may be wrong, see comment 4 about that.

Otherwise, the main change here, will be the same as bug 1593937. It will be about reversing "connectFromParent" to "connectFromContent".
Instead of creating the target on-demand, via ProcessDescriptor.getTarget and initiate the creation from the parent process, we will create it when the process start, from the content process.

Back to Bug 1620248 Comment 0