Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Attributes
nsInputStreamTransport Class Reference
Inheritance diagram for nsInputStreamTransport:
Inheritance graph
[legend]
Collaboration diagram for nsInputStreamTransport:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSITRANSPORT
NS_DECL_NSIINPUTSTREAM 
nsInputStreamTransport (nsIInputStream *source, PRUint64 offset, PRUint64 limit, PRBool closeWhenDone)
virtual ~nsInputStreamTransport ()
nsIInputStream openInputStream (in unsigned long aFlags, in unsigned long aSegmentSize, in unsigned long aSegmentCount)
 Open an input stream on this transport.
nsIOutputStream openOutputStream (in unsigned long aFlags, in unsigned long aSegmentSize, in unsigned long aSegmentCount)
 Open an output stream on this transport.
void close (in nsresult aReason)
 Close the transport and any open streams.
void setEventSink (in nsITransportEventSink aSink, in nsIEventTarget aEventTarget)
 Set the transport event sink.
void close ()
 Close the stream.
unsigned long available ()
unsigned long read (in charPtr aBuf, in unsigned long aCount)
 Read data from the stream.
unsigned long readSegments (in nsWriteSegmentFun aWriter, in voidPtr aClosure, in unsigned long aCount)
 Low-level read method that has access to the stream's underlying buffer.
boolean isNonBlocking ()

Public Attributes

const unsigned long OPEN_BLOCKING = 1<<0
 Open flags.
const unsigned long OPEN_UNBUFFERED = 1<<1
const unsigned long STATUS_READING = 0x804b0008
 Generic nsITransportEventSink status codes.
const unsigned long STATUS_WRITING = 0x804b0009

Private Attributes

nsCOMPtr< nsIAsyncInputStreammPipeIn
nsCOMPtr< nsITransportEventSinkmEventSink
nsCOMPtr< nsIInputStreammSource
nsUint64 mOffset
nsUint64 mLimit
PRPackedBool mCloseWhenDone
PRPackedBool mFirstTime
PRPackedBool mInProgress

Detailed Description

Definition at line 65 of file nsStreamTransportService.cpp.


Constructor & Destructor Documentation

NS_DECL_ISUPPORTS NS_DECL_NSITRANSPORT NS_DECL_NSIINPUTSTREAM nsInputStreamTransport::nsInputStreamTransport ( nsIInputStream source,
PRUint64  offset,
PRUint64  limit,
PRBool  closeWhenDone 
) [inline]

Definition at line 73 of file nsStreamTransportService.cpp.

        : mSource(source)
        , mOffset(offset)
        , mLimit(limit)
        , mCloseWhenDone(closeWhenDone)
        , mFirstTime(PR_TRUE)
        , mInProgress(PR_FALSE)
    {
    }
virtual nsInputStreamTransport::~nsInputStreamTransport ( ) [inline, virtual]

Definition at line 86 of file nsStreamTransportService.cpp.

    {
    }

Member Function Documentation

unsigned long nsIInputStream::available ( ) [inherited]
Returns:
number of bytes currently available in the stream
void nsIInputStream::close ( ) [inherited]

Close the stream.

void nsITransport::close ( in nsresult  aReason) [inherited]

Close the transport and any open streams.

Parameters:
aReasonthe reason for closing the stream.
Returns:
true if stream is non-blocking
nsIInputStream nsITransport::openInputStream ( in unsigned long  aFlags,
in unsigned long  aSegmentSize,
in unsigned long  aSegmentCount 
) [inherited]

Open an input stream on this transport.

Flags have the following meaning:

OPEN_BLOCKING If specified, then the resulting stream will have blocking stream semantics. This means that if the stream has no data and is not closed, then reading from it will block the calling thread until at least one byte is available or until the stream is closed. If this flag is NOT specified, then the stream has non-blocking stream semantics. This means that if the stream has no data and is not closed, then reading from it returns NS_BASE_STREAM_WOULD_BLOCK. In addition, in non-blocking mode, the stream is guaranteed to support nsIAsyncInputStream. This interface allows the consumer of the stream to be notified when the stream can again be read.

OPEN_UNBUFFERED If specified, the resulting stream may not support ReadSegments. ReadSegments is only gauranteed to be implemented when this flag is NOT specified.

Parameters:
aFlagsoptional transport specific flags.
aSegmentSizeif OPEN_UNBUFFERED is not set, then this parameter specifies the size of each buffer segment (pass 0 to use default value).
aSegmentCountif OPEN_UNBUFFERED is not set, then this parameter specifies the maximum number of buffer segments (pass 0 to use default value).
nsIOutputStream nsITransport::openOutputStream ( in unsigned long  aFlags,
in unsigned long  aSegmentSize,
in unsigned long  aSegmentCount 
) [inherited]

Open an output stream on this transport.

Flags have the following meaning:

OPEN_BLOCKING If specified, then the resulting stream will have blocking stream semantics. This means that if the stream is full and is not closed, then writing to it will block the calling thread until ALL of the data can be written or until the stream is closed. If this flag is NOT specified, then the stream has non-blocking stream semantics. This means that if the stream is full and is not closed, then writing to it returns NS_BASE_STREAM_WOULD_BLOCK. In addition, in non- blocking mode, the stream is guaranteed to support nsIAsyncOutputStream. This interface allows the consumer of the stream to be notified when the stream can again accept more data.

OPEN_UNBUFFERED If specified, the resulting stream may not support WriteSegments and WriteFrom. WriteSegments and WriteFrom are only gauranteed to be implemented when this flag is NOT specified.

Parameters:
aFlagsoptional transport specific flags.
aSegmentSizeif OPEN_UNBUFFERED is not set, then this parameter specifies the size of each buffer segment (pass 0 to use default value).
aSegmentCountif OPEN_UNBUFFERED is not set, then this parameter specifies the maximum number of buffer segments (pass 0 to use default value).
unsigned long nsIInputStream::read ( in charPtr  aBuf,
in unsigned long  aCount 
) [inherited]

Read data from the stream.

Parameters:
aBufthe buffer into which the data is to be read
aCountthe maximum number of bytes to be read
Returns:
number of bytes read (may be less than aCount).
0 if reached end of file
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif reading from the input stream would block the calling thread (non-blocking mode only)
<other-error>on failure
unsigned long nsIInputStream::readSegments ( in nsWriteSegmentFun  aWriter,
in voidPtr  aClosure,
in unsigned long  aCount 
) [inherited]

Low-level read method that has access to the stream's underlying buffer.

The writer function may be called multiple times for segmented buffers. ReadSegments is expected to keep calling the writer until either there is nothing left to read or the writer returns an error. ReadSegments should not call the writer with zero bytes to consume.

Parameters:
aWriterthe "consumer" of the data to be read
aClosureopaque parameter passed to writer
aCountthe maximum number of bytes to be read
Returns:
number of bytes read (may be less than aCount)
0 if reached end of file (or if aWriter refused to consume data)
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif reading from the input stream would block the calling thread (non-blocking mode only)
<other-error>on failure

NOTE: this function may be unimplemented if a stream has no underlying buffer (e.g., socket input stream).

void nsITransport::setEventSink ( in nsITransportEventSink  aSink,
in nsIEventTarget  aEventTarget 
) [inherited]

Set the transport event sink.

Parameters:
aSinkreceives transport layer notifications
aEventTargetindicates the event target to which the notifications should be delivered. if NULL, then the notifications may occur on any thread.

Member Data Documentation

Definition at line 99 of file nsStreamTransportService.cpp.

Definition at line 95 of file nsStreamTransportService.cpp.

Definition at line 100 of file nsStreamTransportService.cpp.

Definition at line 104 of file nsStreamTransportService.cpp.

Definition at line 98 of file nsStreamTransportService.cpp.

Definition at line 97 of file nsStreamTransportService.cpp.

Definition at line 91 of file nsStreamTransportService.cpp.

Definition at line 96 of file nsStreamTransportService.cpp.

const unsigned long nsITransport::OPEN_BLOCKING = 1<<0 [inherited]

Open flags.

Definition at line 66 of file nsITransport.idl.

const unsigned long nsITransport::OPEN_UNBUFFERED = 1<<1 [inherited]

Definition at line 67 of file nsITransport.idl.

const unsigned long nsITransport::STATUS_READING = 0x804b0008 [inherited]

Generic nsITransportEventSink status codes.

nsITransport implementations may override these status codes with their own more specific status codes (e.g., see nsISocketTransport).

Definition at line 165 of file nsITransport.idl.

const unsigned long nsITransport::STATUS_WRITING = 0x804b0009 [inherited]

Definition at line 166 of file nsITransport.idl.


The documentation for this class was generated from the following file: