Address review comments from bug 568691 comment 13/14/17:

* rename mozilla::Module struct entries to be clearer
* change Module documentation so that the last entry is { NULL } in all cases (the compiler will 0-expand the structure)
* remove NS_XPCOM_COMPONENT_REGISTRY_FILE
* add MOZ_MEDIA/MOZ_OGG/MOZ_WAVE/MOZ_WEBM ifdefs to nsHTMLMediaElement.h and nsContentUtils.cpp
This commit is contained in:
Benjamin Smedberg 2010-06-21 12:46:26 -04:00
parent 0df0345c66
commit 18fcb3c625
13 changed files with 79 additions and 78 deletions

View File

@ -6096,6 +6096,8 @@ nsIContentUtils::FindInternalContentViewer(const char* aType,
return docFactory.forget();
}
#ifdef MOZ_MEDIA
#ifdef MOZ_OGG
if (nsHTMLMediaElement::IsOggEnabled()) {
for (int i = 0; i < NS_ARRAY_LENGTH(nsHTMLMediaElement::gOggTypes); ++i) {
const char* type = nsHTMLMediaElement::gOggTypes[i];
@ -6108,6 +6110,23 @@ nsIContentUtils::FindInternalContentViewer(const char* aType,
}
}
}
#endif
#ifdef MOZ_WEBM
if (nsHTMLMediaElement::IsWebMEnabled()) {
for (int i = 0; i < NS_ARRAY_LENGTH(nsHTMLMediaElement::gWebMTypes); ++i) {
const char* type = nsHTMLMediaElement::gWebMTypes[i];
if (!strcmp(aType, type)) {
docFactory = do_GetService("@mozilla.org/content/document-loader-factory;1");
if (docFactory && aLoaderType) {
*aLoaderType = TYPE_CONTENT;
}
return docFactory.forget();
}
}
}
#endif
#endif // MOZ_MEDIA
if (AVAILABLE == pluginEnabled) {
docFactory = do_GetService(PLUGIN_DLF_CONTRACTID);

View File

@ -250,20 +250,26 @@ public:
// false here even if CanHandleMediaType would return true.
static PRBool ShouldHandleMediaType(const char* aMIMEType);
#ifdef MOZ_OGG
static bool IsOggEnabled();
static bool IsOggType(const nsACString& aType);
static const char gOggTypes[3][16];
static char const *const gOggCodecs[3];
#endif
#ifdef MOZ_WAVE
static bool IsWaveEnabled();
static bool IsWaveType(const nsACString& aType);
static const char gWaveTypes[4][16];
static char const *const gWaveCodecs[2];
#endif
#ifdef MOZ_WEBM
static bool IsWebMEnabled();
static bool IsWebMType(const nsACString& aType);
static const char gWebMTypes[2][17];
static char const *const gWebMCodecs[4];
#endif
/**
* Called when a child source element is added to this media element. This

View File

@ -158,9 +158,9 @@ class mozJSComponentLoader : public mozilla::ModuleLoader,
mCIDs = NULL;
mContractIDs = NULL;
mCategoryEntries = NULL;
getfactory = GetFactory;
loaded = NULL;
unloaded = NULL;
getFactoryProc = GetFactory;
loadProc = NULL;
unloadProc = NULL;
global = nsnull;
location = nsnull;

View File

@ -2440,9 +2440,6 @@ static void RemoveComponentRegistries(nsIFile* aProfileDir, nsIFile* aLocalProfi
if (!file)
return;
file->AppendNative(NS_LITERAL_CSTRING("compreg.dat"));
file->Remove(PR_FALSE);
if (aRemoveEMFiles) {
file->SetNativeLeafName(NS_LITERAL_CSTRING("extensions.ini"));
file->Remove(PR_FALSE);
@ -3276,7 +3273,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
// Every time a profile is loaded by a build with a different version,
// it updates the compatibility.ini file saying what version last wrote
// the compreg.dat. On subsequent launches if the version matches,
// the fastload caches. On subsequent launches if the version matches,
// there is no need for re-registration. If the user loads the same
// profile in different builds the component registry must be
// re-generated to prevent mysterious component loading failures.
@ -3288,7 +3285,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
}
else if (versionOK) {
if (!cachesOK) {
// Remove compreg.dat, forcing component re-registration.
// Remove caches, forcing component re-registration.
// The new list of additional components directories is derived from
// information in "extensions.ini".
RemoveComponentRegistries(profD, profLD, PR_FALSE);
@ -3300,7 +3297,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
// Nothing need be done for the normal startup case.
}
else {
// Remove compreg.dat, forcing component re-registration
// Remove caches, forcing component re-registration
// with the default set of components (this disables any potentially
// troublesome incompatible XPCOM components).
RemoveComponentRegistries(profD, profLD, PR_TRUE);

View File

@ -334,10 +334,7 @@ nsXREDirProvider::GetFile(const char* aProperty, PRBool* aPersistent,
else if (NS_SUCCEEDED(GetProfileStartupDir(getter_AddRefs(file)))) {
// We need to allow component, xpt, and chrome registration to
// occur prior to the profile-after-change notification.
if (!strcmp(aProperty, NS_XPCOM_COMPONENT_REGISTRY_FILE)) {
rv = file->AppendNative(NS_LITERAL_CSTRING("compreg.dat"));
}
else if (!strcmp(aProperty, NS_APP_USER_CHROME_DIR)) {
if (!strcmp(aProperty, NS_APP_USER_CHROME_DIR)) {
rv = file->AppendNative(NS_LITERAL_CSTRING("chrome"));
}
}

View File

@ -508,8 +508,7 @@ NS_InitXPCOM2(nsIServiceManager* *result,
NS_TIME_FUNCTION_MARK("Next: interface info manager init");
// The iimanager constructor searches and registers XPT files.
nsIInterfaceInfoManager* iim =
xptiInterfaceInfoManager::GetSingleton();
xptiInterfaceInfoManager::GetSingleton();
NS_TIME_FUNCTION_MARK("Next: register category providers");

View File

@ -49,19 +49,19 @@ namespace mozilla {
class GenericFactory : public nsIFactory
{
public:
typedef Module::ConstructorProc ConstructorProc;
typedef Module::ConstructorProcPtr ConstructorProcPtr;
NS_DECL_ISUPPORTS
NS_DECL_NSIFACTORY
GenericFactory(ConstructorProc ctor)
GenericFactory(ConstructorProcPtr ctor)
: mCtor(ctor)
{
NS_ASSERTION(mCtor, "GenericFactory with no constructor");
}
private:
ConstructorProc mCtor;
ConstructorProcPtr mCtor;
};
} // namespace mozilla

View File

@ -57,15 +57,15 @@ struct Module
struct CIDEntry;
typedef already_AddRefed<nsIFactory> (*GetFactoryProc)
typedef already_AddRefed<nsIFactory> (*GetFactoryProcPtr)
(const Module& module, const CIDEntry& entry);
typedef nsresult (*ConstructorProc)(nsISupports* aOuter,
const nsIID& aIID,
void** aResult);
typedef nsresult (*ConstructorProcPtr)(nsISupports* aOuter,
const nsIID& aIID,
void** aResult);
typedef nsresult (*LoadedFunc)();
typedef void (*UnloadedFunc)();
typedef nsresult (*LoadFuncPtr)();
typedef void (*UnloadFuncPtr)();
/**
* The constructor callback is an implementation detail of the default binary
@ -75,8 +75,8 @@ struct Module
{
const nsCID* cid;
bool service;
GetFactoryProc getfactory;
ConstructorProc constructor;
GetFactoryProcPtr getFactoryProc;
ConstructorProcPtr constructorProc;
};
struct ContractIDEntry
@ -99,19 +99,19 @@ struct Module
/**
* An array of CIDs (class IDs) implemented by this module. The final entry
* should be { NULL, false }
* should be { NULL }.
*/
const CIDEntry* mCIDs;
/**
* An array of mappings from contractid to CID. The final entry should
* be { NULL, NULL }
* be { NULL }.
*/
const ContractIDEntry* mContractIDs;
/**
* An array of category manager entries. The final entry should be
* { NULL, NULL, NULL }
* { NULL }.
*/
const CategoryEntry* mCategoryEntries;
@ -122,15 +122,15 @@ struct Module
* also NULL, a generic factory is generated using the CIDEntry constructor
* callback which must be non-NULL.
*/
GetFactoryProc getfactory;
GetFactoryProcPtr getFactoryProc;
/**
* Optional Function which are called when this module is loaded and
* at shutdown. These are not C++ constructor/destructors to avoid
* calling them too early in startup or too late in shutdown.
*/
LoadedFunc loaded;
UnloadedFunc unloaded;
LoadFuncPtr loadProc;
UnloadFuncPtr unloadProc;
};
} // namespace

View File

@ -168,16 +168,6 @@ NS_DEFINE_CID(kCategoryManagerCID, NS_CATEGORYMANAGER_CID);
#define UID_STRING_LENGTH 39
static void GetIDString(const nsID& aCID, char buf[UID_STRING_LENGTH])
{
PR_snprintf(buf, UID_STRING_LENGTH, gIDFormat,
aCID.m0, (PRUint32) aCID.m1, (PRUint32) aCID.m2,
(PRUint32) aCID.m3[0], (PRUint32) aCID.m3[1],
(PRUint32) aCID.m3[2], (PRUint32) aCID.m3[3],
(PRUint32) aCID.m3[4], (PRUint32) aCID.m3[5],
(PRUint32) aCID.m3[6], (PRUint32) aCID.m3[7]);
}
#ifdef NS_FUNCTION_TIMER
#define COMPMGR_TIME_FUNCTION_CID(cid) \
char cid_buf__[NSID_LENGTH] = { '\0' }; \
@ -747,8 +737,8 @@ nsComponentManagerImpl::KnownModule::Load()
}
}
if (!mLoaded) {
if (mModule->loaded) {
nsresult rv = mModule->loaded();
if (mModule->loadProc) {
nsresult rv = mModule->loadProc();
if (NS_FAILED(rv)) {
mFailed = true;
return rv;
@ -1491,17 +1481,26 @@ NS_IMETHODIMP
nsComponentManagerImpl::UnregisterFactory(const nsCID& aClass,
nsIFactory* aFactory)
{
nsAutoMonitor mon(mMon);
nsFactoryEntry* f = mFactories.Get(aClass);
if (!f || f->mFactory != aFactory)
return NS_ERROR_FACTORY_NOT_REGISTERED;
// Don't release the dying factory or service object until releasing
// the component manager monitor.
nsCOMPtr<nsIFactory> dyingFactory;
nsCOMPtr<nsISupports> dyingServiceObject;
mFactories.Remove(aClass);
{
nsAutoMonitor mon(mMon);
nsFactoryEntry* f = mFactories.Get(aClass);
if (!f || f->mFactory != aFactory)
return NS_ERROR_FACTORY_NOT_REGISTERED;
mFactories.Remove(aClass);
// This might leave a stale contractid -> factory mapping in
// place, so null out the factory entry (see
// nsFactoryEntry::GetFactory)
f->mFactory.swap(dyingFactory);
f->mServiceObject.swap(dyingServiceObject);
}
// This might leave a stale contractid -> factory mapping in place, so null
// out the factory entry (see nsFactoryEntry::GetFactory)
f->mFactory = NULL;
return NS_OK;
}
@ -1629,16 +1628,16 @@ nsFactoryEntry::GetFactory()
if (!mModule->Load())
return NULL;
if (mModule->Module()->getfactory) {
mFactory = mModule->Module()->getfactory(*mModule->Module(),
*mCIDEntry);
if (mModule->Module()->getFactoryProc) {
mFactory = mModule->Module()->getFactoryProc(*mModule->Module(),
*mCIDEntry);
}
else if (mCIDEntry->getfactory) {
mFactory = mCIDEntry->getfactory(*mModule->Module(), *mCIDEntry);
else if (mCIDEntry->getFactoryProc) {
mFactory = mCIDEntry->getFactoryProc(*mModule->Module(), *mCIDEntry);
}
else {
NS_ASSERTION(mCIDEntry->constructor, "no getfactory or constructor");
mFactory = new mozilla::GenericFactory(mCIDEntry->constructor);
NS_ASSERTION(mCIDEntry->constructorProc, "no getfactory or constructor");
mFactory = new mozilla::GenericFactory(mCIDEntry->constructorProc);
}
if (!mFactory)
return NULL;

View File

@ -194,8 +194,8 @@ public:
~KnownModule()
{
if (mLoaded && mModule->unloaded)
mModule->unloaded();
if (mLoaded && mModule->unloadProc)
mModule->unloadProc();
}
bool EnsureLoader();

View File

@ -81,7 +81,6 @@
#include "SpecialSystemDirectory.h"
#include "nsAppFileLocationProvider.h"
#define COMPONENT_REGISTRY_NAME NS_LITERAL_CSTRING("compreg.dat")
#define COMPONENT_DIRECTORY NS_LITERAL_CSTRING("components")
// define home directory
@ -622,15 +621,6 @@ nsDirectoryService::GetFile(const char *prop, PRBool *persistent, nsIFile **_ret
{
rv = GetCurrentProcessDirectory(getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sComponentRegistry)
{
rv = GetCurrentProcessDirectory(getter_AddRefs(localFile));
if (!localFile)
return NS_ERROR_FAILURE;
localFile->AppendNative(COMPONENT_DIRECTORY);
localFile->AppendNative(COMPONENT_REGISTRY_NAME);
}
// Unless otherwise set, the core pieces of the GRE exist
// in the current process directory.

View File

@ -37,7 +37,6 @@
* ***** END LICENSE BLOCK ***** */
DIR_ATOM(sCurrentProcess, NS_XPCOM_CURRENT_PROCESS_DIR)
DIR_ATOM(sComponentRegistry, NS_XPCOM_COMPONENT_REGISTRY_FILE)
DIR_ATOM(sGRE_Directory, NS_GRE_DIR)
DIR_ATOM(sOS_DriveDirectory, NS_OS_DRIVE_DIR)
DIR_ATOM(sOS_TemporaryDirectory, NS_OS_TEMP_DIR)

View File

@ -74,11 +74,6 @@
*/
#define NS_XPCOM_CURRENT_PROCESS_DIR "XCurProcD"
/* Property will return the location of the application components
* registry file.
*/
#define NS_XPCOM_COMPONENT_REGISTRY_FILE "ComRegF"
/* Property will return the location of the the XPCOM Shared Library.
*/
#define NS_XPCOM_LIBRARY_FILE "XpcomLib"