modules/libjar/nsJARFactory.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/libjar/nsJARFactory.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include <string.h>
    1.10 +
    1.11 +#include "nscore.h"
    1.12 +
    1.13 +#include "nsIComponentManager.h"
    1.14 +#include "nsIServiceManager.h"
    1.15 +#include "nsCOMPtr.h"
    1.16 +#include "mozilla/ModuleUtils.h"
    1.17 +#include "nsIJARFactory.h"
    1.18 +#include "nsJARProtocolHandler.h"
    1.19 +#include "nsJARURI.h"
    1.20 +#include "nsJAR.h"
    1.21 +
    1.22 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsJAR)
    1.23 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsZipReaderCache)
    1.24 +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsJARProtocolHandler,
    1.25 +                                         nsJARProtocolHandler::GetSingleton)
    1.26 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsJARURI)
    1.27 +
    1.28 +NS_DEFINE_NAMED_CID(NS_ZIPREADER_CID);
    1.29 +NS_DEFINE_NAMED_CID(NS_ZIPREADERCACHE_CID);
    1.30 +NS_DEFINE_NAMED_CID(NS_JARPROTOCOLHANDLER_CID);
    1.31 +NS_DEFINE_NAMED_CID(NS_JARURI_CID);
    1.32 +
    1.33 +static const mozilla::Module::CIDEntry kJARCIDs[] = {
    1.34 +    { &kNS_ZIPREADER_CID, false, nullptr, nsJARConstructor },
    1.35 +    { &kNS_ZIPREADERCACHE_CID, false, nullptr, nsZipReaderCacheConstructor },
    1.36 +    { &kNS_JARPROTOCOLHANDLER_CID, false, nullptr, nsJARProtocolHandlerConstructor },
    1.37 +    { &kNS_JARURI_CID, false, nullptr, nsJARURIConstructor },
    1.38 +    { nullptr }
    1.39 +};
    1.40 +
    1.41 +static const mozilla::Module::ContractIDEntry kJARContracts[] = {
    1.42 +    { "@mozilla.org/libjar/zip-reader;1", &kNS_ZIPREADER_CID },
    1.43 +    { "@mozilla.org/libjar/zip-reader-cache;1", &kNS_ZIPREADERCACHE_CID },
    1.44 +    { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "jar", &kNS_JARPROTOCOLHANDLER_CID },
    1.45 +    { nullptr }
    1.46 +};
    1.47 +
    1.48 +// Jar module shutdown hook
    1.49 +static void nsJarShutdown()
    1.50 +{
    1.51 +    // Make sure to not null out gJarHandler here, because we may have
    1.52 +    // still-live nsJARChannels that will want to release it.
    1.53 +    nsJARProtocolHandler *handler = gJarHandler;
    1.54 +    NS_IF_RELEASE(handler);
    1.55 +}
    1.56 +
    1.57 +static const mozilla::Module kJARModule = {
    1.58 +    mozilla::Module::kVersion,
    1.59 +    kJARCIDs,
    1.60 +    kJARContracts,
    1.61 +    nullptr,
    1.62 +    nullptr,
    1.63 +    nullptr,
    1.64 +    nsJarShutdown
    1.65 +};
    1.66 +
    1.67 +NSMODULE_DEFN(nsJarModule) = &kJARModule;

mercurial