modules/libjar/nsJARFactory.cpp
author Andreea Pavel <apavel@mozilla.com>
Tue, 21 Aug 2018 20:20:24 +0300
changeset 490366 d8a7212c51a48253bfa9551ecc9318a9536c62d4
parent 464971 61aa0247279aaacf8e0aedf47281f15de8952258
child 508163 6f3709b3878117466168c40affa7bca0b60cf75b
permissions -rw-r--r--
Backed out 6 changesets (bug 1396821) for linux tier2 build bustages on a CLOSED TREE Backed out changeset 2fa2975f97e3 (bug 1396821) Backed out changeset c5895db52483 (bug 1396821) Backed out changeset 5c0ddd45f926 (bug 1396821) Backed out changeset 7c97853a85b9 (bug 1396821) Backed out changeset b61ce753f01e (bug 1396821) Backed out changeset 7ef3912feb2c (bug 1396821)

/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include <string.h>

#include "nscore.h"

#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "mozilla/ModuleUtils.h"
#include "nsIJARFactory.h"
#include "nsJARProtocolHandler.h"
#include "nsJARURI.h"
#include "nsJAR.h"

NS_GENERIC_FACTORY_CONSTRUCTOR(nsJAR)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsZipReaderCache)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsJARProtocolHandler,
                                         nsJARProtocolHandler::GetSingleton)

typedef nsJARURI::Mutator nsJARURIMutator;
NS_GENERIC_FACTORY_CONSTRUCTOR(nsJARURIMutator)

NS_DEFINE_NAMED_CID(NS_ZIPREADER_CID);
NS_DEFINE_NAMED_CID(NS_ZIPREADERCACHE_CID);
NS_DEFINE_NAMED_CID(NS_JARPROTOCOLHANDLER_CID);
NS_DEFINE_NAMED_CID(NS_JARURI_CID);
NS_DEFINE_NAMED_CID(NS_JARURIMUTATOR_CID);

static const mozilla::Module::CIDEntry kJARCIDs[] = {
    { &kNS_ZIPREADER_CID, false, nullptr, nsJARConstructor },
    { &kNS_ZIPREADERCACHE_CID, false, nullptr, nsZipReaderCacheConstructor },
    { &kNS_JARPROTOCOLHANDLER_CID, false, nullptr, nsJARProtocolHandlerConstructor },
    { &kNS_JARURI_CID, false, nullptr, nsJARURIMutatorConstructor }, // do_CreateInstance returns mutator
    { &kNS_JARURIMUTATOR_CID, false, nullptr, nsJARURIMutatorConstructor },
    { nullptr }
};

static const mozilla::Module::ContractIDEntry kJARContracts[] = {
    { "@mozilla.org/libjar/zip-reader;1", &kNS_ZIPREADER_CID },
    { "@mozilla.org/libjar/zip-reader-cache;1", &kNS_ZIPREADERCACHE_CID },
    { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "jar", &kNS_JARPROTOCOLHANDLER_CID },
    { nullptr }
};

static const mozilla::Module kJARModule = {
    mozilla::Module::kVersion,
    kJARCIDs,
    kJARContracts,
    nullptr,
    nullptr,
    nullptr,
    nullptr
};

NSMODULE_DEFN(nsJarModule) = &kJARModule;