Bug 1456035: Part 3 - Replace XPCOMUtils.generateQI with a stub for ChromeUtils.generateQI. r?mccr8
MozReview-Commit-ID: HWnlxUQvxYZ
--- a/js/xpconnect/loader/XPCOMUtils.jsm
+++ b/js/xpconnect/loader/XPCOMUtils.jsm
@@ -96,28 +96,17 @@ var XPCOMUtils = {
* assigned to the 'QueryInterface' property of a JS object. When invoked on
* that object, it checks if the given iid is listed in the |interfaces|
* param, and if it is, returns |this| (the object it was called on).
* If the JS object has a classInfo property it'll be returned for the
* nsIClassInfo IID, generateCI can be used to generate the classInfo
* property.
*/
generateQI: function XPCU_generateQI(interfaces) {
- /* Note that Ci[Ci.x] == Ci.x for all x */
- let a = [];
- if (interfaces) {
- for (let i = 0; i < interfaces.length; i++) {
- let iface = interfaces[i];
- let name = (iface && iface.name) || String(iface);
- if (name in Ci) {
- a.push(name);
- }
- }
- }
- return makeQI(a);
+ return ChromeUtils.generateQI(interfaces);
},
/**
* Generate a ClassInfo implementation for a component. The returned object
* must be assigned to the 'classInfo' property of a JS object. The first and
* only argument should be an object that contains a number of optional
* properties: "interfaces", "contractID", "classDescription", "classID" and
* "flags". The values of the properties will be returned as the values of the
@@ -573,26 +562,8 @@ var XPCOMUtils = {
var XPCU_lazyPreferenceObserverQI = XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]);
ChromeUtils.defineModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(XPCOMUtils, "categoryManager",
"@mozilla.org/categorymanager;1",
"nsICategoryManager");
-
-/**
- * Helper for XPCOMUtils.generateQI to avoid leaks - see bug 381651#c1
- */
-function makeQI(interfaceNames) {
- return function XPCOMUtils_QueryInterface(iid) {
- if (iid.equals(Ci.nsISupports))
- return this;
- if (iid.equals(Ci.nsIClassInfo) && "classInfo" in this)
- return this.classInfo;
- for (let i = 0; i < interfaceNames.length; i++) {
- if (Ci[interfaceNames[i]].equals(iid))
- return this;
- }
-
- throw Cr.NS_ERROR_NO_INTERFACE;
- };
-}