nsProxyEvent.cpp revision 489ce997e6d81472bf0d1322ad2b5b57ffa4c53d
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK *****
*
* This Original Code has been modified by IBM Corporation.
* Modifications made by IBM described herein are
* Copyright (c) International Business Machines
* Corporation, 2000
*
* Modifications to Mozilla code or documentation
* identified per MPL Section 3.3
*
* Date Modified by Description of modification
* 04/20/2000 IBM Corp. Added PR_CALLBACK for Optlink use in OS2
*/
#include "nsProxyEvent.h"
#include "nsProxyEventPrivate.h"
#include "nsIProxyObjectManager.h"
#include "nsCRT.h"
#include "pratom.h"
#include "prmem.h"
#include "xptcall.h"
#include "nsIComponentManager.h"
#include "nsComponentManagerObsolete.h"
#include "nsIServiceManager.h"
#include "nsMemory.h"
#include "nsIEventQueueService.h"
#include "nsIThread.h"
#include "nsIAtom.h" //hack! Need a way to define a component as threadsafe (ie. sta).
/**
* Map the nsAUTF8String, nsUTF8String classes to the nsACString and
* nsCString classes respectively for now. These defines need to be removed
* once Jag lands his nsUTF8String implementation.
*/
#define nsAUTF8String nsACString
#define nsUTF8String nsCString
{
mCompleted = 0;
}
{
if (mParameterList)
#ifdef VBOX_USE_IPRT_IN_XPCOM
#else
free( (void*) mParameterList);
#endif
}
void
{
for (PRUint32 i = 0; i < mParameterCount; i++)
{
{
{
if (anInterface)
{
if(addRef)
anInterface->AddRef();
else
anInterface->Release();
}
}
}
}
}
void
{
for (PRUint32 i = 0; i < mParameterCount; i++)
{
{
if (!ptr)
continue;
if (copy)
{
switch (type_tag)
{
case nsXPTType::T_CHAR_STR:
mParameterList[i].val.p =
break;
case nsXPTType::T_WCHAR_STR:
mParameterList[i].val.p =
break;
case nsXPTType::T_DOMSTRING:
mParameterList[i].val.p =
break;
mParameterList[i].val.p =
break;
case nsXPTType::T_UTF8STRING:
mParameterList[i].val.p =
break;
default:
// Other types are ignored
break;
}
}
else
{
switch (type_tag)
{
case nsXPTType::T_CHAR_STR:
case nsXPTType::T_WCHAR_STR:
PL_strfree((char*) ptr);
break;
case nsXPTType::T_DOMSTRING:
break;
break;
case nsXPTType::T_UTF8STRING:
delete (nsUTF8String*) ptr;
break;
default:
// Other types are ignored
break;
}
}
}
}
}
{
return (PRBool)mCompleted;
}
void
{
}
void
{
if (mCallersEventQ)
{
this,
}
else
{
// caller does not have an eventQ? This is an error!
SetCompleted();
}
}
{
return mCallersEventQ;
}
void
{
}
{
}
nsProxyObject::nsProxyObject(nsIEventQueue *destQueue, PRInt32 proxyType, const nsCID &aClass, nsISupports *aDelegate, const nsIID &aIID)
{
aIID,
}
{
// I am worried about order of destruction here.
// do not remove assignments.
mRealObject = 0;
mDestQueue = 0;
}
void
{
}
void
nsProxyObject::Release(void)
{
if (count == 0)
{
if (callDirectly)
{
delete this;
return;
}
// need to do something special here so that
// the real object will always be deleted on
// the correct thread..
{
NS_ASSERTION(0, "Could not create a plevent. Leaking nsProxyObject!");
return; // if this happens we are going to leak.
}
this,
}
}
{
return NS_ERROR_NULL_POINTER;
{
return rv;
}
return rv;
if (!event)
return NS_ERROR_NULL_POINTER;
while (! proxyInfo->GetCompleted())
{
}
if (eventLoopCreated)
{
eventQ = 0;
}
return rv;
}
{
if (!paramCount) return NS_OK;
#ifdef VBOX_USE_IPRT_IN_XPCOM
#else
#endif
return NS_ERROR_OUT_OF_MEMORY;
for (int i = 0; i < paramCount; i++)
{
{
NS_WARNING("Async proxying of out parameters is not supported");
}
}
return NS_OK;
}
{
if (! mDestQueue || ! mRealObject)
return NS_ERROR_OUT_OF_MEMORY;
if (methodInfo->IsNotXPCOM())
return rv;
// see if we should call into the method directly. Either it is a QI function call
// (methodIndex == 0), or it is a sync proxy and this code is running on the same thread
// as the destination event queue.
if ( (methodIndex == 0) ||
(mProxyType & PROXY_SYNC &&
{
// invoke the magic of xptc...
if (fullParam)
#ifdef VBOX_USE_IPRT_IN_XPCOM
#else
#endif
return rv;
}
if (fullParam)
#ifdef VBOX_USE_IPRT_IN_XPCOM
#else
#endif
return NS_ERROR_OUT_OF_MEMORY;
}
fullParam, // will be deleted by ~()
event); // will be deleted by ~()
if (fullParam)
#ifdef VBOX_USE_IPRT_IN_XPCOM
#else
#endif
return NS_ERROR_OUT_OF_MEMORY;
}
if (mProxyType & PROXY_SYNC)
{
if (NS_SUCCEEDED(rv))
delete proxyInfo;
return rv;
}
if (mProxyType & PROXY_ASYNC)
{
return NS_OK;
}
return NS_ERROR_UNEXPECTED;
}
{
if (proxyObject == nsnull)
return;
{
delete owner;
}
else
{
owner->PostCompleted();
}
}
{
if (proxyObject)
{
// invoke the magic of xptc...
info->GetMethodIndex(),
info->GetParameterList());
}
else
{
}
return NULL;
}
{
}
{
owner->SetCompleted();
return nsnull;
}
{
return nsnull;
}
{
}