Bug 1524687: Part 5 - Convert JAR module to static registration. r=valentin

Differential Revision: https://phabricator.services.mozilla.com/D18400

--HG--
extra : rebase_source : 2493b76232f7f18d31b2ce1d24a5821525324fd8
extra : source : 191afe83da2e062951a2740d7cab68cf563ecfc7
This commit is contained in:
Kris Maglione 2019-01-24 15:49:33 -08:00
parent aaf5a4acba
commit 96cf121b5c
7 changed files with 74 additions and 98 deletions

View File

@ -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'],
},
]

View File

@ -32,13 +32,16 @@ EXPORTS += [
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'

View File

@ -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;

View File

@ -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;

View File

@ -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'],
},
]

View File

@ -18,7 +18,10 @@ UNIFIED_SOURCES += [
'nsZipHeader.cpp',
'nsZipWriter.cpp',
'StreamFunctions.cpp',
'ZipWriterModule.cpp',
]
XPCOM_MANIFESTS += [
'components.conf',
]
FINAL_LIBRARY = 'xul'

View File

@ -19,10 +19,10 @@
} \
}
#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
@ -49,7 +49,7 @@ class nsDeflateConverter final : public nsIStreamConverter {
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);