Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include <string.h> |
michael@0 | 7 | |
michael@0 | 8 | #include "nscore.h" |
michael@0 | 9 | |
michael@0 | 10 | #include "nsIComponentManager.h" |
michael@0 | 11 | #include "nsIServiceManager.h" |
michael@0 | 12 | #include "nsCOMPtr.h" |
michael@0 | 13 | #include "mozilla/ModuleUtils.h" |
michael@0 | 14 | #include "nsIJARFactory.h" |
michael@0 | 15 | #include "nsJARProtocolHandler.h" |
michael@0 | 16 | #include "nsJARURI.h" |
michael@0 | 17 | #include "nsJAR.h" |
michael@0 | 18 | |
michael@0 | 19 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsJAR) |
michael@0 | 20 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsZipReaderCache) |
michael@0 | 21 | NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsJARProtocolHandler, |
michael@0 | 22 | nsJARProtocolHandler::GetSingleton) |
michael@0 | 23 | NS_GENERIC_FACTORY_CONSTRUCTOR(nsJARURI) |
michael@0 | 24 | |
michael@0 | 25 | NS_DEFINE_NAMED_CID(NS_ZIPREADER_CID); |
michael@0 | 26 | NS_DEFINE_NAMED_CID(NS_ZIPREADERCACHE_CID); |
michael@0 | 27 | NS_DEFINE_NAMED_CID(NS_JARPROTOCOLHANDLER_CID); |
michael@0 | 28 | NS_DEFINE_NAMED_CID(NS_JARURI_CID); |
michael@0 | 29 | |
michael@0 | 30 | static const mozilla::Module::CIDEntry kJARCIDs[] = { |
michael@0 | 31 | { &kNS_ZIPREADER_CID, false, nullptr, nsJARConstructor }, |
michael@0 | 32 | { &kNS_ZIPREADERCACHE_CID, false, nullptr, nsZipReaderCacheConstructor }, |
michael@0 | 33 | { &kNS_JARPROTOCOLHANDLER_CID, false, nullptr, nsJARProtocolHandlerConstructor }, |
michael@0 | 34 | { &kNS_JARURI_CID, false, nullptr, nsJARURIConstructor }, |
michael@0 | 35 | { nullptr } |
michael@0 | 36 | }; |
michael@0 | 37 | |
michael@0 | 38 | static const mozilla::Module::ContractIDEntry kJARContracts[] = { |
michael@0 | 39 | { "@mozilla.org/libjar/zip-reader;1", &kNS_ZIPREADER_CID }, |
michael@0 | 40 | { "@mozilla.org/libjar/zip-reader-cache;1", &kNS_ZIPREADERCACHE_CID }, |
michael@0 | 41 | { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "jar", &kNS_JARPROTOCOLHANDLER_CID }, |
michael@0 | 42 | { nullptr } |
michael@0 | 43 | }; |
michael@0 | 44 | |
michael@0 | 45 | // Jar module shutdown hook |
michael@0 | 46 | static void nsJarShutdown() |
michael@0 | 47 | { |
michael@0 | 48 | // Make sure to not null out gJarHandler here, because we may have |
michael@0 | 49 | // still-live nsJARChannels that will want to release it. |
michael@0 | 50 | nsJARProtocolHandler *handler = gJarHandler; |
michael@0 | 51 | NS_IF_RELEASE(handler); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | static const mozilla::Module kJARModule = { |
michael@0 | 55 | mozilla::Module::kVersion, |
michael@0 | 56 | kJARCIDs, |
michael@0 | 57 | kJARContracts, |
michael@0 | 58 | nullptr, |
michael@0 | 59 | nullptr, |
michael@0 | 60 | nullptr, |
michael@0 | 61 | nsJarShutdown |
michael@0 | 62 | }; |
michael@0 | 63 | |
michael@0 | 64 | NSMODULE_DEFN(nsJarModule) = &kJARModule; |