Bug 263464: Reduce XTF QI roundtrips by consolidating 'AggregatesInterface()' and 'NS_NewXTFInterfaceAggregator()'. r=bryner. Affects XTF-enabled builds only.

git-svn-id: svn://10.0.0.236/trunk@165007 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
alex%croczilla.com
2004-11-05 15:18:21 +00:00
parent c481be0360
commit 666ff65eb4
4 changed files with 20 additions and 17 deletions

View File

@@ -95,12 +95,16 @@ nsXTFElementWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr)
else if (NS_SUCCEEDED(rv = nsXTFElementWrapperBase::QueryInterface(aIID, aInstancePtr))) {
return rv;
}
else if (AggregatesInterface(aIID)) {
#ifdef DEBUG
// printf("nsXTFElementWrapper::QueryInterface(): creating aggregation tearoff\n");
#endif
return NS_NewXTFInterfaceAggregator(aIID, GetXTFElement(), (nsIContent*)this,
(nsISupports**)aInstancePtr);
else {
// try to get get the interface from our wrapped element:
void *innerPtr = nsnull;
QueryInterfaceInner(aIID, &innerPtr);
if (innerPtr)
return NS_NewXTFInterfaceAggregator(aIID,
NS_STATIC_CAST(nsISupports*, innerPtr),
NS_STATIC_CAST(nsIContent*, this),
aInstancePtr);
}
return NS_ERROR_NO_INTERFACE;
@@ -542,15 +546,14 @@ nsXTFElementWrapper::SetNotificationMask(PRUint32 aNotificationMask)
//----------------------------------------------------------------------
// implementation helpers:
PRBool
nsXTFElementWrapper::AggregatesInterface(REFNSIID aIID)
nsXTFElementWrapper::QueryInterfaceInner(REFNSIID aIID, void** result)
{
// We must ensure that the inner element has a distinct xpconnect
// identity, so we mustn't aggregate nsIXPConnectWrappedJS:
if (aIID.Equals(NS_GET_IID(nsIXPConnectWrappedJS))) return PR_FALSE;
nsCOMPtr<nsISupports> inst;
GetXTFElement()->QueryInterface(aIID, getter_AddRefs(inst));
return (inst!=nsnull);
GetXTFElement()->QueryInterface(aIID, result);
return (*result!=nsnull);
}
PRBool

View File

@@ -120,7 +120,7 @@ protected:
virtual nsIXTFElement *GetXTFElement() const = 0;
// implementation helpers:
PRBool AggregatesInterface(REFNSIID aIID);
PRBool QueryInterfaceInner(REFNSIID aIID, void** result);
PRBool HandledByInner(nsIAtom* attr) const;

View File

@@ -54,7 +54,7 @@ protected:
NS_NewXTFInterfaceAggregator(const nsIID& iid,
nsISupports* inner,
nsISupports* outer,
nsISupports** result);
void** result);
nsXTFInterfaceAggregator(const nsIID& iid,
nsISupports* inner,
@@ -84,12 +84,12 @@ private:
nsXTFInterfaceAggregator::nsXTFInterfaceAggregator(const nsIID& iid,
nsISupports* inner,
nsISupports* outer)
: mOuter(outer), mIID(iid)
: mInner(inner), mOuter(outer), mIID(iid)
{
#ifdef DEBUG
// printf("nsXTFInterfaceAggregator CTOR\n");
#endif
inner->QueryInterface(iid, (void**)&mInner);
mInner->AddRef();
mOuter->AddRef();
}
@@ -106,13 +106,13 @@ nsresult
NS_NewXTFInterfaceAggregator(const nsIID& iid,
nsISupports* inner,
nsISupports* outer,
nsISupports** aResult){
void** aResult){
NS_PRECONDITION(aResult != nsnull, "null ptr");
if (!aResult)
return NS_ERROR_NULL_POINTER;
nsXTFInterfaceAggregator* result = new nsXTFInterfaceAggregator(iid,inner,outer);
if (! result)
if (!result)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(result);

View File

@@ -43,7 +43,7 @@ nsresult
NS_NewXTFInterfaceAggregator(const nsIID& iid,
nsISupports* inner,
nsISupports* outer,
nsISupports** result);
void** result);
#endif // __NS_XTFINTERFACEAGGREGATOR_H__