зеркало из https://github.com/mozilla/pjs.git
Replaced nsIProtocolConnection argument with nsISupports generic context.
This commit is contained in:
Родитель
eb79562943
Коммит
b105285634
|
@ -24,7 +24,6 @@
|
|||
|
||||
class nsIStreamObserver;
|
||||
class nsIStreamListener;
|
||||
class nsIProtocolConnection;
|
||||
class nsITransport;
|
||||
|
||||
#define NS_IFILETRANSPORTSERVICE_IID \
|
||||
|
@ -50,13 +49,13 @@ public:
|
|||
|
||||
|
||||
NS_IMETHOD AsyncRead(PLEventQueue* appEventQueue,
|
||||
nsIProtocolConnection* connection,
|
||||
nsISupports* context,
|
||||
nsIStreamListener* listener,
|
||||
const char* path,
|
||||
nsITransport* *result) = 0;
|
||||
|
||||
NS_IMETHOD AsyncWrite(PLEventQueue* appEventQueue,
|
||||
nsIProtocolConnection* connection,
|
||||
nsISupports* context,
|
||||
nsIStreamObserver* observer,
|
||||
const char* path,
|
||||
nsITransport* *result) = 0;
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
* @return The return value is currently ignored. In the future it may be
|
||||
* used to cancel the URL load..
|
||||
*/
|
||||
NS_IMETHOD OnStartBinding(nsIProtocolConnection* connection) = 0;
|
||||
NS_IMETHOD OnStartBinding(nsISupports* context) = 0;
|
||||
|
||||
/**
|
||||
* Notify the client that data is available in the input stream. This
|
||||
|
@ -60,7 +60,7 @@ public:
|
|||
* @param length The amount of data that was just pushed into the stream.
|
||||
* @return The return value is currently ignored.
|
||||
*/
|
||||
NS_IMETHOD OnDataAvailable(nsIProtocolConnection* connection,
|
||||
NS_IMETHOD OnDataAvailable(nsISupports* context,
|
||||
nsIInputStream *aIStream,
|
||||
PRUint32 aLength) = 0;
|
||||
|
||||
|
@ -75,7 +75,7 @@ public:
|
|||
* @param msg A text string describing the error.
|
||||
* @return The return value is currently ignored.
|
||||
*/
|
||||
NS_IMETHOD OnStopBinding(nsIProtocolConnection* connection,
|
||||
NS_IMETHOD OnStopBinding(nsISupports* context,
|
||||
nsresult aStatus,
|
||||
nsIString* aMsg) = 0;
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "nsFileTransport.h"
|
||||
#include "nsFileTransportService.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIProtocolConnection.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIFileStream.h"
|
||||
|
@ -32,7 +31,7 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|||
// nsFileTransport methods:
|
||||
|
||||
nsFileTransport::nsFileTransport()
|
||||
: mPath(nsnull), mListener(nsnull), mCanceled(PR_FALSE)
|
||||
: mContext(nsnull), mPath(nsnull), mListener(nsnull), mCanceled(PR_FALSE)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
@ -42,21 +41,22 @@ nsFileTransport::~nsFileTransport()
|
|||
if (mPath)
|
||||
delete mPath;
|
||||
NS_IF_RELEASE(mListener);
|
||||
NS_IF_RELEASE(mContext);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFileTransport::Init(const char* path,
|
||||
nsIStreamListener* listener,
|
||||
PLEventQueue* appEventQueue,
|
||||
nsIProtocolConnection* connection)
|
||||
nsISupports* context)
|
||||
{
|
||||
nsresult rv;
|
||||
mPath = nsCRT::strdup(path);
|
||||
if (mPath == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
mConnection = connection;
|
||||
NS_ADDREF(mConnection);
|
||||
mContext = context;
|
||||
NS_IF_ADDREF(mContext);
|
||||
|
||||
rv = NS_NewMarshalingStreamListener(appEventQueue, listener, &mListener);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -117,14 +117,16 @@ nsFileTransport::Run(void)
|
|||
{
|
||||
nsresult rv;
|
||||
nsISupports* fs;
|
||||
nsFileSpec spec(mPath);
|
||||
nsIInputStream* fileStr = nsnull;
|
||||
nsIByteBufferInputStream* bufStr = nsnull;
|
||||
nsFileSpec spec(mPath);
|
||||
|
||||
rv = mListener->OnStartBinding(mConnection); // always send the start notification
|
||||
rv = mListener->OnStartBinding(mContext); // always send the start notification
|
||||
if (NS_FAILED(rv)) goto done; // XXX should this abort the transfer?
|
||||
|
||||
rv = NS_NewTypicalInputFileStream(&fs, spec);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
rv = fs->QueryInterface(nsIInputStream::GetIID(), (void**)&fileStr);
|
||||
NS_RELEASE(fs);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
@ -135,14 +137,14 @@ nsFileTransport::Run(void)
|
|||
while (PR_TRUE) {
|
||||
PRUint32 amt;
|
||||
rv = bufStr->Fill(fileStr, &amt);
|
||||
if (rv == NS_BASE_STREAM_EOF || amt == 0) {
|
||||
if (rv == NS_BASE_STREAM_EOF) {
|
||||
rv = NS_OK;
|
||||
break;
|
||||
}
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
// and feed the buffer to the application via the byte buffer stream:
|
||||
rv = mListener->OnDataAvailable(mConnection, bufStr, amt); // XXX maybe amt should be bufStr->GetLength()
|
||||
rv = mListener->OnDataAvailable(mContext, bufStr, amt); // XXX maybe amt should be bufStr->GetLength()
|
||||
if (NS_FAILED(rv)) break;
|
||||
}
|
||||
|
||||
|
@ -151,7 +153,7 @@ nsFileTransport::Run(void)
|
|||
NS_IF_RELEASE(fileStr);
|
||||
|
||||
// XXX where do we get the error message?
|
||||
rv = mListener->OnStopBinding(mConnection, rv, nsnull);
|
||||
rv = mListener->OnStopBinding(mContext, rv, nsnull);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "plevent.h"
|
||||
|
||||
class nsFileTransportService;
|
||||
class nsIProtocolConnection;
|
||||
class nsIInputStream;
|
||||
class nsIString;
|
||||
|
||||
|
@ -50,13 +49,13 @@ public:
|
|||
nsresult Init(const char* path,
|
||||
nsIStreamListener* listener,
|
||||
PLEventQueue* appEventQueue,
|
||||
nsIProtocolConnection* connection);
|
||||
nsISupports* context);
|
||||
|
||||
protected:
|
||||
nsIProtocolConnection* mConnection;
|
||||
char* mPath;
|
||||
nsIStreamListener* mListener;
|
||||
PRBool mCanceled;
|
||||
nsISupports* mContext;
|
||||
char* mPath;
|
||||
nsIStreamListener* mListener;
|
||||
PRBool mCanceled;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ NS_IMPL_ISUPPORTS(nsFileTransportService, nsIFileTransportService::GetIID());
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsFileTransportService::AsyncRead(PLEventQueue* appEventQueue,
|
||||
nsIProtocolConnection* connection,
|
||||
nsISupports* context,
|
||||
nsIStreamListener* listener,
|
||||
const char* path,
|
||||
nsITransport* *result)
|
||||
|
@ -59,7 +59,7 @@ nsFileTransportService::AsyncRead(PLEventQueue* appEventQueue,
|
|||
if (trans == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv = trans->Init(path, listener, appEventQueue, connection);
|
||||
nsresult rv = trans->Init(path, listener, appEventQueue, context);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete trans;
|
||||
return rv;
|
||||
|
@ -78,7 +78,7 @@ nsFileTransportService::AsyncRead(PLEventQueue* appEventQueue,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsFileTransportService::AsyncWrite(PLEventQueue* appEventQueue,
|
||||
nsIProtocolConnection* connection,
|
||||
nsISupports* context,
|
||||
nsIStreamObserver* observer,
|
||||
const char* path,
|
||||
nsITransport* *result)
|
||||
|
|
|
@ -36,12 +36,12 @@ public:
|
|||
|
||||
// nsIFileTransportService methods:
|
||||
NS_IMETHOD AsyncRead(PLEventQueue* appEventQueue,
|
||||
nsIProtocolConnection* connection,
|
||||
nsISupports* context,
|
||||
nsIStreamListener* listener,
|
||||
const char* path,
|
||||
nsITransport* *result);
|
||||
NS_IMETHOD AsyncWrite(PLEventQueue* appEventQueue,
|
||||
nsIProtocolConnection* connection,
|
||||
nsISupports* context,
|
||||
nsIStreamObserver* observer,
|
||||
const char* path,
|
||||
nsITransport* *result);
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
*/
|
||||
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIProtocolConnection.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIString.h"
|
||||
#include "nsCRT.h"
|
||||
|
@ -28,11 +27,11 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIStreamListener methods:
|
||||
NS_IMETHOD OnStartBinding(nsIProtocolConnection* connection);
|
||||
NS_IMETHOD OnDataAvailable(nsIProtocolConnection* connection,
|
||||
NS_IMETHOD OnStartBinding(nsISupports* context);
|
||||
NS_IMETHOD OnDataAvailable(nsISupports* context,
|
||||
nsIInputStream *aIStream,
|
||||
PRUint32 aLength);
|
||||
NS_IMETHOD OnStopBinding(nsIProtocolConnection* connection,
|
||||
NS_IMETHOD OnStopBinding(nsISupports* context,
|
||||
nsresult aStatus,
|
||||
nsIString* aMsg);
|
||||
|
||||
|
@ -60,7 +59,7 @@ class nsStreamListenerEvent : public PLEvent
|
|||
{
|
||||
public:
|
||||
nsStreamListenerEvent(nsMarshalingStreamListener* listener,
|
||||
nsIProtocolConnection* connection);
|
||||
nsISupports* context);
|
||||
virtual ~nsStreamListenerEvent();
|
||||
|
||||
nsresult Fire(PLEventQueue* aEventQ);
|
||||
|
@ -72,23 +71,23 @@ protected:
|
|||
static void PR_CALLBACK DestroyPLEvent(PLEvent* aEvent);
|
||||
|
||||
nsMarshalingStreamListener* mListener;
|
||||
nsIProtocolConnection* mConnection;
|
||||
nsISupports* mContext;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsStreamListenerEvent::nsStreamListenerEvent(nsMarshalingStreamListener* listener,
|
||||
nsIProtocolConnection* connection)
|
||||
: mListener(listener), mConnection(connection)
|
||||
nsISupports* context)
|
||||
: mListener(listener), mContext(context)
|
||||
{
|
||||
NS_ADDREF(mListener);
|
||||
NS_ADDREF(mConnection);
|
||||
NS_IF_ADDREF(mContext);
|
||||
}
|
||||
|
||||
nsStreamListenerEvent::~nsStreamListenerEvent()
|
||||
{
|
||||
NS_RELEASE(mListener);
|
||||
NS_RELEASE(mConnection);
|
||||
NS_IF_RELEASE(mContext);
|
||||
}
|
||||
|
||||
void PR_CALLBACK nsStreamListenerEvent::HandlePLEvent(PLEvent* aEvent)
|
||||
|
@ -137,8 +136,8 @@ class nsOnStartBindingEvent : public nsStreamListenerEvent
|
|||
{
|
||||
public:
|
||||
nsOnStartBindingEvent(nsMarshalingStreamListener* listener,
|
||||
nsIProtocolConnection* connection)
|
||||
: nsStreamListenerEvent(listener, connection), mContentType(nsnull) {}
|
||||
nsISupports* context)
|
||||
: nsStreamListenerEvent(listener, context), mContentType(nsnull) {}
|
||||
virtual ~nsOnStartBindingEvent();
|
||||
|
||||
NS_IMETHOD HandleEvent();
|
||||
|
@ -156,17 +155,17 @@ nsOnStartBindingEvent::~nsOnStartBindingEvent()
|
|||
NS_IMETHODIMP
|
||||
nsOnStartBindingEvent::HandleEvent()
|
||||
{
|
||||
return mListener->GetReceiver()->OnStartBinding(mConnection);
|
||||
return mListener->GetReceiver()->OnStartBinding(mContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMarshalingStreamListener::OnStartBinding(nsIProtocolConnection* connection)
|
||||
nsMarshalingStreamListener::OnStartBinding(nsISupports* context)
|
||||
{
|
||||
nsresult rv = GetStatus();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsOnStartBindingEvent* event =
|
||||
new nsOnStartBindingEvent(this, connection);
|
||||
new nsOnStartBindingEvent(this, context);
|
||||
if (event == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -185,8 +184,8 @@ class nsOnDataAvailableEvent : public nsStreamListenerEvent
|
|||
{
|
||||
public:
|
||||
nsOnDataAvailableEvent(nsMarshalingStreamListener* listener,
|
||||
nsIProtocolConnection* connection)
|
||||
: nsStreamListenerEvent(listener, connection),
|
||||
nsISupports* context)
|
||||
: nsStreamListenerEvent(listener, context),
|
||||
mIStream(nsnull), mLength(0) {}
|
||||
virtual ~nsOnDataAvailableEvent();
|
||||
|
||||
|
@ -215,11 +214,11 @@ nsOnDataAvailableEvent::Init(nsIInputStream* aIStream, PRUint32 aLength)
|
|||
NS_IMETHODIMP
|
||||
nsOnDataAvailableEvent::HandleEvent()
|
||||
{
|
||||
return mListener->GetReceiver()->OnDataAvailable(mConnection, mIStream, mLength);
|
||||
return mListener->GetReceiver()->OnDataAvailable(mContext, mIStream, mLength);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMarshalingStreamListener::OnDataAvailable(nsIProtocolConnection* connection,
|
||||
nsMarshalingStreamListener::OnDataAvailable(nsISupports* context,
|
||||
nsIInputStream *aIStream,
|
||||
PRUint32 aLength)
|
||||
{
|
||||
|
@ -227,7 +226,7 @@ nsMarshalingStreamListener::OnDataAvailable(nsIProtocolConnection* connection,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsOnDataAvailableEvent* event =
|
||||
new nsOnDataAvailableEvent(this, connection);
|
||||
new nsOnDataAvailableEvent(this, context);
|
||||
if (event == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -248,8 +247,8 @@ class nsOnStopBindingEvent : public nsStreamListenerEvent
|
|||
{
|
||||
public:
|
||||
nsOnStopBindingEvent(nsMarshalingStreamListener* listener,
|
||||
nsIProtocolConnection* connection)
|
||||
: nsStreamListenerEvent(listener, connection),
|
||||
nsISupports* context)
|
||||
: nsStreamListenerEvent(listener, context),
|
||||
mStatus(NS_OK), mMessage(nsnull) {}
|
||||
virtual ~nsOnStopBindingEvent();
|
||||
|
||||
|
@ -277,11 +276,11 @@ nsOnStopBindingEvent::Init(nsresult status, nsIString* aMsg)
|
|||
NS_IMETHODIMP
|
||||
nsOnStopBindingEvent::HandleEvent()
|
||||
{
|
||||
return mListener->GetReceiver()->OnStopBinding(mConnection, mStatus, mMessage);
|
||||
return mListener->GetReceiver()->OnStopBinding(mContext, mStatus, mMessage);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMarshalingStreamListener::OnStopBinding(nsIProtocolConnection* connection,
|
||||
nsMarshalingStreamListener::OnStopBinding(nsISupports* context,
|
||||
nsresult aStatus,
|
||||
nsIString* aMsg)
|
||||
{
|
||||
|
@ -289,7 +288,7 @@ nsMarshalingStreamListener::OnStopBinding(nsIProtocolConnection* connection,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsOnStopBindingEvent* event =
|
||||
new nsOnStopBindingEvent(this, connection);
|
||||
new nsOnStopBindingEvent(this, context);
|
||||
if (event == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче