From 4f0e1d3860f86e02fa2d798f2cbcd8ef17fdd7a1 Mon Sep 17 00:00:00 2001 From: "jst%mozilla.org" Date: Thu, 22 Feb 2007 02:07:19 +0000 Subject: [PATCH] Backing out the fix for bug 328974 per coments in the bug. git-svn-id: svn://10.0.0.236/trunk@220686 18797224-902f-48f8-a5cc-f745e15eee43 --- .../js/src/xpconnect/src/xpccomponents.cpp | 107 +----------------- 1 file changed, 4 insertions(+), 103 deletions(-) diff --git a/mozilla/js/src/xpconnect/src/xpccomponents.cpp b/mozilla/js/src/xpconnect/src/xpccomponents.cpp index 062a51688db..68a02607de1 100644 --- a/mozilla/js/src/xpconnect/src/xpccomponents.cpp +++ b/mozilla/js/src/xpconnect/src/xpccomponents.cpp @@ -318,105 +318,6 @@ nsXPCComponents_Interfaces::NewEnumerate(nsIXPConnectWrappedNative *wrapper, } } -/** - * This class serves as a functor to look up interfaces based on name - */ -class xpc_InterfaceInfoNameLookup -{ -public: - xpc_InterfaceInfoNameLookup(const char * name) : m_Name(name) {} - nsIInterfaceInfo * operator()(nsIInterfaceInfoManager * pManager) - { - nsIInterfaceInfo * pInfo = nsnull; - pManager->GetInfoForName(m_Name, &pInfo); - return pInfo; - } -private: - const char * m_Name; -}; - -/** - * This class serves as a functor to look up interfaces based on IID - */ -class xpc_InterfaceInfoIIDLookup -{ -public: - xpc_InterfaceInfoIIDLookup(const nsID & iid) : m_IID(iid) {} - nsIInterfaceInfo * operator()(nsIInterfaceInfoManager * pManager) - { - nsIInterfaceInfo * pInfo = nsnull; - pManager->GetInfoForIID(&m_IID, &pInfo); - return pInfo; - } -private: - const nsID & m_IID; -}; - -/** - * This is a helper function that returns the list of managers for a super - * manager or null if here is no super manager or the list is empty - * @param pManager The manager being check for super manager support - * @return The enumerator - */ -static already_AddRefed -GetSuperManagerList(nsIInterfaceInfoManager * pManager) -{ - nsISimpleEnumerator * enumerator = nsnull; - // get the super manager - nsCOMPtr superManager = - do_QueryInterface(pManager); - if(superManager != nsnull) - { - // check for additional manager and retrieve the list if it has them - PRBool additionalManagers; - if(NS_SUCCEEDED(superManager->HasAdditionalManagers(&additionalManagers)) && additionalManagers) - { - superManager->EnumerateAdditionalManagers(&enumerator); - } - } - return enumerator; -} - -/** - * This function iterates managers looking for the interface that matches what - * lookup is looking for - * @param pManager The manager and possibly super manager - * @param lookup Holds the logic to inspect a manager for a desired interface - * @return The desired interface, will be null if not found - */ -template -already_AddRefed -xpc_FindInterfaceInfo(nsIInterfaceInfoManager * pManager, - Lookup lookup) -{ - // See if the manager has the interface - nsIInterfaceInfo * ppInfo = lookup(pManager); - if(ppInfo == nsnull) - { - // The manager didn't, so check the super manager managers - nsCOMPtr list = GetSuperManagerList(pManager); - if(list != nsnull) - { - // Iterate over the managers looking for the interface - nsCOMPtr current; - PRBool more; - while(NS_SUCCEEDED(list->HasMoreElements(&more)) && more && - NS_SUCCEEDED(list->GetNext(getter_AddRefs(current))) && - current) - { - // Check the current manager for the interface - ppInfo = lookup(current); - // If we found the interface exit the loop - if(ppInfo != nsnull) - { - break; - } - } - } - } - return ppInfo; -} - /* PRBool newResolve (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal id, in PRUint32 flags, out JSObjectPtr objp); */ NS_IMETHODIMP nsXPCComponents_Interfaces::NewResolve(nsIXPConnectWrappedNative *wrapper, @@ -431,8 +332,8 @@ nsXPCComponents_Interfaces::NewResolve(nsIXPConnectWrappedNative *wrapper, nsnull != (name = JS_GetStringBytes(JSVAL_TO_STRING(id))) && name[0] != '{') // we only allow interfaces by name here { - nsCOMPtr info = - xpc_FindInterfaceInfo(mManager, xpc_InterfaceInfoNameLookup(name)); + nsCOMPtr info; + mManager->GetInfoForName(name, getter_AddRefs(info)); if(!info) return NS_OK; @@ -772,8 +673,8 @@ nsXPCComponents_InterfacesByID::NewResolve(nsIXPConnectWrappedNative *wrapper, name)).get())) return NS_OK; - nsCOMPtr info = - xpc_FindInterfaceInfo(mManager, xpc_InterfaceInfoIIDLookup(iid)); + nsCOMPtr info; + mManager->GetInfoForIID(&iid, getter_AddRefs(info)); if(!info) return NS_OK;