netwerk/streamconv/public/nsIStreamConverterService.idl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "nsISupports.idl"
michael@0 7
michael@0 8 interface nsIInputStream;
michael@0 9 interface nsIStreamListener;
michael@0 10
michael@0 11 %{C++
michael@0 12 #define NS_ISTREAMCONVERTER_KEY "@mozilla.org/streamconv;1"
michael@0 13 %}
michael@0 14
michael@0 15 /**
michael@0 16 * The nsIStreamConverterService is a higher level stream converter factory
michael@0 17 * responsible for locating and creating stream converters
michael@0 18 * (nsIStreamConverter).
michael@0 19 *
michael@0 20 * This service retrieves an interface that can convert data from a particular
michael@0 21 * MIME type, to a particular MIME type. It is responsible for any intermediary
michael@0 22 * conversion required in order to get from X to Z, assuming direct conversion
michael@0 23 * is not possible.
michael@0 24 *
michael@0 25 * @author Jud Valeski
michael@0 26 * @see nsIStreamConverter
michael@0 27 */
michael@0 28 [scriptable, uuid(f2b1ab53-f0bd-4adb-9365-e59b1701a258)]
michael@0 29 interface nsIStreamConverterService : nsISupports {
michael@0 30 /**
michael@0 31 * Tests whether conversion between the two specified types is possible.
michael@0 32 * This is cheaper than calling convert()/asyncConvertData(); it is not
michael@0 33 * necessary to call this function before calling one of those, though.
michael@0 34 */
michael@0 35 boolean canConvert(in string aFromType, in string aToType);
michael@0 36
michael@0 37 /**
michael@0 38 * <b>SYNCHRONOUS VERSION</b>
michael@0 39 * Converts a stream of one type, to a stream of another type.
michael@0 40 *
michael@0 41 * Use this method when you have a stream you want to convert.
michael@0 42 *
michael@0 43 * @param aFromStream The stream representing the original/raw data.
michael@0 44 * @param aFromType The MIME type of aFromStream.
michael@0 45 * @param aToType The MIME type of the returned stream.
michael@0 46 * @param aContext Either an opaque context, or a converter specific
michael@0 47 * context (implementation specific).
michael@0 48 * @return The converted stream. NOTE: The returned stream
michael@0 49 * may not already be converted. An efficient stream
michael@0 50 * converter implementation will convert data on
michael@0 51 * demand rather than buffering the converted data
michael@0 52 * until it is used.
michael@0 53 */
michael@0 54 nsIInputStream convert(in nsIInputStream aFromStream,
michael@0 55 in string aFromType,
michael@0 56 in string aToType,
michael@0 57 in nsISupports aContext);
michael@0 58
michael@0 59 /**
michael@0 60 * <b>ASYNCHRONOUS VERSION</b>
michael@0 61 * Retrieves a nsIStreamListener that receives the original/raw data via its
michael@0 62 * nsIStreamListener::OnDataAvailable() callback, then converts and pushes
michael@0 63 * the data to aListener.
michael@0 64 *
michael@0 65 * Use this method when you want to proxy (and convert) nsIStreamListener
michael@0 66 * callbacks asynchronously.
michael@0 67 *
michael@0 68 * @param aFromType The MIME type of the original/raw data.
michael@0 69 * @param aToType The MIME type of the converted data.
michael@0 70 * @param aListener The listener that receives the converted data.
michael@0 71 * @param aCtxt Either an opaque context, or a converter specific
michael@0 72 * context (implementation specific).
michael@0 73 * @return A nsIStreamListener that receives data via its
michael@0 74 * OnDataAvailable() method.
michael@0 75 */
michael@0 76 nsIStreamListener asyncConvertData(in string aFromType,
michael@0 77 in string aToType,
michael@0 78 in nsIStreamListener aListener,
michael@0 79 in nsISupports aContext);
michael@0 80 };

mercurial