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