Reduce code size of do_GetService by moving an nsCOMPtr and QueryInterface out of the part that's done inline. b=264456 r=darin
git-svn-id: svn://10.0.0.236/trunk@163831 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
41461f0c76
commit
49198d090c
@ -217,6 +217,9 @@ nsGetServiceFromCategory::operator()(const nsIID& aIID, void** aInstancePtr) con
|
||||
{
|
||||
nsresult rv;
|
||||
nsXPIDLCString value;
|
||||
nsCOMPtr<nsIServiceManager> serviceManager =
|
||||
do_QueryInterface(mServiceManager);
|
||||
// XXX Should we use the provided service manager?
|
||||
nsCOMPtr<nsICategoryManager> catman =
|
||||
do_GetService(kCategoryManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) goto error;
|
||||
@ -233,8 +236,8 @@ nsGetServiceFromCategory::operator()(const nsIID& aIID, void** aInstancePtr) con
|
||||
rv = NS_ERROR_SERVICE_NOT_AVAILABLE;
|
||||
goto error;
|
||||
}
|
||||
if (mServiceManager) {
|
||||
rv = mServiceManager->GetServiceByContractID(value, aIID, (void**)aInstancePtr);
|
||||
if (serviceManager) {
|
||||
rv = serviceManager->GetServiceByContractID(value, aIID, (void**)aInstancePtr);
|
||||
} else {
|
||||
nsCOMPtr<nsIServiceManager> mgr;
|
||||
NS_GetServiceManager(getter_AddRefs(mgr));
|
||||
|
||||
@ -49,7 +49,7 @@ class NS_COM nsGetServiceByCID : public nsCOMPtr_helper
|
||||
public:
|
||||
nsGetServiceByCID( const nsCID& aCID, nsISupports* aServiceManager, nsresult* aErrorPtr )
|
||||
: mCID(aCID),
|
||||
mServiceManager( do_QueryInterface(aServiceManager) ),
|
||||
mServiceManager(aServiceManager),
|
||||
mErrorPtr(aErrorPtr)
|
||||
{
|
||||
// nothing else to do
|
||||
@ -59,7 +59,7 @@ class NS_COM nsGetServiceByCID : public nsCOMPtr_helper
|
||||
|
||||
private:
|
||||
const nsCID& mCID;
|
||||
nsCOMPtr<nsIServiceManager> mServiceManager;
|
||||
nsISupports* mServiceManager;
|
||||
nsresult* mErrorPtr;
|
||||
};
|
||||
|
||||
@ -82,7 +82,7 @@ class NS_COM nsGetServiceByContractID : public nsCOMPtr_helper
|
||||
public:
|
||||
nsGetServiceByContractID( const char* aContractID, nsISupports* aServiceManager, nsresult* aErrorPtr )
|
||||
: mContractID(aContractID),
|
||||
mServiceManager( do_QueryInterface(aServiceManager) ),
|
||||
mServiceManager(aServiceManager),
|
||||
mErrorPtr(aErrorPtr)
|
||||
{
|
||||
// nothing else to do
|
||||
@ -92,7 +92,7 @@ class NS_COM nsGetServiceByContractID : public nsCOMPtr_helper
|
||||
|
||||
private:
|
||||
const char* mContractID;
|
||||
nsCOMPtr<nsIServiceManager> mServiceManager;
|
||||
nsISupports* mServiceManager;
|
||||
nsresult* mErrorPtr;
|
||||
};
|
||||
|
||||
@ -118,7 +118,7 @@ class nsGetServiceFromCategory : public nsCOMPtr_helper
|
||||
nsresult* aErrorPtr)
|
||||
: mCategory(aCategory),
|
||||
mEntry(aEntry),
|
||||
mServiceManager( do_QueryInterface(aServiceManager) ),
|
||||
mServiceManager(aServiceManager),
|
||||
mErrorPtr(aErrorPtr)
|
||||
{
|
||||
// nothing else to do
|
||||
@ -128,7 +128,7 @@ class nsGetServiceFromCategory : public nsCOMPtr_helper
|
||||
protected:
|
||||
const char* mCategory;
|
||||
const char* mEntry;
|
||||
nsCOMPtr<nsIServiceManager> mServiceManager;
|
||||
nsISupports* mServiceManager;
|
||||
nsresult* mErrorPtr;
|
||||
};
|
||||
|
||||
|
||||
@ -150,8 +150,10 @@ nsresult
|
||||
nsGetServiceByCID::operator()( const nsIID& aIID, void** aInstancePtr ) const
|
||||
{
|
||||
nsresult status = NS_ERROR_FAILURE;
|
||||
if ( mServiceManager ) {
|
||||
status = mServiceManager->GetService(mCID, aIID, (void**)aInstancePtr);
|
||||
nsCOMPtr<nsIServiceManager> serviceManager =
|
||||
do_QueryInterface(mServiceManager);
|
||||
if ( serviceManager ) {
|
||||
status = serviceManager->GetService(mCID, aIID, (void**)aInstancePtr);
|
||||
} else {
|
||||
nsCOMPtr<nsIServiceManager> mgr;
|
||||
NS_GetServiceManager(getter_AddRefs(mgr));
|
||||
@ -170,8 +172,10 @@ nsresult
|
||||
nsGetServiceByContractID::operator()( const nsIID& aIID, void** aInstancePtr ) const
|
||||
{
|
||||
nsresult status = NS_ERROR_FAILURE;
|
||||
if ( mServiceManager ) {
|
||||
status = mServiceManager->GetServiceByContractID(mContractID, aIID, (void**)aInstancePtr);
|
||||
nsCOMPtr<nsIServiceManager> serviceManager =
|
||||
do_QueryInterface(mServiceManager);
|
||||
if ( serviceManager ) {
|
||||
status = serviceManager->GetServiceByContractID(mContractID, aIID, (void**)aInstancePtr);
|
||||
} else {
|
||||
nsCOMPtr<nsIServiceManager> mgr;
|
||||
NS_GetServiceManager(getter_AddRefs(mgr));
|
||||
|
||||
@ -49,7 +49,7 @@ class NS_COM nsGetServiceByCID : public nsCOMPtr_helper
|
||||
public:
|
||||
nsGetServiceByCID( const nsCID& aCID, nsISupports* aServiceManager, nsresult* aErrorPtr )
|
||||
: mCID(aCID),
|
||||
mServiceManager( do_QueryInterface(aServiceManager) ),
|
||||
mServiceManager(aServiceManager),
|
||||
mErrorPtr(aErrorPtr)
|
||||
{
|
||||
// nothing else to do
|
||||
@ -59,7 +59,7 @@ class NS_COM nsGetServiceByCID : public nsCOMPtr_helper
|
||||
|
||||
private:
|
||||
const nsCID& mCID;
|
||||
nsCOMPtr<nsIServiceManager> mServiceManager;
|
||||
nsISupports* mServiceManager;
|
||||
nsresult* mErrorPtr;
|
||||
};
|
||||
|
||||
@ -82,7 +82,7 @@ class NS_COM nsGetServiceByContractID : public nsCOMPtr_helper
|
||||
public:
|
||||
nsGetServiceByContractID( const char* aContractID, nsISupports* aServiceManager, nsresult* aErrorPtr )
|
||||
: mContractID(aContractID),
|
||||
mServiceManager( do_QueryInterface(aServiceManager) ),
|
||||
mServiceManager(aServiceManager),
|
||||
mErrorPtr(aErrorPtr)
|
||||
{
|
||||
// nothing else to do
|
||||
@ -92,7 +92,7 @@ class NS_COM nsGetServiceByContractID : public nsCOMPtr_helper
|
||||
|
||||
private:
|
||||
const char* mContractID;
|
||||
nsCOMPtr<nsIServiceManager> mServiceManager;
|
||||
nsISupports* mServiceManager;
|
||||
nsresult* mErrorPtr;
|
||||
};
|
||||
|
||||
@ -118,7 +118,7 @@ class nsGetServiceFromCategory : public nsCOMPtr_helper
|
||||
nsresult* aErrorPtr)
|
||||
: mCategory(aCategory),
|
||||
mEntry(aEntry),
|
||||
mServiceManager( do_QueryInterface(aServiceManager) ),
|
||||
mServiceManager(aServiceManager),
|
||||
mErrorPtr(aErrorPtr)
|
||||
{
|
||||
// nothing else to do
|
||||
@ -128,7 +128,7 @@ class nsGetServiceFromCategory : public nsCOMPtr_helper
|
||||
protected:
|
||||
const char* mCategory;
|
||||
const char* mEntry;
|
||||
nsCOMPtr<nsIServiceManager> mServiceManager;
|
||||
nsISupports* mServiceManager;
|
||||
nsresult* mErrorPtr;
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user