diff --git a/mozilla/network/module/nsNetService.cpp b/mozilla/network/module/nsNetService.cpp index 0a18656cc79..e0626683383 100644 --- a/mozilla/network/module/nsNetService.cpp +++ b/mozilla/network/module/nsNetService.cpp @@ -922,23 +922,25 @@ static void bam_exit_routine(URL_Struct *URL_s, int status, MWContext *window_id PR_ASSERT(pConn); /* Release the ConnectionInfo object held in the URL_Struct. */ - if (pConn) { + if (nsnull != pConn) { /* * Normally, the stream is closed when the connection has been * completed. However, if the URL exit proc was called directly * by NET_GetURL(...), then the stream may still be around... */ - if (pConn->pNetStream) { + if (nsnull != pConn->pNetStream) { pConn->pNetStream->Close(); NS_RELEASE(pConn->pNetStream); } /* - * Notify the Data Consumer that the Binding has completed... - * Since the Consumer is still available, the stream was never + * If the connection is still marked as active, then + * notify the Data Consumer that the Binding has completed... + * Since the connection is still active, the stream was never * closed (or possibly created). So, the binding has failed... */ - if (pConn->pConsumer) { + if ((nsConnectionActive == pConn->mStatus) && + (nsnull != pConn->pConsumer)) { nsAutoString status; pConn->pConsumer->OnStopBinding(pConn->pURL, NS_BINDING_FAILED, status); NS_RELEASE(pConn->pConsumer); diff --git a/mozilla/network/module/nsNetStream.cpp b/mozilla/network/module/nsNetStream.cpp index bc0ee5ed5aa..75a1fb0494d 100644 --- a/mozilla/network/module/nsNetStream.cpp +++ b/mozilla/network/module/nsNetStream.cpp @@ -44,6 +44,7 @@ nsConnectionInfo::nsConnectionInfo(nsIURL *aURL, { NS_INIT_REFCNT(); + mStatus = nsConnectionActive; pURL = aURL; pNetStream = aStream; pConsumer = aNotify; diff --git a/mozilla/network/module/nsNetStream.h b/mozilla/network/module/nsNetStream.h index a1c2b18699b..2373e4609b2 100644 --- a/mozilla/network/module/nsNetStream.h +++ b/mozilla/network/module/nsNetStream.h @@ -29,6 +29,16 @@ /* Forward declaration... */ class nsNetlibStream; +/* Enumeration of the various connection states... */ +typedef enum { + nsConnectionActive = 0, + nsConnectionSucceeded, + nsConnectionAborted, + nsConnectionFailed, + nsConnectionMax +} nsConnectionStatus; + + class nsConnectionInfo : public nsIConnectionInfo { public: @@ -50,6 +60,7 @@ public: nsIURL *pURL; nsNetlibStream *pNetStream; nsIStreamListener *pConsumer; + nsConnectionStatus mStatus; }; diff --git a/mozilla/network/module/nsNetThread.cpp b/mozilla/network/module/nsNetThread.cpp index 13aea03cfb5..2a5db6bb2fc 100644 --- a/mozilla/network/module/nsNetThread.cpp +++ b/mozilla/network/module/nsNetThread.cpp @@ -47,6 +47,7 @@ extern "C" { #include "remoturl.h" #include "netcache.h" +#include "cvactive.h" void RL_Init(); @@ -106,6 +107,15 @@ nsresult NS_InitNetlib(void) NET_RegisterUniversalEncodingConverter("chunked", NULL, NET_ChunkedDecoderStream); + + NET_RegisterContentTypeConverter("multipart/x-mixed-replace", FO_NGLAYOUT, + (void *) CVACTIVE_SIGNAL_AT_END_OF_MULTIPART, + CV_MakeMultipleDocumentStream); + + NET_RegisterContentTypeConverter("multipart/mixed", FO_NGLAYOUT, + (void *) CVACTIVE_SIGNAL_AT_END_OF_MULTIPART, + CV_MakeMultipleDocumentStream); + RL_Init(); #if defined(XP_PC) diff --git a/mozilla/network/module/nsStubContext.cpp b/mozilla/network/module/nsStubContext.cpp index ae35ed91a2e..c9c6047fedc 100644 --- a/mozilla/network/module/nsStubContext.cpp +++ b/mozilla/network/module/nsStubContext.cpp @@ -269,7 +269,7 @@ PRIVATE void stub_GraphProgressInit(MWContext *context, if (nsnull != (pListener = getStreamListener(URL_s))) { nsConnectionInfo *pConn = (nsConnectionInfo *) URL_s->fe_data; pListener->OnProgress(pConn->pURL, 0, content_length); - pListener->Release(); + NS_RELEASE(pListener); } } @@ -289,7 +289,7 @@ PRIVATE void stub_GraphProgress(MWContext *context, nsConnectionInfo *pConn = (nsConnectionInfo *) URL_s->fe_data; pListener->OnProgress(pConn->pURL, bytes_received, content_length); - pListener->Release(); + NS_RELEASE(pListener); } } @@ -325,7 +325,7 @@ PRIVATE void stub_Progress(MWContext *context, const char *msg) (nsConnectionInfo *) context->modular_data->fe_data; nsAutoString status(msg); pListener->OnStatus(pConn->pURL, status); - pListener->Release(); + NS_RELEASE(pListener); } else { printf("%s\n", msg); } @@ -539,16 +539,14 @@ void stub_complete(NET_StreamClass *stream) /* Close the stream and remove it from the ConnectionInfo... */ pConn->pNetStream->Close(); - pConn->pNetStream->Release(); - pConn->pNetStream = NULL; + NS_RELEASE(pConn->pNetStream); /* Notify the Data Consumer that the Binding has completed... */ if (pConn->pConsumer) { nsAutoString status; pConn->pConsumer->OnStopBinding(pConn->pURL, NS_BINDING_SUCCEEDED, status); - pConn->pConsumer->Release(); - pConn->pConsumer = NULL; + pConn->mStatus = nsConnectionSucceeded; } /* Release the URL_Struct hanging off of the data_object */ @@ -565,8 +563,7 @@ void stub_abort(NET_StreamClass *stream, int status) /* Close the stream and remove it from the ConnectionInfo... */ pConn->pNetStream->Close(); - pConn->pNetStream->Release(); - pConn->pNetStream = NULL; + NS_RELEASE(pConn->pNetStream); /* Notify the Data Consumer that the Binding has completed... */ /* @@ -577,8 +574,7 @@ void stub_abort(NET_StreamClass *stream, int status) nsAutoString status; pConn->pConsumer->OnStopBinding(pConn->pURL, NS_BINDING_ABORTED, status); - pConn->pConsumer->Release(); - pConn->pConsumer = NULL; + pConn->mStatus = nsConnectionAborted; } /* Release the URL_Struct hanging off of the data_object */ @@ -681,6 +677,9 @@ NET_NGLayoutConverter(FO_Present_Types format_out, */ pConn = (nsConnectionInfo *)URL_s->fe_data; + /* Mark the connection as active... */ + pConn->mStatus = nsConnectionActive; + /* * If the URL address has been rewritten by netlib then update * the cached info in the URL object... @@ -699,19 +698,18 @@ NET_NGLayoutConverter(FO_Present_Types format_out, free(stream); return NULL; } - pConn->pNetStream->AddRef(); + NS_ADDREF(pConn->pNetStream); } /* Hang the URL_Struct off of the NET_StreamClass */ NET_HoldURLStruct(URL_s); stream->data_object = URL_s; - /* Notify the data consumer that Binding is beginning...*/ - /* XXX: check result to terminate connection if necessary */ #ifdef NOISY printf("+++ Created a stream for %s\n", URL_s->address); #endif - if (pConn->pConsumer) { + /* Notify the data consumer that Binding is beginning...*/ + if (nsnull != pConn->pConsumer) { nsresult rv; rv = pConn->pConsumer->OnStartBinding(pConn->pURL, URL_s->content_type);