nsComponentManager.h revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsComponentManager_h__
#define nsComponentManager_h__
#include "nsXPCOM.h"
#include "nsIComponentLoader.h"
#include "xpcom-private.h"
#include "nsNativeComponentLoader.h"
#include "nsIComponentManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIComponentManagerObsolete.h"
#include "nsIComponentLoaderManager.h"
#include "nsCategoryManager.h"
#include "nsIServiceManager.h"
#include "nsIFactory.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "pldhash.h"
#include "prtime.h"
#include "prmon.h"
#include "nsCOMPtr.h"
#include "nsWeakReference.h"
#include "nsXPIDLString.h"
#include "nsIFile.h"
#include "plarena.h"
// Predefined loader types. Do not change the numbers.
// NATIVE should be 0 as it is being used as the first array index.
#define NS_COMPONENT_TYPE_NATIVE 0
#define NS_COMPONENT_TYPE_FACTORY_ONLY -1
// this define means that the factory entry only has a ContractID
// to service mapping and has no cid mapping.
#define NS_COMPONENT_TYPE_SERVICE_ONLY -2
#ifdef DEBUG
#define XPCOM_CHECK_PENDING_CIDS
#endif
////////////////////////////////////////////////////////////////////////////////
// Array of Loaders and their type strings
struct nsLoaderdata {
const char *type;
};
{
// Since the nsIComponentManagerObsolete and nsIComponentManager share some of the
// same interface function names, we have to manually define the functions here.
// The only function that is in nsIComponentManagerObsolete and is in nsIComponentManager
// is GetClassObjectContractID.
//
// nsIComponentManager function not in nsIComponentManagerObsolete:
void **_retval);
// Since the nsIComponentManagerObsolete and nsIComponentRegistrar share some of the
// same interface function names, we have to manually define the functions here.
// the only function that is shared is UnregisterFactory
NS_IMETHOD RegisterFactory(const nsCID & aClass, const char *aClassName, const char *aContractID, nsIFactory *aFactory);
// NS_IMETHOD UnregisterFactory(const nsCID & aClass, nsIFactory *aFactory);
NS_IMETHOD RegisterFactoryLocation(const nsCID & aClass, const char *aClassName, const char *aContractID, nsIFile *aFile, const char *loaderStr, const char *aType);
// nsComponentManagerImpl methods:
static nsComponentManagerImpl* gComponentManager;
NS_GetService(const char *aContractID, const nsIID& aIID, PRBool aDontCreate, nsISupports** result);
const char *aClassName,
const char *aContractID,
const char *aRegistryName,
const char *aType);
// Convert a loader type string into an index into the loader data
// array. Empty loader types are converted to NATIVE. Returns -1 if
// loader type cannot be determined.
int GetLoaderType(const char *typeStr);
// Add a loader type if not already known. Out the typeIndex
// if the loader type is either added or already there;
// returns NS_OK or an error on failure.
// registers only the files in spec's location by loaders other than the
// native loader. This is an optimization method only.
#endif
// Shutdown
#define NS_SHUTDOWN_NEVERHAPPENED 0
#define NS_SHUTDOWN_INPROGRESS 1
#define NS_SHUTDOWN_COMPLETE 2
int mNLoaderData;
int mMaxNLoaderData;
#ifdef XPCOM_CHECK_PENDING_CIDS
#endif
};
#define NS_MAX_FILENAME_LEN 1024
////////////////////////////////////////////////////////////////////////////////
/**
* Class: nsFactoryEntry()
*
* There are two types of FactoryEntries.
*
* 1. {CID, dll} mapping.
* Factory is a consequence of the dll. These can be either session
* specific or persistent based on whether we write this
* to the registry or not.
*
* 2. {CID, factory} mapping
* These are strictly session specific and in memory only.
*/
~nsFactoryEntry();
if (mFactory) {
return NS_OK;
}
if (mTypeIndex < 0)
return NS_ERROR_FAILURE;
return rv;
if (NS_SUCCEEDED(rv))
return rv;
}
// This is an index into the mLoaderData array that holds the type string and the loader
int mTypeIndex;
char* mLocation;
};
////////////////////////////////////////////////////////////////////////////////
};
char *mContractID;
};
{
~AutoRegEntry();
const nsDependentCString GetName()
// this is the optional field line in the compreg.dat.
// it must not contain any comma's and it must be null terminated.
char* GetOptionalData() {return mData;};
void SetOptionalData(const char* data);
char* mName;
char* mData;
};
#endif // nsComponentManager_h__