netwerk/streamconv/public/nsIStreamConverter.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 "nsIStreamListener.idl"
michael@0 7
michael@0 8 interface nsIInputStream;
michael@0 9
michael@0 10 /**
michael@0 11 * nsIStreamConverter provides an interface to implement when you have code
michael@0 12 * that converts data from one type to another.
michael@0 13 *
michael@0 14 * Suppose you had code that converted plain text into HTML. You could implement
michael@0 15 * this interface to allow everyone else to use your conversion logic using a
michael@0 16 * standard api.
michael@0 17 * <p>
michael@0 18 * <b>STREAM CONVERTER USERS</b>
michael@0 19 *
michael@0 20 * There are currently two ways to use a stream converter:
michael@0 21 * <ol>
michael@0 22 * <li> <b>SYNCHRONOUS</b> Stream to Stream
michael@0 23 * You can supply the service with a stream of type X
michael@0 24 * and it will convert it to your desired output type and return
michael@0 25 * a converted (blocking) stream to you.</li>
michael@0 26 *
michael@0 27 * <li> <b>ASYNCHRONOUS</b> nsIStreamListener to nsIStreamListener
michael@0 28 * You can supply data directly to the converter by calling it's
michael@0 29 * nsIStreamListener::OnDataAvailable() method. It will then
michael@0 30 * convert that data from type X to your desired output type and
michael@0 31 * return converted data to you via the nsIStreamListener you passed
michael@0 32 * in by calling its OnDataAvailable() method.</li>
michael@0 33 * </ol>
michael@0 34 * <p>
michael@0 35 *
michael@0 36 * <b>STREAM CONVERTER SUPPLIERS</b>
michael@0 37 *
michael@0 38 * Registering a stream converter:
michael@0 39 * Stream converter registration is a two step process. First of all the stream
michael@0 40 * converter implementation must register itself with the component manager using
michael@0 41 * a contractid in the format below. Second, the stream converter must add the contractid
michael@0 42 * to the registry.
michael@0 43 *
michael@0 44 * Stream converter contractid format (the stream converter root key is defined in this
michael@0 45 * file):
michael@0 46 *
michael@0 47 * <pre>@mozilla.org/streamconv;1?from=FROM_MIME_TYPE&to=TO_MIME_TYPE</pre>
michael@0 48 *
michael@0 49 * @author Jud Valeski
michael@0 50 * @see nsIStreamConverterService
michael@0 51 */
michael@0 52
michael@0 53 [scriptable, uuid(0b6e2c69-5cf5-48b0-9dfd-c95950e2cc7b)]
michael@0 54 interface nsIStreamConverter : nsIStreamListener {
michael@0 55
michael@0 56 /**
michael@0 57 * <b>SYNCRONOUS VERSION</b>
michael@0 58 * Converts a stream of one type, to a stream of another type.
michael@0 59 *
michael@0 60 * Use this method when you have a stream you want to convert.
michael@0 61 *
michael@0 62 * @param aFromStream The stream representing the original/raw data.
michael@0 63 * @param aFromType The MIME type of aFromStream.
michael@0 64 * @param aToType The MIME type of the returned stream.
michael@0 65 * @param aCtxt Either an opaque context, or a converter specific context
michael@0 66 * (implementation specific).
michael@0 67 * @return The converted stream. NOTE: The returned stream may not
michael@0 68 * already be converted. An efficient stream converter
michael@0 69 * implementation will converter data on demand rather than
michael@0 70 * buffering the converted data until it is used.
michael@0 71 */
michael@0 72 nsIInputStream convert(in nsIInputStream aFromStream,
michael@0 73 in string aFromType,
michael@0 74 in string aToType,
michael@0 75 in nsISupports aCtxt);
michael@0 76
michael@0 77 /**
michael@0 78 * <b>ASYNCRONOUS VERSION</b>
michael@0 79 * Converts data arriving via the converter's nsIStreamListener::OnDataAvailable()
michael@0 80 * method from one type to another, pushing the converted data out to the caller
michael@0 81 * via aListener::OnDataAvailable().
michael@0 82 *
michael@0 83 * Use this method when you want to proxy (and convert) nsIStreamListener callbacks
michael@0 84 * asynchronously.
michael@0 85 *
michael@0 86 * @param aFromType The MIME type of the original/raw data.
michael@0 87 * @param aToType The MIME type of the converted data.
michael@0 88 * @param aListener The listener who receives the converted data.
michael@0 89 * @param aCtxt Either an opaque context, or a converter specific context
michael@0 90 * (implementation specific).
michael@0 91 */
michael@0 92 void asyncConvertData(in string aFromType,
michael@0 93 in string aToType,
michael@0 94 in nsIStreamListener aListener,
michael@0 95 in nsISupports aCtxt);
michael@0 96 };
michael@0 97
michael@0 98 %{C++
michael@0 99 #define NS_ISTREAMCONVERTER_KEY "@mozilla.org/streamconv;1"
michael@0 100 %}

mercurial