From fef1bfd95467da95244fb74d11cf815078731637 Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Fri, 28 Feb 2020 11:44:51 +0000 Subject: [PATCH] Bug 1579042 - Rename FrameTargetProxyActor to TabDescriptorActor r=ochameau Differential Revision: https://phabricator.services.mozilla.com/D63498 --HG-- rename : devtools/server/actors/targets/frame-proxy.js => devtools/server/actors/descriptors/tab.js extra : moz-landing-system : lando --- devtools/docs/backend/actor-hierarchy.md | 2 +- devtools/server/actors/descriptors/moz.build | 1 + .../frame-proxy.js => descriptors/tab.js} | 47 ++++++++----------- devtools/server/actors/targets/moz.build | 1 - devtools/server/actors/webbrowser.js | 12 ++--- 5 files changed, 27 insertions(+), 36 deletions(-) rename devtools/server/actors/{targets/frame-proxy.js => descriptors/tab.js} (82%) diff --git a/devtools/docs/backend/actor-hierarchy.md b/devtools/docs/backend/actor-hierarchy.md index ef2ae2c37cd1..123f86a8fe2c 100644 --- a/devtools/docs/backend/actor-hierarchy.md +++ b/devtools/docs/backend/actor-hierarchy.md @@ -52,7 +52,7 @@ and returns its `actorID`. That's the main role of RootActor. ``` RootActor (root.js) | - |-- FrameTargetActorProxy (frame-proxy.js) + |-- TabDescriptorActor (descriptors/tab.js) | Targets frames (such as a tab) living in the parent or child process. | Note that this is just a proxy for FrameTargetActor, which is loaded via | the frame's message manager as a frame script in the process containing diff --git a/devtools/server/actors/descriptors/moz.build b/devtools/server/actors/descriptors/moz.build index 61a311a7f929..83ac853a6135 100644 --- a/devtools/server/actors/descriptors/moz.build +++ b/devtools/server/actors/descriptors/moz.build @@ -7,6 +7,7 @@ DevToolsModules( 'frame.js', 'process.js', + 'tab.js', 'webextension.js', ) diff --git a/devtools/server/actors/targets/frame-proxy.js b/devtools/server/actors/descriptors/tab.js similarity index 82% rename from devtools/server/actors/targets/frame-proxy.js rename to devtools/server/actors/descriptors/tab.js index 65932a2984e2..a79345c58c4a 100644 --- a/devtools/server/actors/targets/frame-proxy.js +++ b/devtools/server/actors/descriptors/tab.js @@ -5,7 +5,7 @@ "use strict"; /* - * Target actor proxy that represents a frame / docShell in the parent process. It + * Descriptor Actor that represents a Tab in the parent process. It * launches a FrameTargetActor in the content process to do the real work and tunnels the * data. * @@ -15,7 +15,6 @@ const { connectToFrame, } = require("devtools/server/connectors/frame-connector"); -const protocol = require("devtools/shared/protocol"); loader.lazyImporter( this, @@ -35,28 +34,19 @@ const { AppConstants } = require("resource://gre/modules/AppConstants.jsm"); * @param options * - {Boolean} favicons: true if the form should include the favicon for the tab. */ -// As this proxy is returned by RootActor.listTabs, it has to be inheriting from Actor -// class in order to be correctly marshalled by protocol.js. -// This is related to this very particular check in protocol.js: -// https://searchfox.org/mozilla-central/rev/b243debf6235b050b42fd2eb615fdc729636ca6b/devtools/shared/protocol/types.js#354-367 -// But this isn't a real Actor. Only `form()` method is being called when protocol.js -// marshall the proxy. We also register the proxy into Pools and so `typeName` -// as well as `actorID` attributes are being used in this process. -const proxySpec = protocol.generateActorSpec({ - typeName: "frameTargetProxy", - methods: {}, - events: {}, -}); -exports.FrameTargetActorProxy = protocol.ActorClassWithSpec(proxySpec, { - initialize: function(conn, browser, options = {}) { - protocol.Actor.prototype.initialize.call(this, conn); +function TabDescriptorActor(connection, browser, options = {}) { + this._conn = connection; + this._browser = browser; + this._form = null; + this.exited = false; + this.options = options; +} - this._conn = conn; - this._browser = browser; - this._form = null; - this.exited = false; - this.options = options; - }, +TabDescriptorActor.prototype = { + // As these proxies are added to pools, they are considered as actors and should have + // a prefix set, even if that's never really used. TabDescriptorActor's actorID is going + // to be used in form(). + actorPrefix: "tabDescriptor", async connect() { const onDestroy = () => { @@ -64,8 +54,7 @@ exports.FrameTargetActorProxy = protocol.ActorClassWithSpec(proxySpec, { // Reject the update promise if the tab was destroyed while requesting an update this._deferredUpdate.reject({ error: "tabDestroyed", - message: - "Tab destroyed while performing a FrameTargetActorProxy update", + message: "Tab destroyed while performing a TabDescriptorActor update", }); } this.exit(); @@ -116,10 +105,10 @@ exports.FrameTargetActorProxy = protocol.ActorClassWithSpec(proxySpec, { /** * @param {Object} options - * See FrameTargetActorProxy constructor. + * See TabDescriptorActor constructor. */ async update(options = {}) { - // Update the FrameTargetActorProxy options. + // Update the TabDescriptorActor options. this.options = options; // If the child happens to be crashed/close/detach, it won't have _form set, @@ -252,4 +241,6 @@ exports.FrameTargetActorProxy = protocol.ActorClassWithSpec(proxySpec, { this._form = null; this.exited = true; }, -}); +}; + +exports.TabDescriptorActor = TabDescriptorActor; diff --git a/devtools/server/actors/targets/moz.build b/devtools/server/actors/targets/moz.build index fe4cf9b07c5b..32c2725a1927 100644 --- a/devtools/server/actors/targets/moz.build +++ b/devtools/server/actors/targets/moz.build @@ -8,7 +8,6 @@ DevToolsModules( 'browsing-context.js', 'chrome-window.js', 'content-process.js', - 'frame-proxy.js', 'frame.js', 'parent-process.js', 'webextension.js', diff --git a/devtools/server/actors/webbrowser.js b/devtools/server/actors/webbrowser.js index ffe07ac31024..884ecc846fcc 100644 --- a/devtools/server/actors/webbrowser.js +++ b/devtools/server/actors/webbrowser.js @@ -18,8 +18,8 @@ loader.lazyRequireGetter( ); loader.lazyRequireGetter( this, - "FrameTargetActorProxy", - "devtools/server/actors/targets/frame-proxy", + "TabDescriptorActor", + "devtools/server/actors/descriptors/tab", true ); loader.lazyRequireGetter( @@ -110,7 +110,7 @@ exports.createRootActor = function createRootActor(connection) { }; /** - * A live list of FrameTargetActorProxys representing the current browser tabs, + * A live list of TabDescriptorActors representing the current browser tabs, * to be provided to the root actor to answer 'listTabs' requests. * * This object also takes care of listening for TabClose events and @@ -345,7 +345,7 @@ BrowserTabList.prototype.getList = function(browserActorOptions) { }; /** - * @param browserActorOptions see options argument of FrameTargetActorProxy constructor. + * @param browserActorOptions see options argument of TabDescriptorActor constructor. */ BrowserTabList.prototype._getActorForBrowser = function( browser, @@ -358,7 +358,7 @@ BrowserTabList.prototype._getActorForBrowser = function( return actor.update(browserActorOptions); } - actor = new FrameTargetActorProxy( + actor = new TabDescriptorActor( this._connection, browser, browserActorOptions @@ -468,7 +468,7 @@ BrowserTabList.prototype._handleActorClose = function(actor, browser) { if (this._testing) { if (this._actorByBrowser.get(browser) !== actor) { throw new Error( - "FrameTargetActorProxy not stored in map under given browser" + "TabDescriptorActor not stored in map under given browser" ); } if (actor.browser !== browser) {