зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
3dfef17d14
Коммит
4d9930a53d
|
@ -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',
|
||||
)
|
||||
|
|
Загрузка…
Ссылка в новой задаче