michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsIRequest.idl" michael@0: michael@0: interface nsIInputStream; michael@0: interface nsIStreamListener; michael@0: michael@0: /** michael@0: * nsIInputStreamPump michael@0: * michael@0: * This interface provides a means to configure and use a input stream pump michael@0: * instance. The input stream pump will asynchronously read from an input michael@0: * stream, and push data to an nsIStreamListener instance. It utilizes the michael@0: * current thread's nsIEventTarget in order to make reading from the stream michael@0: * asynchronous. A different thread can be used if the pump also implements michael@0: * nsIThreadRetargetableRequest. michael@0: * michael@0: * If the given stream supports nsIAsyncInputStream, then the stream pump will michael@0: * call the stream's AsyncWait method to drive the stream listener. Otherwise, michael@0: * the stream will be read on a background thread utilizing the stream michael@0: * transport service. More details are provided below. michael@0: */ michael@0: [scriptable, uuid(400F5468-97E7-4d2b-9C65-A82AECC7AE82)] michael@0: interface nsIInputStreamPump : nsIRequest michael@0: { michael@0: /** michael@0: * Initialize the input stream pump. michael@0: * michael@0: * @param aStream michael@0: * contains the data to be read. if the input stream is non-blocking, michael@0: * then it will be QI'd to nsIAsyncInputStream. if the QI succeeds michael@0: * then the stream will be read directly. otherwise, it will be read michael@0: * on a background thread using the stream transport service. michael@0: * @param aStreamPos michael@0: * specifies the stream offset from which to start reading. the michael@0: * offset value is absolute. pass -1 to specify the current offset. michael@0: * NOTE: this parameter is ignored if the underlying stream does not michael@0: * implement nsISeekableStream. michael@0: * @param aStreamLen michael@0: * specifies how much data to read from the stream. pass -1 to read michael@0: * all data available in the stream. michael@0: * @param aSegmentSize michael@0: * if the stream transport service is used, then this parameter michael@0: * specifies the segment size for the stream transport's buffer. michael@0: * pass 0 to specify the default value. michael@0: * @param aSegmentCount michael@0: * if the stream transport service is used, then this parameter michael@0: * specifies the segment count for the stream transport's buffer. michael@0: * pass 0 to specify the default value. michael@0: * @param aCloseWhenDone michael@0: * if true, the input stream will be closed after it has been read. michael@0: */ michael@0: void init(in nsIInputStream aStream, michael@0: in long long aStreamPos, michael@0: in long long aStreamLen, michael@0: in unsigned long aSegmentSize, michael@0: in unsigned long aSegmentCount, michael@0: in boolean aCloseWhenDone); michael@0: michael@0: /** michael@0: * asyncRead causes the input stream to be read in chunks and delivered michael@0: * asynchronously to the listener via OnDataAvailable. michael@0: * michael@0: * @param aListener michael@0: * receives notifications. michael@0: * @param aListenerContext michael@0: * passed to listener methods. michael@0: */ michael@0: void asyncRead(in nsIStreamListener aListener, michael@0: in nsISupports aListenerContext); michael@0: };