1 /* -*- Mode: IDL; 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/. */
6 #include
"nsISupports.idl"
9 interface nsIInputStream
;
10 interface nsIStreamListener
;
13 #define NS_ISTREAMCONVERTER_KEY
"@mozilla.org/streamconv;1"
17 * The nsIStreamConverterService is a higher level stream converter factory
18 * responsible for locating and creating stream converters
19 * (nsIStreamConverter).
21 * This service retrieves an interface that can convert data from a particular
22 * MIME type, to a particular MIME type. It is responsible for any intermediary
23 * conversion required in order to get from X to Z, assuming direct conversion
27 * @see nsIStreamConverter
29 [scriptable
, uuid(f2b1ab53
-f0bd
-4adb
-9365-e59b1701a258
)]
30 interface nsIStreamConverterService
: nsISupports
{
32 * Tests whether conversion between the two specified types is possible.
33 * This is cheaper than calling convert()/asyncConvertData(); it is not
34 * necessary to call this function before calling one of those, though.
36 boolean canConvert
(in string aFromType
, in string aToType
);
39 * Returns the content type that will be returned from a converter
40 * created with aFromType and * /*.
41 * Can fail if no converters support this conversion, or if the
42 * output type isn't known in advance.
44 ACString convertedType
(in ACString aFromType
, in nsIChannel aChannel
);
47 * <b>SYNCHRONOUS VERSION</b>
48 * Converts a stream of one type, to a stream of another type.
50 * Use this method when you have a stream you want to convert.
52 * @param aFromStream The stream representing the original/raw data.
53 * @param aFromType The MIME type of aFromStream.
54 * @param aToType The MIME type of the returned stream.
55 * @param aContext Either an opaque context, or a converter specific
56 * context (implementation specific).
57 * @return The converted stream. NOTE: The returned stream
58 * may not already be converted. An efficient stream
59 * converter implementation will convert data on
60 * demand rather than buffering the converted data
63 nsIInputStream convert
(in nsIInputStream aFromStream
,
66 in nsISupports aContext
);
69 * <b>ASYNCHRONOUS VERSION</b>
70 * Retrieves a nsIStreamListener that receives the original/raw data via its
71 * nsIStreamListener::OnDataAvailable() callback, then converts and pushes
72 * the data to aListener.
74 * Use this method when you want to proxy (and convert) nsIStreamListener
75 * callbacks asynchronously.
77 * @param aFromType The MIME type of the original/raw data.
78 * @param aToType The MIME type of the converted data.
79 * @param aListener The listener that receives the converted data.
80 * @param aCtxt Either an opaque context, or a converter specific
81 * context (implementation specific).
82 * @return A nsIStreamListener that receives data via its
83 * OnDataAvailable() method.
85 nsIStreamListener asyncConvertData
(in string aFromType
,
87 in nsIStreamListener aListener
,
88 in nsISupports aContext
);