From 41e83422c911e63d33f0f4b8705d9f0aa0517a0f Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Wed, 22 Dec 1999 01:47:59 +0000 Subject: [PATCH] fix for 16273. r=valeski, a=sdagley. git-svn-id: svn://10.0.0.236/trunk@56328 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsWebShell.cpp | 5 --- mozilla/netwerk/base/src/nsFileTransport.cpp | 6 --- .../netwerk/base/src/nsSocketTransport.cpp | 9 +--- .../netwerk/protocol/ftp/src/nsFTPChannel.cpp | 4 -- mozilla/webshell/src/nsWebShell.cpp | 5 --- mozilla/xpcom/proxy/public/nsProxyEvent.h | 19 ++++---- .../xpcom/proxy/public/nsProxyObjectManager.h | 9 ---- mozilla/xpcom/proxy/src/nsProxyEvent.cpp | 43 +++++++++++++++++++ 8 files changed, 55 insertions(+), 45 deletions(-) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index f9a9543d527..e3072715864 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -3447,11 +3447,6 @@ nsWebShell::OnStatus(nsIChannel* channel, nsISupports* ctxt, channel, temp); -#ifndef BUG_16273_FIXED - //free the message- - PRUnichar* tempChar = (PRUnichar*) aMsg; - CRTFREEIF(tempChar); -#endif return rv; } return NS_OK; diff --git a/mozilla/netwerk/base/src/nsFileTransport.cpp b/mozilla/netwerk/base/src/nsFileTransport.cpp index d795a7f5ca2..56c9f8efc39 100644 --- a/mozilla/netwerk/base/src/nsFileTransport.cpp +++ b/mozilla/netwerk/base/src/nsFileTransport.cpp @@ -843,13 +843,7 @@ nsFileTransport::Process(void) // XXX fix up this message for i18n nsAutoString msg = "Read "; msg += (const char*)mSpec; - // this should just change to msg.mUStr instead once bug - // # 16273 is fixed -#ifndef BUG_16273_FIXED //TODO - (void)mProgress->OnStatus(this, mContext, msg.ToNewUnicode()); -#else (void)mProgress->OnStatus(this, mContext, msg.mUStr); -#endif } mContext = null_nsCOMPtr(); diff --git a/mozilla/netwerk/base/src/nsSocketTransport.cpp b/mozilla/netwerk/base/src/nsSocketTransport.cpp index b0d8ec89184..f245400a0bd 100644 --- a/mozilla/netwerk/base/src/nsSocketTransport.cpp +++ b/mozilla/netwerk/base/src/nsSocketTransport.cpp @@ -1889,18 +1889,11 @@ nsSocketTransport::fireStatus(PRUint32 aCode) mesg.Append(mHostName); if (NS_FAILED(rv)) return rv; -#ifndef BUG_16273_FIXED //TODO - return mEventSink ? mEventSink->OnStatus(this, - mReadContext, - mesg.ToNewUnicode()) // this gets freed elsewhere. - : NS_ERROR_FAILURE; -#else + return mEventSink ? mEventSink->OnStatus(this, mReadContext, mesg.mUStr) // this gets freed elsewhere. : NS_ERROR_FAILURE; -#endif - } diff --git a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp index b4a8980a7cc..0e68951b9fa 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp +++ b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp @@ -271,11 +271,7 @@ nsFTPChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount, if (mEventSink) { nsAutoString statusMsg("Beginning FTP transaction."); -#ifndef BUG_16273_FIXED //TODO - rv = mEventSink->OnStatus(this, ctxt, statusMsg.ToNewUnicode()); -#else rv = mEventSink->OnStatus(this, ctxt, statusMsg.GetUnicode()); -#endif if (NS_FAILED(rv)) return rv; } diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index f9a9543d527..e3072715864 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -3447,11 +3447,6 @@ nsWebShell::OnStatus(nsIChannel* channel, nsISupports* ctxt, channel, temp); -#ifndef BUG_16273_FIXED - //free the message- - PRUnichar* tempChar = (PRUnichar*) aMsg; - CRTFREEIF(tempChar); -#endif return rv; } return NS_OK; diff --git a/mozilla/xpcom/proxy/public/nsProxyEvent.h b/mozilla/xpcom/proxy/public/nsProxyEvent.h index ab08080d723..ac0d794e751 100644 --- a/mozilla/xpcom/proxy/public/nsProxyEvent.h +++ b/mozilla/xpcom/proxy/public/nsProxyEvent.h @@ -57,20 +57,21 @@ class nsProxyObjectCallInfo; // { // *x = 0; <----- You will blow up here. // +// +// So what gets saved? +// +// You can safely pass base types by value. You can also pass interface pointers. +// I will make sure that the interface pointers are addrefed while they are being +// proxied. You can also pass string and wstring. These I will copy and free. +// +// I do **NOT** copy arrays or strings with size. If you are using these either +// change your interface, or contact me about this feature request. // Using the ISupports interface just for addrefing. -#define NS_PROXYOBJECT_CID \ -{ 0xeea90d40, \ - 0xb09f, \ - 0x11d2, \ - {0x91, 0x5e, 0xc1, 0x2b, 0x69, 0x6c, 0x93, 0x33}\ -} - - class nsProxyObject : public nsISupports { public: @@ -175,6 +176,8 @@ private: nsCOMPtr mOwner; /* this is the strong referenced nsProxyObject */ void RefCountInInterfacePointers(PRBool addRef); + void CopyStrings(PRBool copy); + }; diff --git a/mozilla/xpcom/proxy/public/nsProxyObjectManager.h b/mozilla/xpcom/proxy/public/nsProxyObjectManager.h index 3f3e0a2389e..496a1bd02cf 100644 --- a/mozilla/xpcom/proxy/public/nsProxyObjectManager.h +++ b/mozilla/xpcom/proxy/public/nsProxyObjectManager.h @@ -35,15 +35,6 @@ #include "nsProxyEvent.h" - -#define NS_PROXYEVENT_FACTORY_IID \ -{ 0xeea90d40, \ - 0xb059, \ - 0x11d2, \ - {0x91, 0x5e, 0xc1, 0x2b, 0x69, 0x6c, 0x93, 0x33}\ -} - - #define NS_IPROXYEVENT_MANAGER_IID \ { 0xeea90d43, \ 0xb059, \ diff --git a/mozilla/xpcom/proxy/src/nsProxyEvent.cpp b/mozilla/xpcom/proxy/src/nsProxyEvent.cpp index 1f3cf1146a6..64b06b9ef08 100644 --- a/mozilla/xpcom/proxy/src/nsProxyEvent.cpp +++ b/mozilla/xpcom/proxy/src/nsProxyEvent.cpp @@ -63,12 +63,16 @@ nsProxyObjectCallInfo::nsProxyObjectCallInfo( nsProxyObject* owner, mOwner = owner; RefCountInInterfacePointers(PR_TRUE); + if (mOwner->GetProxyType() & PROXY_ASYNC) + CopyStrings(PR_TRUE); } nsProxyObjectCallInfo::~nsProxyObjectCallInfo() { RefCountInInterfacePointers(PR_FALSE); + if (mOwner->GetProxyType() & PROXY_ASYNC) + CopyStrings(PR_FALSE); mOwner = 0; @@ -106,6 +110,45 @@ nsProxyObjectCallInfo::RefCountInInterfacePointers(PRBool addRef) } } +void +nsProxyObjectCallInfo::CopyStrings(PRBool copy) +{ + for (PRUint32 i = 0; i < mParameterCount; i++) + { + const nsXPTParamInfo paramInfo = mMethodInfo->GetParam(i); + + if(paramInfo.IsIn()) + { + const nsXPTType& type = paramInfo.GetType(); + uint8 type_tag = type.TagPart(); + + if (type_tag == nsXPTType::T_CHAR_STR || type_tag == nsXPTType::T_WCHAR_STR) + { + if (mParameterList[i].val.p != nsnull) + { + if (copy) + { + nsString str((char*)mParameterList[i].val.p); + + if (type_tag == nsXPTType::T_CHAR_STR) + { + mParameterList[i].val.p = str.ToNewCString(); + } + else if (type_tag == nsXPTType::T_WCHAR_STR) + { + mParameterList[i].val.p = str.ToNewUnicode(); + } + } + else + { + Recycle((char*)mParameterList[i].val.p); + } + } + } + } + } +} + PRBool nsProxyObjectCallInfo::GetCompleted() {