1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/streamconv/public/nsIStreamConverterService.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsISupports.idl" 1.10 + 1.11 +interface nsIInputStream; 1.12 +interface nsIStreamListener; 1.13 + 1.14 +%{C++ 1.15 +#define NS_ISTREAMCONVERTER_KEY "@mozilla.org/streamconv;1" 1.16 +%} 1.17 + 1.18 +/** 1.19 + * The nsIStreamConverterService is a higher level stream converter factory 1.20 + * responsible for locating and creating stream converters 1.21 + * (nsIStreamConverter). 1.22 + * 1.23 + * This service retrieves an interface that can convert data from a particular 1.24 + * MIME type, to a particular MIME type. It is responsible for any intermediary 1.25 + * conversion required in order to get from X to Z, assuming direct conversion 1.26 + * is not possible. 1.27 + * 1.28 + * @author Jud Valeski 1.29 + * @see nsIStreamConverter 1.30 + */ 1.31 +[scriptable, uuid(f2b1ab53-f0bd-4adb-9365-e59b1701a258)] 1.32 +interface nsIStreamConverterService : nsISupports { 1.33 + /** 1.34 + * Tests whether conversion between the two specified types is possible. 1.35 + * This is cheaper than calling convert()/asyncConvertData(); it is not 1.36 + * necessary to call this function before calling one of those, though. 1.37 + */ 1.38 + boolean canConvert(in string aFromType, in string aToType); 1.39 + 1.40 + /** 1.41 + * <b>SYNCHRONOUS VERSION</b> 1.42 + * Converts a stream of one type, to a stream of another type. 1.43 + * 1.44 + * Use this method when you have a stream you want to convert. 1.45 + * 1.46 + * @param aFromStream The stream representing the original/raw data. 1.47 + * @param aFromType The MIME type of aFromStream. 1.48 + * @param aToType The MIME type of the returned stream. 1.49 + * @param aContext Either an opaque context, or a converter specific 1.50 + * context (implementation specific). 1.51 + * @return The converted stream. NOTE: The returned stream 1.52 + * may not already be converted. An efficient stream 1.53 + * converter implementation will convert data on 1.54 + * demand rather than buffering the converted data 1.55 + * until it is used. 1.56 + */ 1.57 + nsIInputStream convert(in nsIInputStream aFromStream, 1.58 + in string aFromType, 1.59 + in string aToType, 1.60 + in nsISupports aContext); 1.61 + 1.62 + /** 1.63 + * <b>ASYNCHRONOUS VERSION</b> 1.64 + * Retrieves a nsIStreamListener that receives the original/raw data via its 1.65 + * nsIStreamListener::OnDataAvailable() callback, then converts and pushes 1.66 + * the data to aListener. 1.67 + * 1.68 + * Use this method when you want to proxy (and convert) nsIStreamListener 1.69 + * callbacks asynchronously. 1.70 + * 1.71 + * @param aFromType The MIME type of the original/raw data. 1.72 + * @param aToType The MIME type of the converted data. 1.73 + * @param aListener The listener that receives the converted data. 1.74 + * @param aCtxt Either an opaque context, or a converter specific 1.75 + * context (implementation specific). 1.76 + * @return A nsIStreamListener that receives data via its 1.77 + * OnDataAvailable() method. 1.78 + */ 1.79 + nsIStreamListener asyncConvertData(in string aFromType, 1.80 + in string aToType, 1.81 + in nsIStreamListener aListener, 1.82 + in nsISupports aContext); 1.83 +};