Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / xpcom / io / nsIStorageStream.idl
blobc2792f50025ede64f8c9ba3d5babfdc2316d2696
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 #include "nsISupports.idl"
8 interface nsIInputStream;
9 interface nsIOutputStream;
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.
17 [scriptable, uuid(44a200fe-6c2b-4b41-b4e3-63e8c14e7c0d)]
18 interface nsIStorageStream : nsISupports
20 /**
22 * Initialize the stream, setting up the amount of space that will be
23 * allocated for the stream's backing-store.
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.
31 void init(in uint32_t segmentSize, in uint32_t maxSize);
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.
40 nsIOutputStream getOutputStream(in int32_t startPosition);
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.
47 nsIInputStream newInputStream(in int32_t startPosition);
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.
56 * @See #writeInProgress */
57 attribute uint32_t length;
59 /**
60 * True, when output stream has not yet been Close'ed
62 readonly attribute boolean writeInProgress;
65 %{C++
66 // Factory method
67 nsresult
68 NS_NewStorageStream(uint32_t segmentSize, uint32_t maxSize, nsIStorageStream **result);