xpcom/io/nsIInputStreamTee.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/io/nsIInputStreamTee.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,42 @@
     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 "nsIInputStream.idl"
    1.10 +
    1.11 +interface nsIOutputStream;
    1.12 +interface nsIEventTarget;
    1.13 +
    1.14 +/**
    1.15 + * A nsIInputStreamTee is a wrapper for an input stream, that when read
    1.16 + * reads the specified amount of data from its |source| and copies that
    1.17 + * data to its |sink|.  |sink| must be a blocking output stream.
    1.18 + */
    1.19 +[scriptable, uuid(90a9d790-3bca-421e-a73b-98f68e13c917)]
    1.20 +interface nsIInputStreamTee : nsIInputStream
    1.21 +{
    1.22 +    attribute nsIInputStream source;
    1.23 +    attribute nsIOutputStream sink;
    1.24 +    
    1.25 +    /**
    1.26 +     * If |eventTarget| is set, copying to sink is done asynchronously using
    1.27 +     * the event-target (e.g. a thread). If |eventTarget| is not set, copying
    1.28 +     * to sink happens synchronously while reading from the source.
    1.29 +     */
    1.30 +    attribute nsIEventTarget eventTarget;
    1.31 +};
    1.32 +
    1.33 +%{C++
    1.34 +// factory methods
    1.35 +extern nsresult
    1.36 +NS_NewInputStreamTee(nsIInputStream **tee, // read from this input stream
    1.37 +                     nsIInputStream *source,
    1.38 +                     nsIOutputStream *sink);
    1.39 +                     
    1.40 +extern nsresult
    1.41 +NS_NewInputStreamTeeAsync(nsIInputStream **tee, // read from this input stream
    1.42 +                     nsIInputStream *source,
    1.43 +                     nsIOutputStream *sink,
    1.44 +                     nsIEventTarget *eventTarget);
    1.45 +%}

mercurial