From 03766e63da15d4eafc11f66b709f75734fe34a1d Mon Sep 17 00:00:00 2001 From: "Byron Campen [:bwc]" Date: Thu, 31 May 2018 11:30:19 -0500 Subject: [PATCH] Bug 1464079 - Bring ICE connection state change callback up to spec. r=jib, a=RyanVM --- dom/media/PeerConnection.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dom/media/PeerConnection.js b/dom/media/PeerConnection.js index d13f1d0fbb..0569b15aeb 100644 --- a/dom/media/PeerConnection.js +++ b/dom/media/PeerConnection.js @@ -516,6 +516,18 @@ RTCPeerConnection.prototype = { }; }, + // This implements the fairly common "Queue a task" logic + async _queueTaskWithClosedCheck(func) { + return new Promise(resolve => { + Services.tm.mainThread.dispatch({ run() { + if (!this._closed) { + func(); + resolve(); + } + }}, Ci.nsIThread.DISPATCH_NORMAL); + }); + }, + /** * An RTCConfiguration may look like this: *