зеркало из https://github.com/mozilla/gecko-dev.git
Minor changes to nsIStreamListener interface... OnStartBinding(...) now passes out the stream content-type. User visible strings are now nsString arguments (for subsequent i18n)
This commit is contained in:
Родитель
b40933b15c
Коммит
53ca67cf12
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -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.<BR>
|
||||
*/
|
||||
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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче