netwerk/base/public/nsITransport.idl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #include "nsISupports.idl"
michael@0 6
michael@0 7 interface nsIInputStream;
michael@0 8 interface nsIOutputStream;
michael@0 9 interface nsITransportEventSink;
michael@0 10 interface nsIEventTarget;
michael@0 11
michael@0 12 /**
michael@0 13 * nsITransport
michael@0 14 *
michael@0 15 * This interface provides a common way of accessing i/o streams connected
michael@0 16 * to some resource. This interface does not in any way specify the resource.
michael@0 17 * It provides methods to open blocking or non-blocking, buffered or unbuffered
michael@0 18 * streams to the resource. The name "transport" is meant to connote the
michael@0 19 * inherent data transfer implied by this interface (i.e., data is being
michael@0 20 * transfered in some fashion via the streams exposed by this interface).
michael@0 21 *
michael@0 22 * A transport can have an event sink associated with it. The event sink
michael@0 23 * receives transport-specific events as the transfer is occuring. For a
michael@0 24 * socket transport, these events can include status about the connection.
michael@0 25 * See nsISocketTransport for more info about socket transport specifics.
michael@0 26 */
michael@0 27 [scriptable, uuid(d8786c64-eb49-4a0b-b42c-0936a745fbe8)]
michael@0 28 interface nsITransport : nsISupports
michael@0 29 {
michael@0 30 /**
michael@0 31 * Open flags.
michael@0 32 */
michael@0 33 const unsigned long OPEN_BLOCKING = 1<<0;
michael@0 34 const unsigned long OPEN_UNBUFFERED = 1<<1;
michael@0 35
michael@0 36 /**
michael@0 37 * Open an input stream on this transport.
michael@0 38 *
michael@0 39 * Flags have the following meaning:
michael@0 40 *
michael@0 41 * OPEN_BLOCKING
michael@0 42 * If specified, then the resulting stream will have blocking stream
michael@0 43 * semantics. This means that if the stream has no data and is not
michael@0 44 * closed, then reading from it will block the calling thread until
michael@0 45 * at least one byte is available or until the stream is closed.
michael@0 46 * If this flag is NOT specified, then the stream has non-blocking
michael@0 47 * stream semantics. This means that if the stream has no data and is
michael@0 48 * not closed, then reading from it returns NS_BASE_STREAM_WOULD_BLOCK.
michael@0 49 * In addition, in non-blocking mode, the stream is guaranteed to
michael@0 50 * support nsIAsyncInputStream. This interface allows the consumer of
michael@0 51 * the stream to be notified when the stream can again be read.
michael@0 52 *
michael@0 53 * OPEN_UNBUFFERED
michael@0 54 * If specified, the resulting stream may not support ReadSegments.
michael@0 55 * ReadSegments is only gauranteed to be implemented when this flag is
michael@0 56 * NOT specified.
michael@0 57 *
michael@0 58 * @param aFlags
michael@0 59 * optional transport specific flags.
michael@0 60 * @param aSegmentSize
michael@0 61 * if OPEN_UNBUFFERED is not set, then this parameter specifies the
michael@0 62 * size of each buffer segment (pass 0 to use default value).
michael@0 63 * @param aSegmentCount
michael@0 64 * if OPEN_UNBUFFERED is not set, then this parameter specifies the
michael@0 65 * maximum number of buffer segments (pass 0 to use default value).
michael@0 66 */
michael@0 67 nsIInputStream openInputStream(in unsigned long aFlags,
michael@0 68 in unsigned long aSegmentSize,
michael@0 69 in unsigned long aSegmentCount);
michael@0 70
michael@0 71 /**
michael@0 72 * Open an output stream on this transport.
michael@0 73 *
michael@0 74 * Flags have the following meaning:
michael@0 75 *
michael@0 76 * OPEN_BLOCKING
michael@0 77 * If specified, then the resulting stream will have blocking stream
michael@0 78 * semantics. This means that if the stream is full and is not closed,
michael@0 79 * then writing to it will block the calling thread until ALL of the
michael@0 80 * data can be written or until the stream is closed. If this flag is
michael@0 81 * NOT specified, then the stream has non-blocking stream semantics.
michael@0 82 * This means that if the stream is full and is not closed, then writing
michael@0 83 * to it returns NS_BASE_STREAM_WOULD_BLOCK. In addition, in non-
michael@0 84 * blocking mode, the stream is guaranteed to support
michael@0 85 * nsIAsyncOutputStream. This interface allows the consumer of the
michael@0 86 * stream to be notified when the stream can again accept more data.
michael@0 87 *
michael@0 88 * OPEN_UNBUFFERED
michael@0 89 * If specified, the resulting stream may not support WriteSegments and
michael@0 90 * WriteFrom. WriteSegments and WriteFrom are only guaranteed to be
michael@0 91 * implemented when this flag is NOT specified.
michael@0 92 *
michael@0 93 * @param aFlags
michael@0 94 * optional transport specific flags.
michael@0 95 * @param aSegmentSize
michael@0 96 * if OPEN_UNBUFFERED is not set, then this parameter specifies the
michael@0 97 * size of each buffer segment (pass 0 to use default value).
michael@0 98 * @param aSegmentCount
michael@0 99 * if OPEN_UNBUFFERED is not set, then this parameter specifies the
michael@0 100 * maximum number of buffer segments (pass 0 to use default value).
michael@0 101 */
michael@0 102 nsIOutputStream openOutputStream(in unsigned long aFlags,
michael@0 103 in unsigned long aSegmentSize,
michael@0 104 in unsigned long aSegmentCount);
michael@0 105
michael@0 106 /**
michael@0 107 * Close the transport and any open streams.
michael@0 108 *
michael@0 109 * @param aReason
michael@0 110 * the reason for closing the stream.
michael@0 111 */
michael@0 112 void close(in nsresult aReason);
michael@0 113
michael@0 114 /**
michael@0 115 * Set the transport event sink.
michael@0 116 *
michael@0 117 * @param aSink
michael@0 118 * receives transport layer notifications
michael@0 119 * @param aEventTarget
michael@0 120 * indicates the event target to which the notifications should
michael@0 121 * be delivered. if NULL, then the notifications may occur on
michael@0 122 * any thread.
michael@0 123 */
michael@0 124 void setEventSink(in nsITransportEventSink aSink,
michael@0 125 in nsIEventTarget aEventTarget);
michael@0 126
michael@0 127 /**
michael@0 128 * Generic nsITransportEventSink status codes. nsITransport
michael@0 129 * implementations may override these status codes with their own more
michael@0 130 * specific status codes (e.g., see nsISocketTransport).
michael@0 131 *
michael@0 132 * In C++, these constants have a type of uint32_t, so C++ callers must use
michael@0 133 * the NS_NET_STATUS_* constants defined below, which have a type of
michael@0 134 * nsresult.
michael@0 135 */
michael@0 136 const unsigned long STATUS_READING = 0x804b0008;
michael@0 137 const unsigned long STATUS_WRITING = 0x804b0009;
michael@0 138 };
michael@0 139
michael@0 140 [scriptable, uuid(EDA4F520-67F7-484b-A691-8C3226A5B0A6)]
michael@0 141 interface nsITransportEventSink : nsISupports
michael@0 142 {
michael@0 143 /**
michael@0 144 * Transport status notification.
michael@0 145 *
michael@0 146 * @param aTransport
michael@0 147 * the transport sending this status notification.
michael@0 148 * @param aStatus
michael@0 149 * the transport status (resolvable to a string using
michael@0 150 * nsIErrorService). See nsISocketTransport for socket specific
michael@0 151 * status codes and more comments.
michael@0 152 * @param aProgress
michael@0 153 * the amount of data either read or written depending on the value
michael@0 154 * of the status code. this value is relative to aProgressMax.
michael@0 155 * @param aProgressMax
michael@0 156 * the maximum amount of data that will be read or written. if
michael@0 157 * unknown, 0xFFFFFFFF will be passed.
michael@0 158 */
michael@0 159 void onTransportStatus(in nsITransport aTransport,
michael@0 160 in nsresult aStatus,
michael@0 161 in unsigned long long aProgress,
michael@0 162 in unsigned long long aProgressMax);
michael@0 163 };

mercurial