Bug 1352522, part 2 - Thunkify ContentWebRTC message listeners. draft
authorAndrew McCreight <continuation@gmail.com>
Fri, 31 Mar 2017 11:19:27 -0700
changeset 555126 993c4afccf8e0c10528964a0ed066b9d5b35b9aa
parent 555125 597fce229a4e30b75ea59687acc5fe0fd405ce1b
child 555127 620e05dd4f810789672e0decb2bdb464c11f75dc
child 555129 215a4e8737f5e3ed0d3f4ef7aa8844000377a435
push id52163
push userbmo:continuation@gmail.com
push dateMon, 03 Apr 2017 17:45:53 +0000
bugs1352522
milestone55.0a1
Bug 1352522, part 2 - Thunkify ContentWebRTC message listeners. This avoids importing ContentWebRTC.jsm unless webrtc is actually being used, which reduces memory usage. MozReview-Commit-ID: GlMo1WIZEFD
browser/base/content/content.js
--- a/browser/base/content/content.js
+++ b/browser/base/content/content.js
@@ -698,21 +698,21 @@ ContentLinkHandler.init(this);
 
 // TODO: Load this lazily so the JSM is run only if a relevant event/message fires.
 var pluginContent = new PluginContent(global);
 
 addEventListener("DOMWindowFocus", function(event) {
   sendAsyncMessage("DOMWindowFocus", {});
 }, false);
 
-addMessageListener("rtcpeer:Allow", ContentWebRTC);
-addMessageListener("rtcpeer:Deny", ContentWebRTC);
-addMessageListener("webrtc:Allow", ContentWebRTC);
-addMessageListener("webrtc:Deny", ContentWebRTC);
-addMessageListener("webrtc:StopSharing", ContentWebRTC);
+addMessageListener("rtcpeer:Allow", (event) => { ContentWebRTC.handleEvent(event)});
+addMessageListener("rtcpeer:Deny", (event) => { ContentWebRTC.handleEvent(event)});
+addMessageListener("webrtc:Allow", (event) => { ContentWebRTC.handleEvent(event)});
+addMessageListener("webrtc:Deny", (event) => { ContentWebRTC.handleEvent(event)});
+addMessageListener("webrtc:StopSharing", (event) => { ContentWebRTC.handleEvent(event)});
 addMessageListener("webrtc:StartBrowserSharing", () => {
   let windowID = content.QueryInterface(Ci.nsIInterfaceRequestor)
                         .getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
   sendAsyncMessage("webrtc:response:StartBrowserSharing", {
     windowID
   });
 });