modules/libjar/nsJARFactory.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     6 #include <string.h>
     8 #include "nscore.h"
    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"
    19 NS_GENERIC_FACTORY_CONSTRUCTOR(nsJAR)
    20 NS_GENERIC_FACTORY_CONSTRUCTOR(nsZipReaderCache)
    21 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsJARProtocolHandler,
    22                                          nsJARProtocolHandler::GetSingleton)
    23 NS_GENERIC_FACTORY_CONSTRUCTOR(nsJARURI)
    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);
    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 };
    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 };
    45 // Jar module shutdown hook
    46 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     nsJARProtocolHandler *handler = gJarHandler;
    51     NS_IF_RELEASE(handler);
    52 }
    54 static const mozilla::Module kJARModule = {
    55     mozilla::Module::kVersion,
    56     kJARCIDs,
    57     kJARContracts,
    58     nullptr,
    59     nullptr,
    60     nullptr,
    61     nsJarShutdown
    62 };
    64 NSMODULE_DEFN(nsJarModule) = &kJARModule;

mercurial