зеркало из 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";
|
"use strict";
|
||||||
|
|
||||||
var { Cc } = require("chrome");
|
const { Cc } = require("chrome");
|
||||||
|
const Services = require("Services");
|
||||||
|
|
||||||
loader.lazyGetter(this, "ppmm", () => {
|
loader.lazyGetter(this, "ppmm", () => {
|
||||||
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService();
|
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService();
|
||||||
|
@ -14,10 +15,7 @@ function ProcessActorList() {
|
||||||
this._actors = new Map();
|
this._actors = new Map();
|
||||||
this._onListChanged = null;
|
this._onListChanged = null;
|
||||||
this._mustNotify = false;
|
this._mustNotify = false;
|
||||||
|
this._hasObserver = false;
|
||||||
this._onMessage = this._onMessage.bind(this);
|
|
||||||
this._processScript =
|
|
||||||
"resource://devtools/server/startup/debug-new-process.js";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessActorList.prototype = {
|
ProcessActorList.prototype = {
|
||||||
|
@ -58,31 +56,24 @@ ProcessActorList.prototype = {
|
||||||
|
|
||||||
_checkListening: function() {
|
_checkListening: function() {
|
||||||
if (this._onListChanged !== null && this._mustNotify) {
|
if (this._onListChanged !== null && this._mustNotify) {
|
||||||
this._knownProcesses = [];
|
if (!this._hasObserver) {
|
||||||
for (let i = 0; i < ppmm.childCount; i++) {
|
Services.obs.addObserver(this, "ipc:content-created");
|
||||||
this._knownProcesses.push(ppmm.getChildAt(i));
|
Services.obs.addObserver(this, "ipc:content-shutdown");
|
||||||
|
this._hasObserver = true;
|
||||||
}
|
}
|
||||||
ppmm.addMessageListener("debug:new-process", this._onMessage);
|
} else if (this._hasObserver) {
|
||||||
ppmm.loadProcessScript(this._processScript, true);
|
Services.obs.removeObserver(this, "ipc:content-created");
|
||||||
} else {
|
Services.obs.removeObserver(this, "ipc:content-shutdown");
|
||||||
ppmm.removeMessageListener("debug:new-process", this._onMessage);
|
this._hasObserver = false;
|
||||||
ppmm.removeDelayedProcessScript(this._processScript);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_notifyListChanged: function() {
|
observe() {
|
||||||
if (this._mustNotify) {
|
if (this._mustNotify) {
|
||||||
this._onListChanged();
|
this._onListChanged();
|
||||||
this._mustNotify = false;
|
this._mustNotify = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_onMessage: function({ target }) {
|
|
||||||
if (this._knownProcesses.includes(target)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._notifyListChanged();
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.ProcessActorList = ProcessActorList;
|
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(
|
DevToolsModules(
|
||||||
'content-process.js',
|
'content-process.js',
|
||||||
'content-process.jsm',
|
'content-process.jsm',
|
||||||
'debug-new-process.js',
|
|
||||||
'frame.js',
|
'frame.js',
|
||||||
'worker.js',
|
'worker.js',
|
||||||
)
|
)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче