xpcom/io/nsBinaryStream.h

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: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     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 #ifndef nsBinaryStream_h___
     7 #define nsBinaryStream_h___
     9 #include "nsCOMPtr.h"
    10 #include "nsAString.h"
    11 #include "nsIObjectInputStream.h"
    12 #include "nsIObjectOutputStream.h"
    13 #include "nsIStreamBufferAccess.h"
    15 #define NS_BINARYOUTPUTSTREAM_CID        \
    16 { /* 86c37b9a-74e7-4672-844e-6e7dd83ba484 */         \
    17      0x86c37b9a,                                     \
    18      0x74e7,                                         \
    19      0x4672,                                         \
    20     {0x84, 0x4e, 0x6e, 0x7d, 0xd8, 0x3b, 0xa4, 0x84} \
    21 }
    23 #define NS_BINARYOUTPUTSTREAM_CONTRACTID "@mozilla.org/binaryoutputstream;1"
    25 // Derive from nsIObjectOutputStream so this class can be used as a superclass
    26 // by nsObjectOutputStream.
    27 class nsBinaryOutputStream : public nsIObjectOutputStream
    28 {
    29 public:
    30     nsBinaryOutputStream() {}
    31     // virtual dtor since subclasses call our Release()
    32     virtual ~nsBinaryOutputStream() {}
    34 protected:
    35     // nsISupports methods
    36     NS_DECL_ISUPPORTS
    38     // nsIOutputStream methods
    39     NS_DECL_NSIOUTPUTSTREAM
    41     // nsIBinaryOutputStream methods
    42     NS_DECL_NSIBINARYOUTPUTSTREAM
    44     // nsIObjectOutputStream methods
    45     NS_DECL_NSIOBJECTOUTPUTSTREAM
    47     // Call Write(), ensuring that all proffered data is written
    48     nsresult WriteFully(const char *aBuf, uint32_t aCount);
    50     nsCOMPtr<nsIOutputStream>       mOutputStream;
    51     nsCOMPtr<nsIStreamBufferAccess> mBufferAccess;
    52 };
    54 #define NS_BINARYINPUTSTREAM_CID        \
    55 { /* c521a612-2aad-46db-b6ab-3b821fb150b1 */         \
    56      0xc521a612,                                     \
    57      0x2aad,                                         \
    58      0x46db,                                         \
    59     {0xb6, 0xab, 0x3b, 0x82, 0x1f, 0xb1, 0x50, 0xb1} \
    60 }
    62 #define NS_BINARYINPUTSTREAM_CONTRACTID "@mozilla.org/binaryinputstream;1"
    64 // Derive from nsIObjectInputStream so this class can be used as a superclass
    65 // by nsObjectInputStream.
    66 class nsBinaryInputStream : public nsIObjectInputStream
    67 {
    68 public:
    69     nsBinaryInputStream() {}
    70     // virtual dtor since subclasses call our Release()
    71     virtual ~nsBinaryInputStream() {}
    73 protected:
    74     // nsISupports methods
    75     NS_DECL_ISUPPORTS
    77     // nsIInputStream methods
    78     NS_DECL_NSIINPUTSTREAM
    80     // nsIBinaryInputStream methods
    81     NS_DECL_NSIBINARYINPUTSTREAM
    83     // nsIObjectInputStream methods
    84     NS_DECL_NSIOBJECTINPUTSTREAM
    86     nsCOMPtr<nsIInputStream>        mInputStream;
    87     nsCOMPtr<nsIStreamBufferAccess> mBufferAccess;
    88 };
    90 #endif // nsBinaryStream_h___

mercurial