1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
---|
2 | * ***** BEGIN LICENSE BLOCK *****
|
---|
3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
---|
4 | *
|
---|
5 | * The contents of this file are subject to the Mozilla Public License Version
|
---|
6 | * 1.1 (the "License"); you may not use this file except in compliance with
|
---|
7 | * the License. You may obtain a copy of the License at
|
---|
8 | * http://www.mozilla.org/MPL/
|
---|
9 | *
|
---|
10 | * Software distributed under the License is distributed on an "AS IS" basis,
|
---|
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
---|
12 | * for the specific language governing rights and limitations under the
|
---|
13 | * License.
|
---|
14 | *
|
---|
15 | * The Original Code is Mozilla Communicator client code, released
|
---|
16 | * March 31, 1998.
|
---|
17 | *
|
---|
18 | * The Initial Developer of the Original Code is
|
---|
19 | * Netscape Communications Corporation.
|
---|
20 | * Portions created by the Initial Developer are Copyright (C) 1998-1999
|
---|
21 | * the Initial Developer. All Rights Reserved.
|
---|
22 | *
|
---|
23 | * Contributor(s):
|
---|
24 | *
|
---|
25 | * Alternatively, the contents of this file may be used under the terms of
|
---|
26 | * either of the GNU General Public License Version 2 or later (the "GPL"),
|
---|
27 | * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
---|
28 | * in which case the provisions of the GPL or the LGPL are applicable instead
|
---|
29 | * of those above. If you wish to allow use of your version of this file only
|
---|
30 | * under the terms of either the GPL or the LGPL, and not to allow others to
|
---|
31 | * use your version of this file under the terms of the MPL, indicate your
|
---|
32 | * decision by deleting the provisions above and replace them with the notice
|
---|
33 | * and other provisions required by the GPL or the LGPL. If you do not delete
|
---|
34 | * the provisions above, a recipient may use your version of this file under
|
---|
35 | * the terms of any one of the MPL, the GPL or the LGPL.
|
---|
36 | *
|
---|
37 | * ***** END LICENSE BLOCK ***** */
|
---|
38 |
|
---|
39 | #include "nsISupports.idl"
|
---|
40 | #include "nsrootidl.idl"
|
---|
41 |
|
---|
42 | interface nsIMemory;
|
---|
43 | interface nsIInputStream;
|
---|
44 | interface nsIOutputStream;
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * The nsIStorageStream interface maintains an internal data buffer that can be
|
---|
48 | * filled using a single output stream. One or more independent input streams
|
---|
49 | * can be created to read the data from the buffer non-destructively.
|
---|
50 | */
|
---|
51 |
|
---|
52 | [scriptable, uuid(604ad9d0-753e-11d3-90ca-34278643278f)]
|
---|
53 | interface nsIStorageStream : nsISupports
|
---|
54 | {
|
---|
55 | /**
|
---|
56 | *
|
---|
57 | * Initialize the stream, setting up the amount of space that will be
|
---|
58 | * allocated for the stream's backing-store.
|
---|
59 | *
|
---|
60 | * @param segmentSize
|
---|
61 | * Size of each segment. Must be a power of two.
|
---|
62 | * @param maxSize
|
---|
63 | * Maximum total size of this stream. length will always be less
|
---|
64 | * than or equal to this value. Passing PR_UINT32_MAX is safe.
|
---|
65 | * @param segmentAllocator
|
---|
66 | * Which allocator to use for the segments. May be null, in which
|
---|
67 | * case a default allocator will be used.
|
---|
68 | */
|
---|
69 | void init(in PRUint32 segmentSize, in PRUint32 maxSize, in nsIMemory segmentAllocator);
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * Get a reference to the one and only output stream for this instance.
|
---|
73 | * The zero-based startPosition argument is used is used to set the initial
|
---|
74 | * write cursor position. The startPosition cannot be set larger than the
|
---|
75 | * current buffer length. Calling this method has the side-effect of
|
---|
76 | * truncating the internal buffer to startPosition bytes.
|
---|
77 | */
|
---|
78 | nsIOutputStream getOutputStream(in PRInt32 startPosition);
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * Create a new input stream to read data (written by the singleton output
|
---|
82 | * stream) from the internal buffer. Multiple, independent input streams
|
---|
83 | * can be created.
|
---|
84 | */
|
---|
85 | nsIInputStream newInputStream(in PRInt32 startPosition);
|
---|
86 |
|
---|
87 | /**
|
---|
88 | * The length attribute indicates the total number of bytes stored in the
|
---|
89 | * nsIStorageStream internal buffer, regardless of any consumption by input
|
---|
90 | * streams. Assigning to the length field can be used to truncate the
|
---|
91 | * buffer data, but can not be used when either the instance's output
|
---|
92 | * stream is in use.
|
---|
93 | *
|
---|
94 | * @See #writeInProgress */
|
---|
95 | attribute PRUint32 length;
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * True, when output stream has not yet been Close'ed
|
---|
99 | */
|
---|
100 | readonly attribute boolean writeInProgress;
|
---|
101 | };
|
---|
102 |
|
---|
103 | %{C++
|
---|
104 | // Factory method
|
---|
105 | NS_COM nsresult
|
---|
106 | NS_NewStorageStream(PRUint32 segmentSize, PRUint32 maxSize, nsIStorageStream **result);
|
---|
107 | %}
|
---|