1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/io/nsIScriptableBase64Encoder.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,32 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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 + 1.13 +/** 1.14 + * nsIScriptableBase64Encoder efficiently encodes the contents 1.15 + * of a nsIInputStream to a Base64 string. This avoids the need 1.16 + * to read the entire stream into a buffer, and only then do the 1.17 + * Base64 encoding. 1.18 + * 1.19 + * If you already have a buffer full of data, you should use 1.20 + * btoa instead! 1.21 + */ 1.22 +[scriptable, uuid(9479c864-d1f9-45ab-b7b9-28b907bd2ba9)] 1.23 +interface nsIScriptableBase64Encoder : nsISupports 1.24 +{ 1.25 + /** 1.26 + * These methods take an nsIInputStream and return a narrow or wide 1.27 + * string with the contents of the nsIInputStream base64 encoded. 1.28 + * 1.29 + * The stream passed in must support ReadSegments and must not be 1.30 + * a non-blocking stream that will return NS_BASE_STREAM_WOULD_BLOCK. 1.31 + * If either of these restrictions are violated we will abort. 1.32 + */ 1.33 + ACString encodeToCString(in nsIInputStream stream, in unsigned long length); 1.34 + AString encodeToString(in nsIInputStream stream, in unsigned long length); 1.35 +};