nsIInputStreamPump.idl (2869B)
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/. */ 4 5 #include "nsIRequest.idl" 6 7 interface nsIInputStream; 8 interface nsISerialEventTarget; 9 interface nsIStreamListener; 10 11 /** 12 * nsIInputStreamPump 13 * 14 * This interface provides a means to configure and use a input stream pump 15 * instance. The input stream pump will asynchronously read from an input 16 * stream, and push data to an nsIStreamListener instance. It utilizes the 17 * current thread's nsIEventTarget in order to make reading from the stream 18 * asynchronous. A different thread can be used if the pump also implements 19 * nsIThreadRetargetableRequest. 20 * 21 * If the given stream supports nsIAsyncInputStream, then the stream pump will 22 * call the stream's AsyncWait method to drive the stream listener. Otherwise, 23 * the stream will be read on a background thread utilizing the stream 24 * transport service. More details are provided below. 25 */ 26 [scriptable, uuid(400F5468-97E7-4d2b-9C65-A82AECC7AE82)] 27 interface nsIInputStreamPump : nsIRequest 28 { 29 /** 30 * Initialize the input stream pump. 31 * 32 * @param aStream 33 * contains the data to be read. if the input stream is non-blocking, 34 * then it will be QI'd to nsIAsyncInputStream. if the QI succeeds 35 * then the stream will be read directly. otherwise, it will be read 36 * on a background thread using the stream transport service. 37 * @param aSegmentSize 38 * if the stream transport service is used, then this parameter 39 * specifies the segment size for the stream transport's buffer. 40 * pass 0 to specify the default value. 41 * @param aSegmentCount 42 * if the stream transport service is used, then this parameter 43 * specifies the segment count for the stream transport's buffer. 44 * pass 0 to specify the default value. 45 * @param aCloseWhenDone 46 * if true, the input stream will be closed after it has been read. 47 * @param aMainThreadTarget 48 * a labeled main therad event target. 49 */ 50 void init(in nsIInputStream aStream, 51 in unsigned long aSegmentSize, 52 in unsigned long aSegmentCount, 53 in boolean aCloseWhenDone, 54 [optional] in nsISerialEventTarget aMainThreadTarget); 55 56 // Resets the inputstream and listener 57 void reset(); 58 59 /** 60 * asyncRead causes the input stream to be read in chunks and delivered 61 * asynchronously to the listener via OnDataAvailable. 62 * 63 * @param aListener 64 * receives notifications. 65 * @param aListenerContext 66 * passed to listener methods. 67 */ 68 void asyncRead(in nsIStreamListener aListener); 69 };