From f9515f980692d4425de51916d95eaa90cb411a2e Mon Sep 17 00:00:00 2001 From: rpotts Date: Thu, 4 Jun 1998 05:09:32 +0000 Subject: [PATCH] Minor changes to nsIStreamListener interface... OnStartBinding(...) now passes out the stream content-type. User visible strings are now nsString arguments (for subsequent i18n) git-svn-id: svn://10.0.0.236/trunk@3160 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/htmlparser/robot/nsDebugRobot.cpp | 12 ++++++---- mozilla/htmlparser/src/nsHTMLParser.cpp | 10 ++++---- mozilla/htmlparser/src/nsHTMLParser.h | 6 ++--- mozilla/network/module/nsIStreamListener.h | 12 ++++++---- mozilla/network/module/nsNetService.cpp | 5 +++- mozilla/network/module/nsStubContext.cpp | 23 ++++++++++++++----- mozilla/network/module/tests/nettest.cpp | 21 +++++++++-------- .../parser/htmlparser/robot/nsDebugRobot.cpp | 12 ++++++---- .../parser/htmlparser/src/nsHTMLParser.cpp | 10 ++++---- mozilla/parser/htmlparser/src/nsHTMLParser.h | 6 ++--- mozilla/webshell/tests/viewer/nsViewer.cpp | 11 +++++---- mozilla/webshell/tests/viewer/nsViewer.h | 6 ++--- 12 files changed, 79 insertions(+), 55 deletions(-) diff --git a/mozilla/htmlparser/robot/nsDebugRobot.cpp b/mozilla/htmlparser/robot/nsDebugRobot.cpp index 7ada38c3050..4204dfc76b6 100644 --- a/mozilla/htmlparser/robot/nsDebugRobot.cpp +++ b/mozilla/htmlparser/robot/nsDebugRobot.cpp @@ -130,15 +130,17 @@ public: NS_DECL_ISUPPORTS NS_IMETHOD GetBindInfo(void) { return NS_OK; } - NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const char *msg) { return NS_OK; } - NS_IMETHOD OnStartBinding(void) { return NS_OK; } + NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMsg) { return NS_OK; } + NS_IMETHOD OnStartBinding(const char *aContentType) { return NS_OK; } NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length) { return NS_OK; } - NS_IMETHOD OnStopBinding(PRInt32 status, const char *msg); + NS_IMETHOD OnStopBinding(PRInt32 status, const nsString& aMsg); }; -NS_IMETHODIMP CStreamListener::OnStopBinding(PRInt32 status, const char *msg) +NS_IMETHODIMP CStreamListener::OnStopBinding(PRInt32 status, const nsString& aMsg) { - printf("CStreamListener: stream complete: %s\n", msg); + fputs("CStreamListener: stream complete: ", stdout); + fputs(aMsg, stdout); + fputs("\n", stdout); g_bReadyForNextUrl = PR_TRUE; return NS_OK; } diff --git a/mozilla/htmlparser/src/nsHTMLParser.cpp b/mozilla/htmlparser/src/nsHTMLParser.cpp index ba05a5e1d97..59eaf1d06f6 100644 --- a/mozilla/htmlparser/src/nsHTMLParser.cpp +++ b/mozilla/htmlparser/src/nsHTMLParser.cpp @@ -1629,7 +1629,7 @@ nsresult nsHTMLParser::GetBindInfo(void){ */ nsresult nsHTMLParser::OnProgress(PRInt32 aProgress, PRInt32 aProgressMax, - const char *aMsg) + const nsString& aMsg) { nsresult result=0; if (nsnull != mListener) { @@ -1645,9 +1645,9 @@ nsHTMLParser::OnProgress(PRInt32 aProgress, PRInt32 aProgressMax, * @param * @return */ -nsresult nsHTMLParser::OnStartBinding(void){ +nsresult nsHTMLParser::OnStartBinding(const char *aContentType){ if (nsnull != mListener) { - mListener->OnStartBinding(); + mListener->OnStartBinding(aContentType); } nsresult result=WillBuildModel(); if(!mTransferBuffer) { @@ -1710,10 +1710,10 @@ nsresult nsHTMLParser::OnDataAvailable(nsIInputStream *pIStream, PRInt32 length) * @param * @return */ -nsresult nsHTMLParser::OnStopBinding(PRInt32 status, const char *msg){ +nsresult nsHTMLParser::OnStopBinding(PRInt32 status, const nsString& aMsg){ nsresult result=DidBuildModel(status); if (nsnull != mListener) { - mListener->OnStopBinding(status, msg); + mListener->OnStopBinding(status, aMsg); } return result; } diff --git a/mozilla/htmlparser/src/nsHTMLParser.h b/mozilla/htmlparser/src/nsHTMLParser.h index 2d63b9a9728..24910f2bc87 100644 --- a/mozilla/htmlparser/src/nsHTMLParser.h +++ b/mozilla/htmlparser/src/nsHTMLParser.h @@ -249,10 +249,10 @@ friend class CTokenHandler; // net lib to let us know about our inputstream. //********************************************* NS_IMETHOD GetBindInfo(void); - NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const char *msg); - NS_IMETHOD OnStartBinding(void); + NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMmsg); + NS_IMETHOD OnStartBinding(const char *aContentType); NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length); - NS_IMETHOD OnStopBinding(PRInt32 status, const char *msg); + NS_IMETHOD OnStopBinding(PRInt32 status, const nsString& aMsg); protected: diff --git a/mozilla/network/module/nsIStreamListener.h b/mozilla/network/module/nsIStreamListener.h index 263e120c481..932ef683e88 100644 --- a/mozilla/network/module/nsIStreamListener.h +++ b/mozilla/network/module/nsIStreamListener.h @@ -24,7 +24,7 @@ /* forward declaration */ class nsIInputStream; - +class nsString; /* 45d234d0-c6c9-11d1-bea2-00805f8a66dc */ #define NS_ISTREAMNOTIFICATION_IID \ @@ -54,7 +54,8 @@ public: /** * Notify the client that progress as occurred for the URL load.
*/ - NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const char *msg) = 0; + NS_IMETHOD OnProgress(PRInt32 aProgress, PRInt32 aProgressMax, + const nsString &aMsg) = 0; /** * Notify the client that the URL has started to load. This method is @@ -63,7 +64,7 @@ public: * @return The return value is currently ignored. In the future it may be * used to cancel the URL load.. */ - NS_IMETHOD OnStartBinding(void) = 0; + NS_IMETHOD OnStartBinding(const char *aContentType) = 0; /** * Notify the client that data is available in the input stream. This @@ -75,7 +76,8 @@ public: * @param length The amount of data that was just pushed into the stream. * @return The return value is currently ignored. */ - NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length) = 0; + NS_IMETHOD OnDataAvailable(nsIInputStream *aIStream, + PRInt32 aLength) = 0; /** * Notify the client that the URL has finished loading. This method is @@ -88,7 +90,7 @@ public: * @param msg A text string describing the error. * @return The return value is currently ignored. */ - NS_IMETHOD OnStopBinding(PRInt32 status, const char *msg) = 0; + NS_IMETHOD OnStopBinding(PRInt32 aStatus, const nsString &aMsg) = 0; }; /* Generic status codes for OnStopBinding */ diff --git a/mozilla/network/module/nsNetService.cpp b/mozilla/network/module/nsNetService.cpp index 0593e12a03a..56aa0c8f4fd 100644 --- a/mozilla/network/module/nsNetService.cpp +++ b/mozilla/network/module/nsNetService.cpp @@ -21,6 +21,7 @@ #include "net.h" #include "mktrace.h" +#include "nsString.h" #include "nsIProtocolConnection.h" /* XXX: Legacy definitions... */ @@ -318,7 +319,9 @@ static void bam_exit_routine(URL_Struct *URL_s, int status, MWContext *window_id * closed (or possibly created). So, the binding has failed... */ if (pConn->pConsumer) { - pConn->pConsumer->OnStopBinding(NS_BINDING_FAILED, nsnull); + nsAutoString status; + + pConn->pConsumer->OnStopBinding(NS_BINDING_FAILED, status); pConn->pConsumer->Release(); pConn->pConsumer = NULL; } diff --git a/mozilla/network/module/nsStubContext.cpp b/mozilla/network/module/nsStubContext.cpp index e6832c8e9c9..fb51d1c5a23 100644 --- a/mozilla/network/module/nsStubContext.cpp +++ b/mozilla/network/module/nsStubContext.cpp @@ -23,6 +23,7 @@ #include "ctxtfunc.h" #include "xp_list.h" +#include "nsString.h" #include "nsIStreamListener.h" #include "nsNetStream.h" @@ -57,7 +58,9 @@ PRIVATE void stub_GraphProgressInit(MWContext *context, */ pConn = (nsConnectionInfo *)URL_s->fe_data; if ((NULL != pConn) && (NULL != pConn->pConsumer)) { - pConn->pConsumer->OnProgress(0, content_length, NULL); + nsAutoString status; + + pConn->pConsumer->OnProgress(0, content_length, status); } } } @@ -78,7 +81,9 @@ PRIVATE void stub_GraphProgress(MWContext *context, */ pConn = (nsConnectionInfo *)URL_s->fe_data; if ((NULL != pConn) && (NULL != pConn->pConsumer)) { - pConn->pConsumer->OnProgress(bytes_received, content_length, NULL); + nsAutoString status; + + pConn->pConsumer->OnProgress(bytes_received, content_length, status); } } } @@ -103,7 +108,9 @@ PRIVATE void stub_GraphProgressDestroy(MWContext *context, */ pConn = (nsConnectionInfo *)URL_s->fe_data; if ((NULL != pConn) && (NULL != pConn->pConsumer)) { - pConn->pConsumer->OnProgress(total_bytes_read, content_length, NULL); + nsAutoString status; + + pConn->pConsumer->OnProgress(total_bytes_read, content_length, status); } } } @@ -312,7 +319,9 @@ void stub_complete(NET_StreamClass *stream) /* Notify the Data Consumer that the Binding has completed... */ if (pConn->pConsumer) { - pConn->pConsumer->OnStopBinding(NS_BINDING_SUCCEEDED, nsnull); + nsAutoString status; + + pConn->pConsumer->OnStopBinding(NS_BINDING_SUCCEEDED, status); pConn->pConsumer->Release(); pConn->pConsumer = NULL; } @@ -340,7 +349,9 @@ void stub_abort(NET_StreamClass *stream, int status) * abort... */ if (pConn->pConsumer) { - pConn->pConsumer->OnStopBinding(NS_BINDING_ABORTED, nsnull); + nsAutoString status; + + pConn->pConsumer->OnStopBinding(NS_BINDING_ABORTED, status); pConn->pConsumer->Release(); pConn->pConsumer = NULL; } @@ -471,7 +482,7 @@ NET_StreamBuilder (FO_Present_Types format_out, printf("+++ Created a stream for %s\n", URL_s->address); #endif if (pConn->pConsumer) { - pConn->pConsumer->OnStartBinding(); + pConn->pConsumer->OnStartBinding(URL_s->content_type); } } } diff --git a/mozilla/network/module/tests/nettest.cpp b/mozilla/network/module/tests/nettest.cpp index 306571b3101..8012d22a791 100644 --- a/mozilla/network/module/tests/nettest.cpp +++ b/mozilla/network/module/tests/nettest.cpp @@ -55,10 +55,10 @@ public: TestConsumer(); NS_IMETHOD GetBindInfo(void); - NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const char *msg); - NS_IMETHOD OnStartBinding(void); + NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMsg); + NS_IMETHOD OnStartBinding(const char *aContentType); NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length); - NS_IMETHOD OnStopBinding(PRInt32 status, const char *msg); + NS_IMETHOD OnStopBinding(PRInt32 status, const nsString& aMsg); protected: ~TestConsumer(); @@ -92,11 +92,14 @@ NS_IMETHODIMP TestConsumer::GetBindInfo(void) return 0; } -NS_IMETHODIMP TestConsumer::OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const char *msg) +NS_IMETHODIMP TestConsumer::OnProgress(PRInt32 Progress, PRInt32 ProgressMax, + const nsString& aMsg) { if (bTraceEnabled) { - if (msg) { - printf("\n+++ TestConsumer::OnProgress: status %s\n", msg); + if (aMsg.Length()) { + printf("\n+++ TestConsumer::OnProgress: status "); + fputs(aMsg, stdout); + fputs("\n", stdout); } else { printf("\n+++ TestConsumer::OnProgress: %d of total %d\n", Progress, ProgressMax); } @@ -105,10 +108,10 @@ NS_IMETHODIMP TestConsumer::OnProgress(PRInt32 Progress, PRInt32 ProgressMax, co return 0; } -NS_IMETHODIMP TestConsumer::OnStartBinding(void) +NS_IMETHODIMP TestConsumer::OnStartBinding(const char *aContentType) { if (bTraceEnabled) { - printf("\n+++ TestConsumer::OnStartBinding\n"); + printf("\n+++ TestConsumer::OnStartBinding: Content type: %s\n", aContentType); } return 0; @@ -138,7 +141,7 @@ NS_IMETHODIMP TestConsumer::OnDataAvailable(nsIInputStream *pIStream, PRInt32 le } -NS_IMETHODIMP TestConsumer::OnStopBinding(PRInt32 status, const char *msg) +NS_IMETHODIMP TestConsumer::OnStopBinding(PRInt32 status, const nsString& aMsg) { if (bTraceEnabled) { printf("\n+++ TestConsumer::OnStopBinding... status: %d\n", status); diff --git a/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp b/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp index 7ada38c3050..4204dfc76b6 100644 --- a/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp +++ b/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp @@ -130,15 +130,17 @@ public: NS_DECL_ISUPPORTS NS_IMETHOD GetBindInfo(void) { return NS_OK; } - NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const char *msg) { return NS_OK; } - NS_IMETHOD OnStartBinding(void) { return NS_OK; } + NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMsg) { return NS_OK; } + NS_IMETHOD OnStartBinding(const char *aContentType) { return NS_OK; } NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length) { return NS_OK; } - NS_IMETHOD OnStopBinding(PRInt32 status, const char *msg); + NS_IMETHOD OnStopBinding(PRInt32 status, const nsString& aMsg); }; -NS_IMETHODIMP CStreamListener::OnStopBinding(PRInt32 status, const char *msg) +NS_IMETHODIMP CStreamListener::OnStopBinding(PRInt32 status, const nsString& aMsg) { - printf("CStreamListener: stream complete: %s\n", msg); + fputs("CStreamListener: stream complete: ", stdout); + fputs(aMsg, stdout); + fputs("\n", stdout); g_bReadyForNextUrl = PR_TRUE; return NS_OK; } diff --git a/mozilla/parser/htmlparser/src/nsHTMLParser.cpp b/mozilla/parser/htmlparser/src/nsHTMLParser.cpp index ba05a5e1d97..59eaf1d06f6 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLParser.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLParser.cpp @@ -1629,7 +1629,7 @@ nsresult nsHTMLParser::GetBindInfo(void){ */ nsresult nsHTMLParser::OnProgress(PRInt32 aProgress, PRInt32 aProgressMax, - const char *aMsg) + const nsString& aMsg) { nsresult result=0; if (nsnull != mListener) { @@ -1645,9 +1645,9 @@ nsHTMLParser::OnProgress(PRInt32 aProgress, PRInt32 aProgressMax, * @param * @return */ -nsresult nsHTMLParser::OnStartBinding(void){ +nsresult nsHTMLParser::OnStartBinding(const char *aContentType){ if (nsnull != mListener) { - mListener->OnStartBinding(); + mListener->OnStartBinding(aContentType); } nsresult result=WillBuildModel(); if(!mTransferBuffer) { @@ -1710,10 +1710,10 @@ nsresult nsHTMLParser::OnDataAvailable(nsIInputStream *pIStream, PRInt32 length) * @param * @return */ -nsresult nsHTMLParser::OnStopBinding(PRInt32 status, const char *msg){ +nsresult nsHTMLParser::OnStopBinding(PRInt32 status, const nsString& aMsg){ nsresult result=DidBuildModel(status); if (nsnull != mListener) { - mListener->OnStopBinding(status, msg); + mListener->OnStopBinding(status, aMsg); } return result; } diff --git a/mozilla/parser/htmlparser/src/nsHTMLParser.h b/mozilla/parser/htmlparser/src/nsHTMLParser.h index 2d63b9a9728..24910f2bc87 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLParser.h +++ b/mozilla/parser/htmlparser/src/nsHTMLParser.h @@ -249,10 +249,10 @@ friend class CTokenHandler; // net lib to let us know about our inputstream. //********************************************* NS_IMETHOD GetBindInfo(void); - NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const char *msg); - NS_IMETHOD OnStartBinding(void); + NS_IMETHOD OnProgress(PRInt32 Progress, PRInt32 ProgressMax, const nsString& aMmsg); + NS_IMETHOD OnStartBinding(const char *aContentType); NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length); - NS_IMETHOD OnStopBinding(PRInt32 status, const char *msg); + NS_IMETHOD OnStopBinding(PRInt32 status, const nsString& aMsg); protected: diff --git a/mozilla/webshell/tests/viewer/nsViewer.cpp b/mozilla/webshell/tests/viewer/nsViewer.cpp index e08631d6580..5a993e83732 100644 --- a/mozilla/webshell/tests/viewer/nsViewer.cpp +++ b/mozilla/webshell/tests/viewer/nsViewer.cpp @@ -307,17 +307,18 @@ DocObserver::GetBindInfo(void) NS_IMETHODIMP DocObserver::OnProgress(PRInt32 aProgress, PRInt32 aProgressMax, - const char *aMsg) + const nsString& aMsg) { fputs("[progress ", stdout); fputs(mURL, stdout); - printf(" %d %d %s]\n", aProgress, aProgressMax, - aMsg ? aMsg : ""); + printf(" %d %d ", aProgress, aProgressMax); + fputs(aMsg, stdout); + fputs("]\n", stdout); return NS_OK; } NS_IMETHODIMP -DocObserver::OnStartBinding(void) +DocObserver::OnStartBinding(const char *aContentType) { fputs("Loading ", stdout); fputs(mURL, stdout); @@ -332,7 +333,7 @@ DocObserver::OnDataAvailable(nsIInputStream *pIStream, PRInt32 length) } NS_IMETHODIMP -DocObserver::OnStopBinding(PRInt32 status, const char *msg) +DocObserver::OnStopBinding(PRInt32 status, const nsString& aMsg) { fputs("Done loading ", stdout); fputs(mURL, stdout); diff --git a/mozilla/webshell/tests/viewer/nsViewer.h b/mozilla/webshell/tests/viewer/nsViewer.h index 590545a03d3..c30584ace3f 100644 --- a/mozilla/webshell/tests/viewer/nsViewer.h +++ b/mozilla/webshell/tests/viewer/nsViewer.h @@ -75,10 +75,10 @@ public: // nsIStreamListener NS_IMETHOD GetBindInfo(void); NS_IMETHOD OnProgress(PRInt32 aProgress, PRInt32 aProgressMax, - const char *aMsg); - NS_IMETHOD OnStartBinding(void); + const nsString& aMsg); + NS_IMETHOD OnStartBinding(const char *aContentType); NS_IMETHOD OnDataAvailable(nsIInputStream *pIStream, PRInt32 length); - NS_IMETHOD OnStopBinding(PRInt32 status, const char *msg); + NS_IMETHOD OnStopBinding(PRInt32 status, const nsString& aMsg); // nsILinkHandler NS_IMETHOD Init(nsIWebWidget* aWidget);