Bug 1351690, part 3 - Move stream converter XPCOM registration constants into the registration file. r=bdahl

As with the last patch, the factory is only used for a single class,
so move the constants closer to where they are used. This will allow
us to register the stream converter without loading the stream
converter JSM.

MozReview-Commit-ID: DRKVtYQOs2J

--HG--
extra : rebase_source : d871033c17a0c42a41b62ad753f4d6221f2118a8
This commit is contained in:
Andrew McCreight 2018-05-22 15:37:58 -07:00
Родитель 4c81305931
Коммит b13bcee28c
2 изменённых файлов: 13 добавлений и 20 удалений

Просмотреть файл

@ -25,23 +25,25 @@ ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
// Register/unregister a constructor as a factory.
function StreamConverterFactory() {}
StreamConverterFactory.prototype = {
// properties required for XPCOM registration:
_classID: Components.ID("{d0c5195d-e798-49d4-b1d3-9324328b2291}"),
_classDescription: "pdf.js Component",
_contractID: "@mozilla.org/streamconv;1?from=application/pdf&to=*/*",
_classID2: Components.ID("{d0c5195d-e798-49d4-b1d3-9324328b2292}"),
_contractID2: "@mozilla.org/streamconv;1?from=application/pdf&to=text/html",
register: function register() {
ChromeUtils.import("resource://pdf.js/PdfStreamConverter.jsm");
var proto = PdfStreamConverter.prototype;
this._classID = proto.classID;
var factory = XPCOMUtils._getFactory(PdfStreamConverter);
this._factory = factory;
var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(proto.classID, proto.classDescription,
proto.contractID, factory);
if (proto.classID2) {
this._classID2 = proto.classID2;
registrar.registerFactory(proto.classID2, proto.classDescription,
proto.contractID2, factory);
}
registrar.registerFactory(this._classID, this._classDescription,
this._contractID, factory);
registrar.registerFactory(this._classID2, this._classDescription,
this._contractID2, factory);
},
unregister: function unregister() {

Просмотреть файл

@ -800,15 +800,6 @@ function PdfStreamConverter() {
}
PdfStreamConverter.prototype = {
// properties required for XPCOM registration:
classID: Components.ID("{d0c5195d-e798-49d4-b1d3-9324328b2291}"),
classDescription: "pdf.js Component",
contractID: "@mozilla.org/streamconv;1?from=application/pdf&to=*/*",
classID2: Components.ID("{d0c5195d-e798-49d4-b1d3-9324328b2292}"),
contractID2: "@mozilla.org/streamconv;1?from=application/pdf&to=text/html",
QueryInterface: ChromeUtils.generateQI([Ci.nsIStreamConverter, Ci.nsIStreamListener, Ci.nsIRequestObserver]),
/*