Bug 1596981 - catch the case where actors go away while a timer is pending in ContentMetaChild.jsm, r=NeilDeakin

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gijs Kruitbosch 2020-02-18 12:09:19 +00:00
parent 63edde2d24
commit 9cea1e5848

View File

@ -92,6 +92,12 @@ class ContentMetaChild extends JSWindowActorChild {
this.metaTags = new Map();
}
willDestroy() {
for (let entry of this.metaTags.values()) {
entry.timeout.cancel();
}
}
handleEvent(event) {
if (event.type != "DOMMetaAdded") {
return;
@ -162,6 +168,12 @@ class ContentMetaChild extends JSWindowActorChild {
entry.timeout.initWithCallback(
() => {
entry.timeout = null;
this.metaTags.delete(url);
// We try to cancel the timers when we get destroyed, but if
// there's a race, catch it:
if (!this.manager || this.manager.isClosed) {
return;
}
// Save description and preview image to moz_places
this.sendAsyncMessage("Meta:SetPageInfo", {
@ -178,7 +190,6 @@ class ContentMetaChild extends JSWindowActorChild {
Services.telemetry
.getHistogramById("PAGE_METADATA_SIZE")
.add(metadataSize);
this.metaTags.delete(url);
},
TIMEOUT_DELAY,
Ci.nsITimer.TYPE_ONE_SHOT