netwerk/base/public/nsIInputStreamPump.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/base/public/nsIInputStreamPump.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#include "nsIRequest.idl"
     1.9 +
    1.10 +interface nsIInputStream;
    1.11 +interface nsIStreamListener;
    1.12 +
    1.13 +/**
    1.14 + * nsIInputStreamPump
    1.15 + *
    1.16 + * This interface provides a means to configure and use a input stream pump
    1.17 + * instance.  The input stream pump will asynchronously read from an input
    1.18 + * stream, and push data to an nsIStreamListener instance.  It utilizes the
    1.19 + * current thread's nsIEventTarget in order to make reading from the stream
    1.20 + * asynchronous. A different thread can be used if the pump also implements
    1.21 + * nsIThreadRetargetableRequest.
    1.22 + *
    1.23 + * If the given stream supports nsIAsyncInputStream, then the stream pump will
    1.24 + * call the stream's AsyncWait method to drive the stream listener.  Otherwise,
    1.25 + * the stream will be read on a background thread utilizing the stream
    1.26 + * transport service.  More details are provided below.
    1.27 + */
    1.28 +[scriptable, uuid(400F5468-97E7-4d2b-9C65-A82AECC7AE82)]
    1.29 +interface nsIInputStreamPump : nsIRequest
    1.30 +{
    1.31 +    /**
    1.32 +     * Initialize the input stream pump.
    1.33 +     *
    1.34 +     * @param aStream
    1.35 +     *        contains the data to be read.  if the input stream is non-blocking,
    1.36 +     *        then it will be QI'd to nsIAsyncInputStream.  if the QI succeeds
    1.37 +     *        then the stream will be read directly.  otherwise, it will be read
    1.38 +     *        on a background thread using the stream transport service.
    1.39 +     * @param aStreamPos
    1.40 +     *        specifies the stream offset from which to start reading.  the
    1.41 +     *        offset value is absolute.  pass -1 to specify the current offset.
    1.42 +     *        NOTE: this parameter is ignored if the underlying stream does not
    1.43 +     *        implement nsISeekableStream.
    1.44 +     * @param aStreamLen
    1.45 +     *        specifies how much data to read from the stream.  pass -1 to read
    1.46 +     *        all data available in the stream.
    1.47 +     * @param aSegmentSize
    1.48 +     *        if the stream transport service is used, then this parameter
    1.49 +     *        specifies the segment size for the stream transport's buffer.
    1.50 +     *        pass 0 to specify the default value.
    1.51 +     * @param aSegmentCount
    1.52 +     *        if the stream transport service is used, then this parameter
    1.53 +     *        specifies the segment count for the stream transport's buffer.
    1.54 +     *        pass 0 to specify the default value.
    1.55 +     * @param aCloseWhenDone
    1.56 +     *        if true, the input stream will be closed after it has been read.
    1.57 +     */
    1.58 +    void init(in nsIInputStream aStream,
    1.59 +              in long long      aStreamPos,
    1.60 +              in long long      aStreamLen,
    1.61 +              in unsigned long  aSegmentSize,
    1.62 +              in unsigned long  aSegmentCount,
    1.63 +              in boolean        aCloseWhenDone);
    1.64 +
    1.65 +    /**
    1.66 +     * asyncRead causes the input stream to be read in chunks and delivered
    1.67 +     * asynchronously to the listener via OnDataAvailable.
    1.68 +     *
    1.69 +     * @param aListener
    1.70 +     *        receives notifications.
    1.71 +     * @param aListenerContext
    1.72 +     *        passed to listener methods.
    1.73 +     */
    1.74 +    void asyncRead(in nsIStreamListener aListener,
    1.75 +                   in nsISupports       aListenerContext);
    1.76 +};

mercurial