Bug 405241 - "Don't register nsDownloadHistory if it's not needed" [p=comrade693+bmo@gmail.com (Shawn Wilsher [sdwilsh]) r=biesi sr=bzbarsky a1.9=damons]
This commit is contained in:
@@ -44,12 +44,43 @@
|
|||||||
#include "nsIGlobalHistory2.h"
|
#include "nsIGlobalHistory2.h"
|
||||||
#include "nsIObserverService.h"
|
#include "nsIObserverService.h"
|
||||||
#include "nsIURI.h"
|
#include "nsIURI.h"
|
||||||
|
#include "nsIComponentRegistrar.h"
|
||||||
|
#include "nsDocShellCID.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//// nsDownloadHistory
|
//// nsDownloadHistory
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS1(nsDownloadHistory, nsIDownloadHistory)
|
NS_IMPL_ISUPPORTS1(nsDownloadHistory, nsIDownloadHistory)
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsDownloadHistory::RegisterSelf(nsIComponentManager *aCompMgr,
|
||||||
|
nsIFile *aPath,
|
||||||
|
const char *aLoaderStr,
|
||||||
|
const char *aType,
|
||||||
|
const nsModuleComponentInfo *aInfo)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIComponentRegistrar> compReg(do_QueryInterface(aCompMgr));
|
||||||
|
if (!compReg)
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
|
PRBool registered;
|
||||||
|
nsresult rv = compReg->IsContractIDRegistered(NS_DOWNLOADHISTORY_CONTRACTID,
|
||||||
|
®istered);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
// If someone has already registered the contractID, we don't want to register
|
||||||
|
// it ourself. We do want to register though in case someone wants to access
|
||||||
|
// this implementation (by CID).
|
||||||
|
if (registered) {
|
||||||
|
return compReg->RegisterFactoryLocation(GetCID(), "nsDownloadHistory",
|
||||||
|
nsnull, aPath, aLoaderStr, aType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return compReg->RegisterFactoryLocation(GetCID(), "nsDownloadHistory",
|
||||||
|
NS_DOWNLOADHISTORY_CONTRACTID,
|
||||||
|
aPath, aLoaderStr, aType);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//// nsIDownloadHistory
|
//// nsIDownloadHistory
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
#define __nsDownloadHistory_h__
|
#define __nsDownloadHistory_h__
|
||||||
|
|
||||||
#include "nsIDownloadHistory.h"
|
#include "nsIDownloadHistory.h"
|
||||||
|
#include "nsIGenericFactory.h"
|
||||||
|
|
||||||
#define NS_DOWNLOADHISTORY_CID \
|
#define NS_DOWNLOADHISTORY_CID \
|
||||||
{0x2ee83680, 0x2af0, 0x4bcb, {0xbf, 0xa0, 0xc9, 0x70, 0x5f, 0x65, 0x54, 0xf1}}
|
{0x2ee83680, 0x2af0, 0x4bcb, {0xbf, 0xa0, 0xc9, 0x70, 0x5f, 0x65, 0x54, 0xf1}}
|
||||||
@@ -50,6 +51,14 @@ class nsDownloadHistory : public nsIDownloadHistory
|
|||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSIDOWNLOADHISTORY
|
NS_DECL_NSIDOWNLOADHISTORY
|
||||||
|
|
||||||
|
static NS_METHOD RegisterSelf(nsIComponentManager *aCompMgr,
|
||||||
|
nsIFile *aPath,
|
||||||
|
const char *aLoaderStr,
|
||||||
|
const char *aType,
|
||||||
|
const nsModuleComponentInfo *aInfo);
|
||||||
|
|
||||||
|
NS_DEFINE_STATIC_CID_ACCESSOR(NS_DOWNLOADHISTORY_CID)
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __nsDownloadHistory_h__
|
#endif // __nsDownloadHistory_h__
|
||||||
|
|||||||
@@ -250,7 +250,8 @@ static const nsModuleComponentInfo gDocShellModuleInfo[] = {
|
|||||||
|
|
||||||
// download history
|
// download history
|
||||||
{ "nsDownloadHistory", NS_DOWNLOADHISTORY_CID,
|
{ "nsDownloadHistory", NS_DOWNLOADHISTORY_CID,
|
||||||
NS_DOWNLOADHISTORY_CONTRACTID, nsDownloadHistoryConstructor }
|
nsnull, nsDownloadHistoryConstructor,
|
||||||
|
nsDownloadHistory::RegisterSelf }
|
||||||
};
|
};
|
||||||
|
|
||||||
// "docshell provider" to illustrate that this thing really *should*
|
// "docshell provider" to illustrate that this thing really *should*
|
||||||
|
|||||||
Reference in New Issue
Block a user