Bug 1586468 Part 2 - Use observer service to listen for content process connects/disconnects, r=ochameau.

Depends on D48260

Differential Revision: https://phabricator.services.mozilla.com/D48262

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brian Hackett 2019-10-09 21:17:44 +00:00
Родитель 3dfef17d14
Коммит 4d9930a53d
3 изменённых файлов: 12 добавлений и 31 удалений

Просмотреть файл

@ -4,7 +4,8 @@
"use strict";
var { Cc } = require("chrome");
const { Cc } = require("chrome");
const Services = require("Services");
loader.lazyGetter(this, "ppmm", () => {
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService();
@ -14,10 +15,7 @@ function ProcessActorList() {
this._actors = new Map();
this._onListChanged = null;
this._mustNotify = false;
this._onMessage = this._onMessage.bind(this);
this._processScript =
"resource://devtools/server/startup/debug-new-process.js";
this._hasObserver = false;
}
ProcessActorList.prototype = {
@ -58,31 +56,24 @@ ProcessActorList.prototype = {
_checkListening: function() {
if (this._onListChanged !== null && this._mustNotify) {
this._knownProcesses = [];
for (let i = 0; i < ppmm.childCount; i++) {
this._knownProcesses.push(ppmm.getChildAt(i));
if (!this._hasObserver) {
Services.obs.addObserver(this, "ipc:content-created");
Services.obs.addObserver(this, "ipc:content-shutdown");
this._hasObserver = true;
}
ppmm.addMessageListener("debug:new-process", this._onMessage);
ppmm.loadProcessScript(this._processScript, true);
} else {
ppmm.removeMessageListener("debug:new-process", this._onMessage);
ppmm.removeDelayedProcessScript(this._processScript);
} else if (this._hasObserver) {
Services.obs.removeObserver(this, "ipc:content-created");
Services.obs.removeObserver(this, "ipc:content-shutdown");
this._hasObserver = false;
}
},
_notifyListChanged: function() {
observe() {
if (this._mustNotify) {
this._onListChanged();
this._mustNotify = false;
}
},
_onMessage: function({ target }) {
if (this._knownProcesses.includes(target)) {
return;
}
this._notifyListChanged();
},
};
exports.ProcessActorList = ProcessActorList;

Просмотреть файл

@ -1,9 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/* global sendAsyncMessage */
sendAsyncMessage("debug:new-process");

Просмотреть файл

@ -7,7 +7,6 @@
DevToolsModules(
'content-process.js',
'content-process.jsm',
'debug-new-process.js',
'frame.js',
'worker.js',
)