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 nsISerialEventTarget
;
9 interface nsIStreamListener
;
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.
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.
26 [scriptable
, uuid(400F5468
-97E7
-4d2b
-9C65
-A82AECC7AE82
)]
27 interface nsIInputStreamPump
: nsIRequest
30 * Initialize the input stream pump.
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.
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.
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
);
57 * asyncRead causes the input stream to be read in chunks and delivered
58 * asynchronously to the listener via OnDataAvailable.
61 * receives notifications.
62 * @param aListenerContext
63 * passed to listener methods.
65 void asyncRead
(in nsIStreamListener aListener
);