(netwerk part of Bug 124029)

Implement nsBufferedOutputStream::WriteSegments and WriteFrom, and improve comments in other parts of necko
r=darin sr=bz
CVS: ----------------------------------------------------------------------
CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
CVS:
CVS: Committing in .
CVS:
CVS: Modified Files:
CVS: 	base/public/nsISocketTransport.idl
CVS: 	base/public/nsITransport.idl base/src/nsBufferedStreams.cpp
CVS: 	base/src/nsFileStreams.cpp protocol/http/src/nsHttpChannel.cpp
CVS: ----------------------------------------------------------------------
This commit is contained in:
cbiesinger%web.de 2003-09-14 11:55:05 +00:00
parent 9effbc9a16
commit c7fd59e0a0
5 changed files with 57 additions and 9 deletions

View File

@ -87,7 +87,13 @@ interface nsISocketTransport : nsITransport
boolean isAlive();
/**
* nsITransportEventSink status codes:
* nsITransportEventSink status codes.
*
* Although these look like XPCOM error codes and are passed in an nsresult
* variable, they are *not* error codes. Note that while they *do* overlap
* with existing error codes in Necko, these status codes are confined
* within a very limited context where no error codes may appear, so there
* is no ambiguity.
*/
const unsigned long STATUS_RESOLVING = 0x804b0003;
const unsigned long STATUS_CONNECTED_TO = 0x804b0004;

View File

@ -123,7 +123,8 @@ interface nsITransportEventSink : nsISupports
* the transport sending this status notification.
* @param aStatus
* the transport status (resolvable to a string using
* nsIErrorService).
* nsIErrorService). See nsISocketTransport for socket specific
* status codes and more comments.
* @param aProgress
* the amount of data either read or written depending on the value
* of the status code. this value is relative to aProgressMax.

View File

@ -565,18 +565,50 @@ nsBufferedOutputStream::Flush()
return NS_ERROR_FAILURE; // didn't flush all
}
static NS_METHOD
nsReadFromInputStream(nsIOutputStream* outStr,
void* closure,
char* toRawSegment,
PRUint32 offset,
PRUint32 count,
PRUint32 *readCount)
{
nsIInputStream* fromStream = (nsIInputStream*)closure;
return fromStream->Read(toRawSegment, count, readCount);
}
NS_IMETHODIMP
nsBufferedOutputStream::WriteFrom(nsIInputStream *inStr, PRUint32 count, PRUint32 *_retval)
{
NS_NOTREACHED("WriteFrom");
return NS_ERROR_NOT_IMPLEMENTED;
return WriteSegments(nsReadFromInputStream, inStr, count, _retval);
}
NS_IMETHODIMP
nsBufferedOutputStream::WriteSegments(nsReadSegmentFun reader, void * closure, PRUint32 count, PRUint32 *_retval)
{
NS_NOTREACHED("WriteSegments");
return NS_ERROR_NOT_IMPLEMENTED;
*_retval = 0;
nsresult rv;
while (count > 0) {
PRUint32 left = PR_MIN(count, mBufferSize - mCursor);
if (left == 0) {
rv = Flush();
if (NS_FAILED(rv))
return rv;
continue;
}
PRUint32 read = 0;
rv = reader(this, closure, mBuffer + mCursor, *_retval, left, &read);
if (NS_FAILED(rv)) // If we have written some data, return ok
return (*_retval > 0) ? NS_OK : rv;
mCursor += read;
*_retval += read;
count -= read;
mFillPoint = PR_MAX(mFillPoint, mCursor);
}
return NS_OK;
}
NS_IMETHODIMP

View File

@ -461,15 +461,21 @@ nsFileOutputStream::Flush(void)
NS_IMETHODIMP
nsFileOutputStream::WriteFrom(nsIInputStream *inStr, PRUint32 count, PRUint32 *_retval)
{
NS_NOTREACHED("WriteFrom");
NS_NOTREACHED("WriteFrom (see source comment)");
return NS_ERROR_NOT_IMPLEMENTED;
// File streams intentionally do not support this method.
// If you need something like this, then you should wrap
// the file stream using nsIBufferedOutputStream
}
NS_IMETHODIMP
nsFileOutputStream::WriteSegments(nsReadSegmentFun reader, void * closure, PRUint32 count, PRUint32 *_retval)
{
NS_NOTREACHED("WriteSegments");
NS_NOTREACHED("WriteSegments (see source comment)");
return NS_ERROR_NOT_IMPLEMENTED;
// File streams intentionally do not support this method.
// If you need something like this, then you should wrap
// the file stream using nsIBufferedOutputStream
}
NS_IMETHODIMP

View File

@ -2666,15 +2666,18 @@ nsHttpChannel::GetContentLength(PRInt32 *value)
*value = mResponseHead->ContentLength();
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::SetContentLength(PRInt32 value)
{
NS_NOTYETIMPLEMENTED("nsHttpChannel::SetContentLength");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsHttpChannel::Open(nsIInputStream **_retval)
{
NS_NOTYETIMPLEMENTED("nsHttpChannel::Open");
return NS_ERROR_NOT_IMPLEMENTED;
}