michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsIInputStream.idl" michael@0: michael@0: interface nsIOutputStream; michael@0: interface nsIEventTarget; michael@0: michael@0: /** michael@0: * A nsIInputStreamTee is a wrapper for an input stream, that when read michael@0: * reads the specified amount of data from its |source| and copies that michael@0: * data to its |sink|. |sink| must be a blocking output stream. michael@0: */ michael@0: [scriptable, uuid(90a9d790-3bca-421e-a73b-98f68e13c917)] michael@0: interface nsIInputStreamTee : nsIInputStream michael@0: { michael@0: attribute nsIInputStream source; michael@0: attribute nsIOutputStream sink; michael@0: michael@0: /** michael@0: * If |eventTarget| is set, copying to sink is done asynchronously using michael@0: * the event-target (e.g. a thread). If |eventTarget| is not set, copying michael@0: * to sink happens synchronously while reading from the source. michael@0: */ michael@0: attribute nsIEventTarget eventTarget; michael@0: }; michael@0: michael@0: %{C++ michael@0: // factory methods michael@0: extern nsresult michael@0: NS_NewInputStreamTee(nsIInputStream **tee, // read from this input stream michael@0: nsIInputStream *source, michael@0: nsIOutputStream *sink); michael@0: michael@0: extern nsresult michael@0: NS_NewInputStreamTeeAsync(nsIInputStream **tee, // read from this input stream michael@0: nsIInputStream *source, michael@0: nsIOutputStream *sink, michael@0: nsIEventTarget *eventTarget); michael@0: %}