Bug 1524687: Part 5 - Convert JAR module to static registration. r=valentin
☠☠ backed out by 3b1b94e39795 ☠ ☠
authorKris Maglione <maglione.k@gmail.com>
Thu, 24 Jan 2019 15:49:33 -0800
changeset 458965 191afe83da2e
parent 458964 c58caf41bb94
child 458966 f4ee175bc5bd
push id111908
push usermaglione.k@gmail.com
push dateThu, 14 Feb 2019 02:29:45 +0000
treeherdermozilla-inbound@625f71135038 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1524687
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1524687: Part 5 - Convert JAR module to static registration. r=valentin Differential Revision: https://phabricator.services.mozilla.com/D18400
modules/libjar/components.conf
modules/libjar/moz.build
modules/libjar/nsJARFactory.cpp
modules/libjar/zipwriter/ZipWriterModule.cpp
modules/libjar/zipwriter/components.conf
modules/libjar/zipwriter/moz.build
modules/libjar/zipwriter/nsDeflateConverter.h
new file mode 100644
--- /dev/null
+++ b/modules/libjar/components.conf
@@ -0,0 +1,38 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+Classes = [
+    {
+        'cid': '{88e2fd0b-f7f4-480c-9483-7846b00e8dad}',
+        'contract_ids': ['@mozilla.org/libjar/zip-reader;1'],
+        'type': 'nsJAR',
+        'headers': ['/modules/libjar/nsJAR.h'],
+    },
+    {
+        'cid': '{c7e410d4-85f2-11d3-9f63-006008a6efe9}',
+        'contract_ids': ['@mozilla.org/network/protocol;1?name=jar'],
+        'singleton': True,
+        'type': 'nsJARProtocolHandler',
+        'headers': ['/modules/libjar/nsJARProtocolHandler.h'],
+        'constructor': 'nsJARProtocolHandler::GetSingleton',
+    },
+    {
+        'cid': '{245abae2-b947-4ded-a46d-9829d3cca462}',
+        'type': 'nsJARURI::Mutator',
+        'headers': ['nsJARURI.h'],
+    },
+    {
+        'cid': '{19d9161b-a2a9-4518-b2c9-fcb8296d6dcd}',
+        'type': 'nsJARURI::Mutator',
+        'headers': ['nsJARURI.h'],
+    },
+    {
+        'cid': '{608b7f6f-4b60-40d6-87ed-d933bf53d8c1}',
+        'contract_ids': ['@mozilla.org/libjar/zip-reader-cache;1'],
+        'type': 'nsZipReaderCache',
+        'headers': ['/modules/libjar/nsJAR.h'],
+    },
+]
--- a/modules/libjar/moz.build
+++ b/modules/libjar/moz.build
@@ -27,18 +27,21 @@ EXPORTS += [
     'nsJARURI.h',
     'nsZipArchive.h',
     'zipstruct.h',
 ]
 
 UNIFIED_SOURCES += [
     'nsJAR.cpp',
     'nsJARChannel.cpp',
-    'nsJARFactory.cpp',
     'nsJARInputStream.cpp',
     'nsJARProtocolHandler.cpp',
     'nsJARURI.cpp',
     'nsZipArchive.cpp',
 ]
 
+XPCOM_MANIFESTS += [
+    'components.conf',
+]
+
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
deleted file mode 100644
--- a/modules/libjar/nsJARFactory.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include <string.h>
-
-#include "nscore.h"
-
-#include "nsIComponentManager.h"
-#include "nsIServiceManager.h"
-#include "nsCOMPtr.h"
-#include "mozilla/ModuleUtils.h"
-#include "nsIJARFactory.h"
-#include "nsJARProtocolHandler.h"
-#include "nsJARURI.h"
-#include "nsJAR.h"
-
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsJAR)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsZipReaderCache)
-NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsJARProtocolHandler,
-                                         nsJARProtocolHandler::GetSingleton)
-
-typedef nsJARURI::Mutator nsJARURIMutator;
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsJARURIMutator)
-
-NS_DEFINE_NAMED_CID(NS_ZIPREADER_CID);
-NS_DEFINE_NAMED_CID(NS_ZIPREADERCACHE_CID);
-NS_DEFINE_NAMED_CID(NS_JARPROTOCOLHANDLER_CID);
-NS_DEFINE_NAMED_CID(NS_JARURI_CID);
-NS_DEFINE_NAMED_CID(NS_JARURIMUTATOR_CID);
-
-static const mozilla::Module::CIDEntry kJARCIDs[] = {
-    {&kNS_ZIPREADER_CID, false, nullptr, nsJARConstructor},
-    {&kNS_ZIPREADERCACHE_CID, false, nullptr, nsZipReaderCacheConstructor},
-    {&kNS_JARPROTOCOLHANDLER_CID, false, nullptr,
-     nsJARProtocolHandlerConstructor},
-    {&kNS_JARURI_CID, false, nullptr,
-     nsJARURIMutatorConstructor},  // do_CreateInstance returns mutator
-    {&kNS_JARURIMUTATOR_CID, false, nullptr, nsJARURIMutatorConstructor},
-    {nullptr}};
-
-static const mozilla::Module::ContractIDEntry kJARContracts[] = {
-    {"@mozilla.org/libjar/zip-reader;1", &kNS_ZIPREADER_CID},
-    {"@mozilla.org/libjar/zip-reader-cache;1", &kNS_ZIPREADERCACHE_CID},
-    {NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "jar", &kNS_JARPROTOCOLHANDLER_CID},
-    {nullptr}};
-
-static const mozilla::Module kJARModule = {mozilla::Module::kVersion,
-                                           kJARCIDs,
-                                           kJARContracts,
-                                           nullptr,
-                                           nullptr,
-                                           nullptr,
-                                           nullptr};
-
-NSMODULE_DEFN(nsJarModule) = &kJARModule;
deleted file mode 100644
--- a/modules/libjar/zipwriter/ZipWriterModule.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include "mozilla/ModuleUtils.h"
-#include "nsDeflateConverter.h"
-#include "nsZipWriter.h"
-
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeflateConverter)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsZipWriter)
-
-NS_DEFINE_NAMED_CID(DEFLATECONVERTER_CID);
-NS_DEFINE_NAMED_CID(ZIPWRITER_CID);
-
-static const mozilla::Module::CIDEntry kZipWriterCIDs[] = {
-    {&kDEFLATECONVERTER_CID, false, nullptr, nsDeflateConverterConstructor},
-    {&kZIPWRITER_CID, false, nullptr, nsZipWriterConstructor},
-    {nullptr}};
-
-static const mozilla::Module::ContractIDEntry kZipWriterContracts[] = {
-    {"@mozilla.org/streamconv;1?from=uncompressed&to=deflate",
-     &kDEFLATECONVERTER_CID},
-    {"@mozilla.org/streamconv;1?from=uncompressed&to=gzip",
-     &kDEFLATECONVERTER_CID},
-    {"@mozilla.org/streamconv;1?from=uncompressed&to=x-gzip",
-     &kDEFLATECONVERTER_CID},
-    {"@mozilla.org/streamconv;1?from=uncompressed&to=rawdeflate",
-     &kDEFLATECONVERTER_CID},
-    {ZIPWRITER_CONTRACTID, &kZIPWRITER_CID},
-    {nullptr}};
-
-static const mozilla::Module kZipWriterModule = {
-    mozilla::Module::kVersion, kZipWriterCIDs, kZipWriterContracts};
-
-NSMODULE_DEFN(ZipWriterModule) = &kZipWriterModule;
new file mode 100644
--- /dev/null
+++ b/modules/libjar/zipwriter/components.conf
@@ -0,0 +1,25 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+Classes = [
+    {
+        'cid': '{461cd5dd-73c6-47a4-8cc3-603b37d84a61}',
+        'contract_ids': [
+            '@mozilla.org/streamconv;1?from=uncompressed&to=deflate',
+            '@mozilla.org/streamconv;1?from=uncompressed&to=gzip',
+            '@mozilla.org/streamconv;1?from=uncompressed&to=rawdeflate',
+            '@mozilla.org/streamconv;1?from=uncompressed&to=x-gzip',
+        ],
+        'type': 'nsDeflateConverter',
+        'headers': ['/modules/libjar/zipwriter/nsDeflateConverter.h'],
+    },
+    {
+        'cid': '{430d416c-a722-4ad1-be98-d9a445f85e3f}',
+        'contract_ids': ['@mozilla.org/zipwriter;1'],
+        'type': 'nsZipWriter',
+        'headers': ['/modules/libjar/zipwriter/nsZipWriter.h'],
+    },
+]
--- a/modules/libjar/zipwriter/moz.build
+++ b/modules/libjar/zipwriter/moz.build
@@ -13,12 +13,15 @@ XPIDL_SOURCES += [
 XPIDL_MODULE = 'zipwriter'
 
 UNIFIED_SOURCES += [
     'nsDeflateConverter.cpp',
     'nsZipDataStream.cpp',
     'nsZipHeader.cpp',
     'nsZipWriter.cpp',
     'StreamFunctions.cpp',
-    'ZipWriterModule.cpp',
+]
+
+XPCOM_MANIFESTS += [
+    'components.conf',
 ]
 
 FINAL_LIBRARY = 'xul'
--- a/modules/libjar/zipwriter/nsDeflateConverter.h
+++ b/modules/libjar/zipwriter/nsDeflateConverter.h
@@ -14,20 +14,20 @@
 
 #define DEFLATECONVERTER_CID                         \
   {                                                  \
     0x461cd5dd, 0x73c6, 0x47a4, {                    \
       0x8c, 0xc3, 0x60, 0x3b, 0x37, 0xd8, 0x4a, 0x61 \
     }                                                \
   }
 
-#define ZIP_BUFLEN (4 * 1024 - 1)
-
 class nsDeflateConverter final : public nsIStreamConverter {
  public:
+  static constexpr size_t kZipBufLen = (4 * 1024 - 1);
+
   NS_DECL_ISUPPORTS
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSISTREAMLISTENER
   NS_DECL_NSISTREAMCONVERTER
 
   nsDeflateConverter() : mWrapMode(WRAP_NONE), mOffset(0), mZstream() {
     // 6 is Z_DEFAULT_COMPRESSION but we need the actual value
     mLevel = 6;
@@ -44,15 +44,15 @@ class nsDeflateConverter final : public 
   enum WrapMode { WRAP_ZLIB, WRAP_GZIP, WRAP_NONE };
 
   WrapMode mWrapMode;
   uint64_t mOffset;
   int32_t mLevel;
   nsCOMPtr<nsIStreamListener> mListener;
   nsCOMPtr<nsISupports> mContext;
   z_stream mZstream;
-  unsigned char mWriteBuffer[ZIP_BUFLEN];
+  unsigned char mWriteBuffer[kZipBufLen];
 
   nsresult Init();
   nsresult PushAvailableData(nsIRequest *aRequest, nsISupports *aContext);
 };
 
 #endif