зеркало из https://github.com/mozilla/pjs.git
(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:
Родитель
bad255111b
Коммит
d79ad7e944
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -564,19 +564,51 @@ nsBufferedOutputStream::Flush()
|
|||
mFillPoint = mCursor = rem;
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче