summaryrefslogtreecommitdiff
path: root/netwerk/base/nsIAsyncStreamCopier2.idl
blob: 7de793f51e3270d63cdae1b8e21fa11b68e4ff5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsIRequest.idl"

interface nsIInputStream;
interface nsIOutputStream;
interface nsIRequestObserver;
interface nsIEventTarget;

[scriptable, uuid(a5b2decf-4ede-4801-8b38-e5fe5db46bf2)]
interface nsIAsyncStreamCopier2 : nsIRequest
{
    /**
     * Initialize the stream copier.
     *
     * If neither the source nor the sink are buffered, buffering will
     * be automatically added to the sink.
     *
     *
     * @param aSource
     *        contains the data to be copied.
     * @param aSink
     *        specifies the destination for the data.
     * @param aTarget
     *        specifies the thread on which the copy will occur.  a null value
     *        is permitted and will cause the copy to occur on an unspecified
     *        background thread.
     * @param aChunkSize
     *        specifies how many bytes to read/write at a time.  this controls
     *        the granularity of the copying.  it should match the segment size
     *        of the "buffered" streams involved.
     * @param aCloseSource
     *        true if aSource should be closed after copying (this is generally
     *        the desired behavior).
     * @param aCloseSink
     *        true if aSink should be closed after copying (this is generally
     *        the desired behavior).
     */
  void init(in nsIInputStream    aSource,
            in nsIOutputStream   aSink,
            in nsIEventTarget    aTarget,
            in unsigned long     aChunkSize,
            in boolean           aCloseSource,
            in boolean           aCloseSink);

  /**
   * asyncCopy triggers the start of the copy.  The observer will be notified
   * when the copy completes.
   *
   * @param aObserver
   *        receives notifications.
   * @param aObserverContext
   *        passed to observer methods.
   */
  void asyncCopy(in nsIRequestObserver   aObserver,
                 in nsISupports          aObserverContext);
};