33935. r=dougt. I built on all three platforms. I smoketested win and linux, but mac is hanging after profile mgr so I can't verify it. When the CSS loader would try and load a non-existant local css file, we would crash. Now we post the OnComplete() callback asynchronously to the event queue so the CSS loader isn't entered recursively, and life is good again

This commit is contained in:
valeski%netscape.com 2000-03-31 20:39:16 +00:00
Родитель 5dea64f5a5
Коммит 465309a241
1 изменённых файлов: 18 добавлений и 5 удалений

Просмотреть файл

@ -25,6 +25,9 @@
#include "nsIURL.h"
#include "nsNetUtil.h"
#include "nsIChannel.h"
#include "nsProxiedService.h"
static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
NS_IMETHODIMP
nsStreamLoader::Init(nsIURI* aURL,
@ -43,11 +46,21 @@ nsStreamLoader::Init(nsIURI* aURL,
rv = NS_OpenURI(this, nsnull, aURL, nsnull, aGroup, notificationCallbacks,
loadAttributes, bufferSegmentSize, bufferMaxSize);
if (NS_FAILED(rv) && mObserver) {
nsresult rv2 = mObserver->OnStreamComplete(this, mContext, rv,
mData.Length(),
mData.GetBuffer());
if (NS_FAILED(rv2))
rv = rv2; // take the user's error instead
// don't callback synchronously as it puts the caller
// in a recursive situation and breaks the asynchronous
// semantics of nsIStreamLoader
nsresult rv2 = NS_OK;
NS_WITH_SERVICE(nsIProxyObjectManager, pIProxyObjectManager,
kProxyObjectManagerCID, &rv);
if (NS_FAILED(rv2)) return rv2;
nsCOMPtr<nsIStreamLoaderObserver> pObserver;
rv2 = pIProxyObjectManager->GetProxyObject(NS_CURRENT_EVENTQ,
NS_GET_IID(nsIStreamLoaderObserver), observer,
PROXY_ASYNC, getter_AddRefs(pObserver));
if (NS_FAILED(rv2)) return rv2;
rv = pObserver->OnStreamComplete(this, mContext, rv, 0, nsnull);
}
return rv;