Bug 1351690, part 2 - Specialize Factory into StreamConverterFactory. r=bdahl
authorAndrew McCreight <continuation@gmail.com>
Tue, 22 May 2018 15:28:45 -0700
changeset 804114 21a2a25d8fa04ccdcb225a8459cadfd187135ecd
parent 804113 047a3f7078379e139ed83aafb20aeacb1e6e2755
child 804115 5eb08c5b8492287d22674ed747d0932c2cc55f42
push id112312
push userbmo:standard8@mozilla.com
push dateTue, 05 Jun 2018 16:07:56 +0000
reviewersbdahl
bugs1351690
milestone62.0a1
Bug 1351690, part 2 - Specialize Factory into StreamConverterFactory. r=bdahl Factory is only ever passed PdfStreamConverter, so specialize the registration method and rename the class. Also, classID2 is always non-null for PdfStreamConverter, so drop the check. MozReview-Commit-ID: Ts295QTmrm
browser/extensions/pdfjs/content/PdfJsRegistration.jsm
--- a/browser/extensions/pdfjs/content/PdfJsRegistration.jsm
+++ b/browser/extensions/pdfjs/content/PdfJsRegistration.jsm
@@ -18,23 +18,24 @@
 var EXPORTED_SYMBOLS = ["PdfJsRegistration"];
 
 const Cm = Components.manager;
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 
 // Register/unregister a constructor as a factory.
-function Factory() {}
-Factory.prototype = {
-  register: function register(targetConstructor) {
-    var proto = targetConstructor.prototype;
+function StreamConverterFactory() {}
+StreamConverterFactory.prototype = {
+  register: function register() {
+    ChromeUtils.import("resource://pdf.js/PdfStreamConverter.jsm");
+    var proto = PdfStreamConverter.prototype;
     this._classID = proto.classID;
 
-    var factory = XPCOMUtils._getFactory(targetConstructor);
+    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;
@@ -55,19 +56,18 @@ Factory.prototype = {
 
 var PdfJsRegistration = {
   _registered: false,
 
   ensureRegistered: function ensureRegistered() {
     if (this._registered) {
       return;
     }
-    this._pdfStreamConverterFactory = new Factory();
-    ChromeUtils.import("resource://pdf.js/PdfStreamConverter.jsm");
-    this._pdfStreamConverterFactory.register(PdfStreamConverter);
+    this._pdfStreamConverterFactory = new StreamConverterFactory();
+    this._pdfStreamConverterFactory.register();
 
     this._registered = true;
   },
 
   ensureUnregistered: function ensureUnregistered() {
     if (!this._registered) {
       return;
     }