зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1615418 - Remove destroyed fronts from devtools workers-listener r=daisuke
This will avoid part of the exceptions thrown when disconnecting a remote runtime. However the rootFront unwatchFront calls will still throw because the root front is already gone at this point Differential Revision: https://phabricator.services.mozilla.com/D62893 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
fe7d7126bc
Коммит
06deaf08bc
|
@ -25,6 +25,15 @@ class WorkersListener {
|
|||
this._onProcessDescriptorAvailable = this._onProcessDescriptorAvailable.bind(
|
||||
this
|
||||
);
|
||||
this._onContentProcessTargetDestroyed = this._onContentProcessTargetDestroyed.bind(
|
||||
this
|
||||
);
|
||||
this._onServiceWorkerRegistrationDestroyed = this._onServiceWorkerRegistrationDestroyed.bind(
|
||||
this
|
||||
);
|
||||
this._onProcessDescriptorDestroyed = this._onProcessDescriptorDestroyed.bind(
|
||||
this
|
||||
);
|
||||
|
||||
// Array of contentProcessTarget fronts on which we will listen for worker events.
|
||||
this._contentProcessFronts = [];
|
||||
|
@ -42,12 +51,14 @@ class WorkersListener {
|
|||
this.rootFront.on("workerListChanged", this._listener);
|
||||
this.rootFront.watchFronts(
|
||||
"processDescriptor",
|
||||
this._onProcessDescriptorAvailable
|
||||
this._onProcessDescriptorAvailable,
|
||||
this._onProcessDescriptorDestroyed
|
||||
);
|
||||
|
||||
this.rootFront.watchFronts(
|
||||
"serviceWorkerRegistration",
|
||||
this._onServiceWorkerRegistrationAvailable
|
||||
this._onServiceWorkerRegistrationAvailable,
|
||||
this._onServiceWorkerRegistrationDestroyed
|
||||
);
|
||||
|
||||
this.rootFront.on("serviceWorkerRegistrationListChanged", this._listener);
|
||||
|
@ -81,11 +92,13 @@ class WorkersListener {
|
|||
|
||||
this.rootFront.unwatchFronts(
|
||||
"processDescriptor",
|
||||
this._onProcessDescriptorAvailable
|
||||
this._onProcessDescriptorAvailable,
|
||||
this._onProcessDescriptorDestroyed
|
||||
);
|
||||
this.rootFront.unwatchFronts(
|
||||
"serviceWorkerRegistration",
|
||||
this._onServiceWorkerRegistrationAvailable
|
||||
this._onServiceWorkerRegistrationAvailable,
|
||||
this._onServiceWorkerRegistrationDestroyed
|
||||
);
|
||||
|
||||
this._contentProcessFronts = [];
|
||||
|
@ -99,17 +112,36 @@ class WorkersListener {
|
|||
front.on("workerListChanged", this._listener);
|
||||
}
|
||||
|
||||
_onContentProcessTargetDestroyed(front) {
|
||||
this._contentProcessFronts = this._contentProcessFronts.filter(
|
||||
f => f !== front
|
||||
);
|
||||
}
|
||||
|
||||
_onServiceWorkerRegistrationAvailable(front) {
|
||||
this._serviceWorkerRegistrationFronts.push(front);
|
||||
front.on("push-subscription-modified", this._listener);
|
||||
front.on("registration-changed", this._listener);
|
||||
}
|
||||
|
||||
_onServiceWorkerRegistrationDestroyed(front) {
|
||||
this._serviceWorkerRegistrationFronts = this._serviceWorkerRegistrationFronts.filter(
|
||||
f => f !== front
|
||||
);
|
||||
}
|
||||
|
||||
_onProcessDescriptorAvailable(processFront) {
|
||||
this._processDescriptors.push(processFront);
|
||||
processFront.watchFronts(
|
||||
"contentProcessTarget",
|
||||
this._onContentProcessTargetAvailable
|
||||
this._onContentProcessTargetAvailable,
|
||||
this._onContentProcessTargetDestroyed
|
||||
);
|
||||
}
|
||||
|
||||
_onProcessDescriptorDestroyed(processFront) {
|
||||
this._processDescriptors = this._processDescriptors.filter(
|
||||
f => f !== processFront
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче