|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "nsIInputStream.idl" |
|
7 |
|
8 interface nsIOutputStream; |
|
9 interface nsIEventTarget; |
|
10 |
|
11 /** |
|
12 * A nsIInputStreamTee is a wrapper for an input stream, that when read |
|
13 * reads the specified amount of data from its |source| and copies that |
|
14 * data to its |sink|. |sink| must be a blocking output stream. |
|
15 */ |
|
16 [scriptable, uuid(90a9d790-3bca-421e-a73b-98f68e13c917)] |
|
17 interface nsIInputStreamTee : nsIInputStream |
|
18 { |
|
19 attribute nsIInputStream source; |
|
20 attribute nsIOutputStream sink; |
|
21 |
|
22 /** |
|
23 * If |eventTarget| is set, copying to sink is done asynchronously using |
|
24 * the event-target (e.g. a thread). If |eventTarget| is not set, copying |
|
25 * to sink happens synchronously while reading from the source. |
|
26 */ |
|
27 attribute nsIEventTarget eventTarget; |
|
28 }; |
|
29 |
|
30 %{C++ |
|
31 // factory methods |
|
32 extern nsresult |
|
33 NS_NewInputStreamTee(nsIInputStream **tee, // read from this input stream |
|
34 nsIInputStream *source, |
|
35 nsIOutputStream *sink); |
|
36 |
|
37 extern nsresult |
|
38 NS_NewInputStreamTeeAsync(nsIInputStream **tee, // read from this input stream |
|
39 nsIInputStream *source, |
|
40 nsIOutputStream *sink, |
|
41 nsIEventTarget *eventTarget); |
|
42 %} |