1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
2 * vim: sw=2 ts=2 sts=2 et filetype=javascript
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 * Deprecated utilities for JavaScript components loaded by the JS component
12 const nsIFactoryQI = ChromeUtils.generateQI(["nsIFactory"]);
14 export var ComponentUtils = {
18 * Generates a singleton nsIFactory implementation that can be used as
19 * an argument to nsIComponentRegistrar.registerFactory.
21 * @param {Function} aServiceConstructor
22 * Constructor function of the component.
24 generateSingletonFactory(aServiceConstructor) {
27 createInstance(aIID) {
28 if (this._instance === null) {
29 this._instance = new aServiceConstructor();
31 return this._instance.QueryInterface(aIID);
33 QueryInterface: nsIFactoryQI,