1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/io/nsIStorageStream.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,69 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsISupports.idl" 1.10 + 1.11 +interface nsIInputStream; 1.12 +interface nsIOutputStream; 1.13 + 1.14 +/** 1.15 + * The nsIStorageStream interface maintains an internal data buffer that can be 1.16 + * filled using a single output stream. One or more independent input streams 1.17 + * can be created to read the data from the buffer non-destructively. 1.18 + */ 1.19 + 1.20 +[scriptable, uuid(44a200fe-6c2b-4b41-b4e3-63e8c14e7c0d)] 1.21 +interface nsIStorageStream : nsISupports 1.22 +{ 1.23 + /** 1.24 + * 1.25 + * Initialize the stream, setting up the amount of space that will be 1.26 + * allocated for the stream's backing-store. 1.27 + * 1.28 + * @param segmentSize 1.29 + * Size of each segment. Must be a power of two. 1.30 + * @param maxSize 1.31 + * Maximum total size of this stream. length will always be less 1.32 + * than or equal to this value. Passing UINT32_MAX is safe. 1.33 + */ 1.34 + void init(in uint32_t segmentSize, in uint32_t maxSize); 1.35 + 1.36 + /** 1.37 + * Get a reference to the one and only output stream for this instance. 1.38 + * The zero-based startPosition argument is used is used to set the initial 1.39 + * write cursor position. The startPosition cannot be set larger than the 1.40 + * current buffer length. Calling this method has the side-effect of 1.41 + * truncating the internal buffer to startPosition bytes. 1.42 + */ 1.43 + nsIOutputStream getOutputStream(in int32_t startPosition); 1.44 + 1.45 + /** 1.46 + * Create a new input stream to read data (written by the singleton output 1.47 + * stream) from the internal buffer. Multiple, independent input streams 1.48 + * can be created. 1.49 + */ 1.50 + nsIInputStream newInputStream(in int32_t startPosition); 1.51 + 1.52 + /** 1.53 + * The length attribute indicates the total number of bytes stored in the 1.54 + * nsIStorageStream internal buffer, regardless of any consumption by input 1.55 + * streams. Assigning to the length field can be used to truncate the 1.56 + * buffer data, but can not be used when either the instance's output 1.57 + * stream is in use. 1.58 + * 1.59 + * @See #writeInProgress */ 1.60 + attribute uint32_t length; 1.61 + 1.62 + /** 1.63 + * True, when output stream has not yet been Close'ed 1.64 + */ 1.65 + readonly attribute boolean writeInProgress; 1.66 +}; 1.67 + 1.68 +%{C++ 1.69 +// Factory method 1.70 +nsresult 1.71 +NS_NewStorageStream(uint32_t segmentSize, uint32_t maxSize, nsIStorageStream **result); 1.72 +%}