xpcom/io/nsIBinaryOutputStream.idl

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; 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 "nsIOutputStream.idl"
michael@0 7
michael@0 8 /**
michael@0 9 * This interface allows writing of primitive data types (integers,
michael@0 10 * floating-point values, booleans, etc.) to a stream in a binary, untagged,
michael@0 11 * fixed-endianness format. This might be used, for example, to implement
michael@0 12 * network protocols or to produce architecture-neutral binary disk files,
michael@0 13 * i.e. ones that can be read and written by both big-endian and little-endian
michael@0 14 * platforms. Output is written in big-endian order (high-order byte first),
michael@0 15 * as this is traditional network order.
michael@0 16 *
michael@0 17 * @See nsIBinaryInputStream
michael@0 18 */
michael@0 19
michael@0 20 [scriptable, uuid(204ee610-8765-11d3-90cf-0040056a906e)]
michael@0 21 interface nsIBinaryOutputStream : nsIOutputStream {
michael@0 22 void setOutputStream(in nsIOutputStream aOutputStream);
michael@0 23
michael@0 24 /**
michael@0 25 * Write a boolean as an 8-bit char to the stream.
michael@0 26 */
michael@0 27 void writeBoolean(in boolean aBoolean);
michael@0 28
michael@0 29 void write8(in uint8_t aByte);
michael@0 30 void write16(in uint16_t a16);
michael@0 31 void write32(in uint32_t a32);
michael@0 32 void write64(in uint64_t a64);
michael@0 33
michael@0 34 void writeFloat(in float aFloat);
michael@0 35 void writeDouble(in double aDouble);
michael@0 36
michael@0 37 /**
michael@0 38 * Write an 8-bit pascal style string to the stream.
michael@0 39 * 32-bit length field, followed by length 8-bit chars.
michael@0 40 */
michael@0 41 void writeStringZ(in string aString);
michael@0 42
michael@0 43 /**
michael@0 44 * Write a 16-bit pascal style string to the stream.
michael@0 45 * 32-bit length field, followed by length PRUnichars.
michael@0 46 */
michael@0 47 void writeWStringZ(in wstring aString);
michael@0 48
michael@0 49 /**
michael@0 50 * Write an 8-bit pascal style string (UTF8-encoded) to the stream.
michael@0 51 * 32-bit length field, followed by length 8-bit chars.
michael@0 52 */
michael@0 53 void writeUtf8Z(in wstring aString);
michael@0 54
michael@0 55 /**
michael@0 56 * Write an opaque byte array to the stream.
michael@0 57 */
michael@0 58 void writeBytes([size_is(aLength)] in string aString, in uint32_t aLength);
michael@0 59
michael@0 60 /**
michael@0 61 * Write an opaque byte array to the stream.
michael@0 62 */
michael@0 63 void writeByteArray([array, size_is(aLength)] in uint8_t aBytes,
michael@0 64 in uint32_t aLength);
michael@0 65
michael@0 66 };
michael@0 67
michael@0 68 %{C++
michael@0 69
michael@0 70 inline nsresult
michael@0 71 NS_WriteOptionalStringZ(nsIBinaryOutputStream* aStream, const char* aString)
michael@0 72 {
michael@0 73 bool nonnull = (aString != nullptr);
michael@0 74 nsresult rv = aStream->WriteBoolean(nonnull);
michael@0 75 if (NS_SUCCEEDED(rv) && nonnull)
michael@0 76 rv = aStream->WriteStringZ(aString);
michael@0 77 return rv;
michael@0 78 }
michael@0 79
michael@0 80 inline nsresult
michael@0 81 NS_WriteOptionalWStringZ(nsIBinaryOutputStream* aStream, const char16_t* aString)
michael@0 82 {
michael@0 83 bool nonnull = (aString != nullptr);
michael@0 84 nsresult rv = aStream->WriteBoolean(nonnull);
michael@0 85 if (NS_SUCCEEDED(rv) && nonnull)
michael@0 86 rv = aStream->WriteWStringZ(aString);
michael@0 87 return rv;
michael@0 88 }
michael@0 89
michael@0 90 %}

mercurial