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
--- a/browser/extensions/pdfjs/content/PdfJsRegistration.jsm
+++ b/browser/extensions/pdfjs/content/PdfJsRegistration.jsm
@@ -20,33 +20,35 @@ var EXPORTED_SYMBOLS = ["PdfJsRegistrati
const Cm = Components.manager;
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() {
var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(this._classID, this._factory);
if (this._classID2) {
registrar.unregisterFactory(this._classID2, this._factory);
}
--- a/browser/extensions/pdfjs/content/PdfStreamConverter.jsm
+++ b/browser/extensions/pdfjs/content/PdfStreamConverter.jsm
@@ -795,25 +795,16 @@ class FindEventManager {
this.winmm.sendAsyncMessage("PDFJS:Parent:removeEventListener");
}
}
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]),
/*
* This component works as such:
* 1. asyncConvertData stores the listener
* 2. onStartRequest creates a new channel, streams the viewer
* 3. If range requests are supported:
* 3.1. Leave the request open until the viewer is ready to switch to