xpcom/io/nsIUnicharInputStream.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.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include "nsISupports.idl"
     8 interface nsIUnicharInputStream;
     9 interface nsIInputStream;
    11 %{C++
    12 /**
    13  * The signature of the writer function passed to ReadSegments. This
    14  * is the "consumer" of data that gets read from the stream's buffer.
    15  *
    16  * @param aInStream stream being read
    17  * @param aClosure opaque parameter passed to ReadSegments
    18  * @param aFromSegment pointer to memory owned by the input stream
    19  * @param aToOffset amount already read (since ReadSegments was called)
    20  * @param aCount length of fromSegment
    21  * @param aWriteCount number of bytes read
    22  *
    23  * Implementers should return the following:
    24  *
    25  * @throws <any-error> if not interested in consuming any data
    26  *
    27  * Errors are never passed to the caller of ReadSegments.
    28  *
    29  * NOTE: returning NS_OK and (*aWriteCount = 0) has undefined behavior.
    30  */
    31 typedef NS_CALLBACK(nsWriteUnicharSegmentFun)(nsIUnicharInputStream *aInStream,
    32                                               void *aClosure,
    33                                               const char16_t *aFromSegment,
    34                                               uint32_t aToOffset,
    35                                               uint32_t aCount,
    36                                               uint32_t *aWriteCount);
    37 %}
    38 native nsWriteUnicharSegmentFun(nsWriteUnicharSegmentFun);
    40 /**
    41  * Abstract unicode character input stream
    42  * @see nsIInputStream
    43  */
    44 [scriptable, uuid(d5e3bd80-6723-4b92-b0c9-22f6162fd94f)]
    45 interface nsIUnicharInputStream : nsISupports {
    46   /**
    47    * Reads into a caller-provided character array.
    48    *
    49    * @return The number of characters that were successfully read. May be less
    50    *         than aCount, even if there is more data in the input stream.
    51    *         A return value of 0 means EOF.
    52    *
    53    * @note To read more than 2^32 characters, call this method multiple times.
    54    */
    55   [noscript] unsigned long read([array, size_is(aCount)] in char16_t aBuf,
    56                                 in unsigned long aCount);
    58   /**
    59    * Low-level read method that has access to the stream's underlying buffer.
    60    * The writer function may be called multiple times for segmented buffers.
    61    * ReadSegments is expected to keep calling the writer until either there is
    62    * nothing left to read or the writer returns an error.  ReadSegments should
    63    * not call the writer with zero characters to consume.
    64    *
    65    * @param aWriter the "consumer" of the data to be read
    66    * @param aClosure opaque parameter passed to writer 
    67    * @param aCount the maximum number of characters to be read
    68    *
    69    * @return number of characters read (may be less than aCount)
    70    * @return 0 if reached end of file (or if aWriter refused to consume data)
    71    *
    72    * @throws NS_BASE_STREAM_WOULD_BLOCK if reading from the input stream would
    73    *   block the calling thread (non-blocking mode only)
    74    * @throws <other-error> on failure
    75    *
    76    * NOTE: this function may be unimplemented if a stream has no underlying
    77    * buffer
    78    */
    79   [noscript] unsigned long readSegments(in nsWriteUnicharSegmentFun aWriter,
    80                                         in voidPtr aClosure,
    81                                         in unsigned long aCount);
    83   /**
    84    * Read into a string object.
    85    * @param aCount The number of characters that should be read
    86    * @return The number of characters that were read.
    87    */
    88   unsigned long readString(in unsigned long aCount, out AString aString);
    90  /**
    91   * Close the stream and free associated resources. This also closes the
    92   * underlying stream, if any.
    93   */
    94   void close();
    95 };

mercurial