Back to index

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSITRANSPORT
NS_DECL_NSIOUTPUTSTREAM 
nsOutputStreamTransport (nsIOutputStream *sink, PRUint64 offset, PRUint64 limit, PRBool closeWhenDone)
virtual ~nsOutputStreamTransport ()
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.
void flush ()
 Flush the stream.
unsigned long write (in string aBuf, in unsigned long aCount)
 Write data into the stream.
unsigned long writeFrom (in nsIInputStream aFromStream, in unsigned long aCount)
 Writes data into the stream from an input stream.
unsigned long writeSegments (in nsReadSegmentFun aReader, in voidPtr aClosure, in unsigned long aCount)
 Low-level write 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< nsIAsyncOutputStreammPipeOut
nsCOMPtr< nsITransportEventSinkmEventSink
nsCOMPtr< nsIOutputStreammSink
nsUint64 mOffset
nsUint64 mLimit
PRPackedBool mCloseWhenDone
PRPackedBool mFirstTime
PRPackedBool mInProgress

Detailed Description

Definition at line 267 of file nsStreamTransportService.cpp.


Constructor & Destructor Documentation

NS_DECL_ISUPPORTS NS_DECL_NSITRANSPORT NS_DECL_NSIOUTPUTSTREAM nsOutputStreamTransport::nsOutputStreamTransport ( nsIOutputStream sink,
PRUint64  offset,
PRUint64  limit,
PRBool  closeWhenDone 
) [inline]

Definition at line 275 of file nsStreamTransportService.cpp.

        : mSink(sink)
        , mOffset(offset)
        , mLimit(limit)
        , mCloseWhenDone(closeWhenDone)
        , mFirstTime(PR_TRUE)
        , mInProgress(PR_FALSE)
    {
    }

Definition at line 288 of file nsStreamTransportService.cpp.

    {
    }

Member Function Documentation

void nsIOutputStream::close ( ) [inherited]

Close the stream.

Forces the output stream to flush any buffered data.

Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif unable to flush without blocking the calling thread (non-blocking mode only)
void nsITransport::close ( in nsresult  aReason) [inherited]

Close the transport and any open streams.

Parameters:
aReasonthe reason for closing the stream.
void nsIOutputStream::flush ( ) [inherited]

Flush the stream.

Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif unable to flush without blocking the calling thread (non-blocking mode only)
Returns:
true if stream is non-blocking

NOTE: writing to a blocking output stream will block the calling thread until all given data can be consumed by the stream.

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).
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.
unsigned long nsIOutputStream::write ( in string  aBuf,
in unsigned long  aCount 
) [inherited]

Write data into the stream.

Parameters:
aBufthe buffer containing the data to be written
aCountthe maximum number of bytes to be written
Returns:
number of bytes written (may be less than aCount)
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif writing to the output stream would block the calling thread (non-blocking mode only)
<other-error>on failure
unsigned long nsIOutputStream::writeFrom ( in nsIInputStream  aFromStream,
in unsigned long  aCount 
) [inherited]

Writes data into the stream from an input stream.

Parameters:
aFromStreamthe stream containing the data to be written
aCountthe maximum number of bytes to be written
Returns:
number of bytes written (may be less than aCount)
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif writing to the output stream would block the calling thread (non-blocking mode only)
<other-error>on failure

NOTE: This method is defined by this interface in order to allow the output stream to efficiently copy the data from the input stream into its internal buffer (if any). If this method was provided as an external facility, a separate char* buffer would need to be used in order to call the output stream's other Write method.

unsigned long nsIOutputStream::writeSegments ( in nsReadSegmentFun  aReader,
in voidPtr  aClosure,
in unsigned long  aCount 
) [inherited]

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

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

Parameters:
aReaderthe "provider" of the data to be written
aClosureopaque parameter passed to reader
aCountthe maximum number of bytes to be written
Returns:
number of bytes written (may be less than aCount)
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif writing to the output 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 output stream).


Member Data Documentation

Definition at line 301 of file nsStreamTransportService.cpp.

Definition at line 297 of file nsStreamTransportService.cpp.

Definition at line 302 of file nsStreamTransportService.cpp.

Definition at line 306 of file nsStreamTransportService.cpp.

Definition at line 300 of file nsStreamTransportService.cpp.

Definition at line 299 of file nsStreamTransportService.cpp.

Definition at line 293 of file nsStreamTransportService.cpp.

Definition at line 298 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: