michael@0: /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include michael@0: michael@0: #include "nscore.h" michael@0: michael@0: #include "nsIComponentManager.h" michael@0: #include "nsIServiceManager.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "mozilla/ModuleUtils.h" michael@0: #include "nsIJARFactory.h" michael@0: #include "nsJARProtocolHandler.h" michael@0: #include "nsJARURI.h" michael@0: #include "nsJAR.h" michael@0: michael@0: NS_GENERIC_FACTORY_CONSTRUCTOR(nsJAR) michael@0: NS_GENERIC_FACTORY_CONSTRUCTOR(nsZipReaderCache) michael@0: NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsJARProtocolHandler, michael@0: nsJARProtocolHandler::GetSingleton) michael@0: NS_GENERIC_FACTORY_CONSTRUCTOR(nsJARURI) michael@0: michael@0: NS_DEFINE_NAMED_CID(NS_ZIPREADER_CID); michael@0: NS_DEFINE_NAMED_CID(NS_ZIPREADERCACHE_CID); michael@0: NS_DEFINE_NAMED_CID(NS_JARPROTOCOLHANDLER_CID); michael@0: NS_DEFINE_NAMED_CID(NS_JARURI_CID); michael@0: michael@0: static const mozilla::Module::CIDEntry kJARCIDs[] = { michael@0: { &kNS_ZIPREADER_CID, false, nullptr, nsJARConstructor }, michael@0: { &kNS_ZIPREADERCACHE_CID, false, nullptr, nsZipReaderCacheConstructor }, michael@0: { &kNS_JARPROTOCOLHANDLER_CID, false, nullptr, nsJARProtocolHandlerConstructor }, michael@0: { &kNS_JARURI_CID, false, nullptr, nsJARURIConstructor }, michael@0: { nullptr } michael@0: }; michael@0: michael@0: static const mozilla::Module::ContractIDEntry kJARContracts[] = { michael@0: { "@mozilla.org/libjar/zip-reader;1", &kNS_ZIPREADER_CID }, michael@0: { "@mozilla.org/libjar/zip-reader-cache;1", &kNS_ZIPREADERCACHE_CID }, michael@0: { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "jar", &kNS_JARPROTOCOLHANDLER_CID }, michael@0: { nullptr } michael@0: }; michael@0: michael@0: // Jar module shutdown hook michael@0: static void nsJarShutdown() michael@0: { michael@0: // Make sure to not null out gJarHandler here, because we may have michael@0: // still-live nsJARChannels that will want to release it. michael@0: nsJARProtocolHandler *handler = gJarHandler; michael@0: NS_IF_RELEASE(handler); michael@0: } michael@0: michael@0: static const mozilla::Module kJARModule = { michael@0: mozilla::Module::kVersion, michael@0: kJARCIDs, michael@0: kJARContracts, michael@0: nullptr, michael@0: nullptr, michael@0: nullptr, michael@0: nsJarShutdown michael@0: }; michael@0: michael@0: NSMODULE_DEFN(nsJarModule) = &kJARModule;