netwerk/base/public/nsIInputStreamPump.idl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #include "nsIRequest.idl"
     7 interface nsIInputStream;
     8 interface nsIStreamListener;
    10 /**
    11  * nsIInputStreamPump
    12  *
    13  * This interface provides a means to configure and use a input stream pump
    14  * instance.  The input stream pump will asynchronously read from an input
    15  * stream, and push data to an nsIStreamListener instance.  It utilizes the
    16  * current thread's nsIEventTarget in order to make reading from the stream
    17  * asynchronous. A different thread can be used if the pump also implements
    18  * nsIThreadRetargetableRequest.
    19  *
    20  * If the given stream supports nsIAsyncInputStream, then the stream pump will
    21  * call the stream's AsyncWait method to drive the stream listener.  Otherwise,
    22  * the stream will be read on a background thread utilizing the stream
    23  * transport service.  More details are provided below.
    24  */
    25 [scriptable, uuid(400F5468-97E7-4d2b-9C65-A82AECC7AE82)]
    26 interface nsIInputStreamPump : nsIRequest
    27 {
    28     /**
    29      * Initialize the input stream pump.
    30      *
    31      * @param aStream
    32      *        contains the data to be read.  if the input stream is non-blocking,
    33      *        then it will be QI'd to nsIAsyncInputStream.  if the QI succeeds
    34      *        then the stream will be read directly.  otherwise, it will be read
    35      *        on a background thread using the stream transport service.
    36      * @param aStreamPos
    37      *        specifies the stream offset from which to start reading.  the
    38      *        offset value is absolute.  pass -1 to specify the current offset.
    39      *        NOTE: this parameter is ignored if the underlying stream does not
    40      *        implement nsISeekableStream.
    41      * @param aStreamLen
    42      *        specifies how much data to read from the stream.  pass -1 to read
    43      *        all data available in the stream.
    44      * @param aSegmentSize
    45      *        if the stream transport service is used, then this parameter
    46      *        specifies the segment size for the stream transport's buffer.
    47      *        pass 0 to specify the default value.
    48      * @param aSegmentCount
    49      *        if the stream transport service is used, then this parameter
    50      *        specifies the segment count for the stream transport's buffer.
    51      *        pass 0 to specify the default value.
    52      * @param aCloseWhenDone
    53      *        if true, the input stream will be closed after it has been read.
    54      */
    55     void init(in nsIInputStream aStream,
    56               in long long      aStreamPos,
    57               in long long      aStreamLen,
    58               in unsigned long  aSegmentSize,
    59               in unsigned long  aSegmentCount,
    60               in boolean        aCloseWhenDone);
    62     /**
    63      * asyncRead causes the input stream to be read in chunks and delivered
    64      * asynchronously to the listener via OnDataAvailable.
    65      *
    66      * @param aListener
    67      *        receives notifications.
    68      * @param aListenerContext
    69      *        passed to listener methods.
    70      */
    71     void asyncRead(in nsIStreamListener aListener,
    72                    in nsISupports       aListenerContext);
    73 };

mercurial