xpcom/io/nsIStorageStream.idl

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:c72177b3e8a9
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/. */
5
6 #include "nsISupports.idl"
7
8 interface nsIInputStream;
9 interface nsIOutputStream;
10
11 /**
12 * The nsIStorageStream interface maintains an internal data buffer that can be
13 * filled using a single output stream. One or more independent input streams
14 * can be created to read the data from the buffer non-destructively.
15 */
16
17 [scriptable, uuid(44a200fe-6c2b-4b41-b4e3-63e8c14e7c0d)]
18 interface nsIStorageStream : nsISupports
19 {
20 /**
21 *
22 * Initialize the stream, setting up the amount of space that will be
23 * allocated for the stream's backing-store.
24 *
25 * @param segmentSize
26 * Size of each segment. Must be a power of two.
27 * @param maxSize
28 * Maximum total size of this stream. length will always be less
29 * than or equal to this value. Passing UINT32_MAX is safe.
30 */
31 void init(in uint32_t segmentSize, in uint32_t maxSize);
32
33 /**
34 * Get a reference to the one and only output stream for this instance.
35 * The zero-based startPosition argument is used is used to set the initial
36 * write cursor position. The startPosition cannot be set larger than the
37 * current buffer length. Calling this method has the side-effect of
38 * truncating the internal buffer to startPosition bytes.
39 */
40 nsIOutputStream getOutputStream(in int32_t startPosition);
41
42 /**
43 * Create a new input stream to read data (written by the singleton output
44 * stream) from the internal buffer. Multiple, independent input streams
45 * can be created.
46 */
47 nsIInputStream newInputStream(in int32_t startPosition);
48
49 /**
50 * The length attribute indicates the total number of bytes stored in the
51 * nsIStorageStream internal buffer, regardless of any consumption by input
52 * streams. Assigning to the length field can be used to truncate the
53 * buffer data, but can not be used when either the instance's output
54 * stream is in use.
55 *
56 * @See #writeInProgress */
57 attribute uint32_t length;
58
59 /**
60 * True, when output stream has not yet been Close'ed
61 */
62 readonly attribute boolean writeInProgress;
63 };
64
65 %{C++
66 // Factory method
67 nsresult
68 NS_NewStorageStream(uint32_t segmentSize, uint32_t maxSize, nsIStorageStream **result);
69 %}

mercurial