From aaaab1ab736e616dd3be97d09a71a6e8cef8bb98 Mon Sep 17 00:00:00 2001 From: "valeski@netscape.com" Date: Wed, 23 Jun 1999 23:32:43 +0000 Subject: [PATCH] added the nsIProxyCreateInstance.idl file to the xpidl auto gen macros. added smarts to proxy object mgr to determine whether or not the proxy obj is on the same thread as the caller (did this checkin for doug) --- xpcom/proxy/public/Makefile.in | 23 +++++++++------ xpcom/proxy/public/makefile.win | 5 ++++ .../idl => public}/nsIProxyCreateInstance.idl | 0 xpcom/proxy/src/idl/mk.bat | 6 ---- xpcom/proxy/src/nsProxyObjectManager.cpp | 16 ++++++++++- xpcom/proxy/tests/proxytests.cpp | 28 +++++++++++++++++++ 6 files changed, 62 insertions(+), 16 deletions(-) rename xpcom/proxy/{src/idl => public}/nsIProxyCreateInstance.idl (100%) delete mode 100755 xpcom/proxy/src/idl/mk.bat diff --git a/xpcom/proxy/public/Makefile.in b/xpcom/proxy/public/Makefile.in index 037f23f55116..88ad20640b71 100644 --- a/xpcom/proxy/public/Makefile.in +++ b/xpcom/proxy/public/Makefile.in @@ -14,20 +14,25 @@ # Copyright (C) 1998 Netscape Communications Corporation. All Rights # Reserved. -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -MODULE = xpcom +MODULE = xpcom -EXPORTS = nsProxyEvent.h \ - nsProxyObjectManager.h\ - $(NULL) +XPIDL_MODULE = proxyObjInst +XPIDLSRCS = \ + .\nsIProxyCreateInstance.idl \ + $(NULL) -EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) +EXPORTS = nsProxyEvent.h \ + nsProxyObjectManager.h\ + $(NULL) + +EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) include $(topsrcdir)/config/config.mk diff --git a/xpcom/proxy/public/makefile.win b/xpcom/proxy/public/makefile.win index 73052575cbf7..34bbca092810 100644 --- a/xpcom/proxy/public/makefile.win +++ b/xpcom/proxy/public/makefile.win @@ -26,4 +26,9 @@ EXPORTS = \ nsProxyObjectManager.h \ $(NULL) +XPIDL_MODULE = proxyObjInst +XPIDLSRCS = \ + .\nsIProxyCreateInstance.idl \ + $(NULL) + include <$(DEPTH)\config\rules.mak> diff --git a/xpcom/proxy/src/idl/nsIProxyCreateInstance.idl b/xpcom/proxy/public/nsIProxyCreateInstance.idl similarity index 100% rename from xpcom/proxy/src/idl/nsIProxyCreateInstance.idl rename to xpcom/proxy/public/nsIProxyCreateInstance.idl diff --git a/xpcom/proxy/src/idl/mk.bat b/xpcom/proxy/src/idl/mk.bat deleted file mode 100755 index e3e1e7d7d601..000000000000 --- a/xpcom/proxy/src/idl/mk.bat +++ /dev/null @@ -1,6 +0,0 @@ -xpidl -w -I ../../../../js/src/xpconnect/idl/ -m header nsIProxyCreateInstance.idl -xpidl -w -I ../../../../js/src/xpconnect/idl/ -m typelib nsIProxyCreateInstance.idl - -cp nsIProxyCreateInstance.xpt ../../../../dist/win32_d.obj/bin/components -cp nsIProxyCreateInstance.h ../ - diff --git a/xpcom/proxy/src/nsProxyObjectManager.cpp b/xpcom/proxy/src/nsProxyObjectManager.cpp index 2135225c9b05..652262f77bd9 100644 --- a/xpcom/proxy/src/nsProxyObjectManager.cpp +++ b/xpcom/proxy/src/nsProxyObjectManager.cpp @@ -168,6 +168,19 @@ nsProxyObjectManager::GetProxyObject(nsIEventQueue *destQueue, REFNSIID aIID, ns return NS_ERROR_UNEXPECTED; } + // check to see if the eventQ is on our thread. If so, just return the real object. + + if (postQ != nsnull && proxyType != PROXY_ASYNC) + { + PRBool aResult; + postQ->IsQueueOnCurrentThread(&aResult); + + if (aResult) + { + return aObj->QueryInterface(aIID, aProxyObject); + } + } + // check to see if proxy is there or not. *aProxyObject = nsProxyEventObject::GetNewOrUsedProxy(postQ, proxyType, aObj, aIID); if (*aProxyObject != nsnull) @@ -217,8 +230,9 @@ nsProxyObjectManager::GetProxyObject(nsIEventQueue *destQueue, // 3. Delete the create instance proxy and its real object. - delete ciObject; NS_RELEASE(ciProxy); + delete ciObject; + ciObject = nsnull; // 4. Check to see if creating the requested instance failed. diff --git a/xpcom/proxy/tests/proxytests.cpp b/xpcom/proxy/tests/proxytests.cpp index bb69a1ff4f62..3c0ce8f03874 100644 --- a/xpcom/proxy/tests/proxytests.cpp +++ b/xpcom/proxy/tests/proxytests.cpp @@ -354,6 +354,34 @@ static void PR_CALLBACK EventLoop( void *arg ) rv = eventQ->QueryInterface(nsIEventQueue::GetIID(), (void**)&gEventQueue); if (NS_FAILED(rv)) return; + + printf("Verifing calling Proxy on eventQ thread.\n"); + + nsIProxyObjectManager* manager; + + nsServiceManager::GetService( NS_XPCOMPROXY_PROGID, + kProxyObjectManagerIID, + (nsISupports **)&manager); + + PR_ASSERT(manager); + + nsITestProxy *proxyObject; + nsTestXPCFoo* foo = new nsTestXPCFoo(); + + PR_ASSERT(foo); + + manager->GetProxyObject(gEventQueue, nsITestProxy::GetIID(), foo, PROXY_SYNC, (void**)&proxyObject); + + PRInt32 a; + proxyObject->Test(1, 2, &a); + proxyObject->Test2(); + + delete foo; + NS_RELEASE(proxyObject); + + printf("End of Verification calling Proxy on eventQ thread.\n"); + + printf("Looping for events.\n"); PLEvent* event = nsnull;