helper function to make code that gets nsISupports proxies more readable: NS_GetProxyForObject (bug 74792). r=brendan@mozilla.org, sr=waterson@netscape.com

git-svn-id: svn://10.0.0.236/trunk@92235 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dmose%netscape.com
2001-04-13 22:13:04 +00:00
parent 08d052a062
commit e253dbb57e
2 changed files with 55 additions and 3 deletions

View File

@@ -17,7 +17,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Contributor(s): Doug Turner <dougt@netscape.com> (Original Author)
* Dan Mosedale <dmose@netscape.com>
*/
#include "nsISupports.idl"
interface nsIEventQueue;
@@ -54,4 +55,17 @@ interface nsIProxyObjectManager : nsISupports
{0x91, 0x5e, 0xc1, 0x2b, 0x69, 0x6c, 0x93, 0x33}\
}
/**
* Helper function for code that already has a link-time dependency on
* libxpcom and needs to get proxies in a bunch of different places.
* This way, the caller isn't forced to get the proxy object manager
* themselves every single time, thus making the calling code more
* readable.
*/
extern NS_COM nsresult
NS_GetProxyForObject(nsIEventQueue *destQueue,
REFNSIID aIID,
nsISupports* aObj,
PRInt32 proxyType,
void** aProxyObject);
%}

View File

@@ -17,8 +17,17 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
* Contributor(s): Doug Turner <dougt@netscape.com> (Original Author)
* Judson Valeski <valeski@netscape.com>
* Dan Matejka <danm@netscape.com>
* Scott Collins <scc@netscape.com>
* Heikki Toivonen <heiki@citec.fi>
* Patrick Beard <beard@netscape.com>
* Pierre Phaneuf <pp@ludusdesign.com>
* Warren Harris <warren@netscape.com>
* Chris Seawood <cls@seawood.org>
* Chris Waterson <waterson@netscape.com>
* Dan Mosedale <dmose@netscape.com>
*/
@@ -265,5 +274,34 @@ nsProxyObjectManager::GetProxy( nsIEventQueue *destQueue,
return rv;
}
/**
* Helper function for code that already has a link-time dependency on
* libxpcom and needs to get proxies in a bunch of different places.
* This way, the caller isn't forced to get the proxy object manager
* themselves every single time, thus making the calling code more
* readable.
*/
NS_COM nsresult
NS_GetProxyForObject(nsIEventQueue *destQueue,
REFNSIID aIID,
nsISupports* aObj,
PRInt32 proxyType,
void** aProxyObject)
{
static NS_DEFINE_CID(proxyObjMgrCID, NS_PROXYEVENT_MANAGER_CID);
nsresult rv; // temp for return value
// get the proxy object manager
//
nsCOMPtr<nsIProxyObjectManager> proxyObjMgr =
do_GetService(proxyObjMgrCID, &rv);
if (NS_FAILED(rv))
return NS_ERROR_FAILURE;
// and try to get the proxy object
//
return proxyObjMgr->GetProxyForObject(destQueue, aIID, aObj,
proxyType, aProxyObject);
}