Source code

Revision control

Other Tools

1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
#include "nsIRequest.idl"
6
7
interface nsIInputStream;
8
interface nsIOutputStream;
9
interface nsIRequestObserver;
10
interface nsIEventTarget;
11
12
// You should prefer nsIAsyncStreamCopier2
13
[scriptable, uuid(5a19ca27-e041-4aca-8287-eb248d4c50c0)]
14
interface nsIAsyncStreamCopier : nsIRequest
15
{
16
/**
17
* Initialize the stream copier.
18
*
19
* @param aSource
20
* contains the data to be copied.
21
* @param aSink
22
* specifies the destination for the data.
23
* @param aTarget
24
* specifies the thread on which the copy will occur. a null value
25
* is permitted and will cause the copy to occur on an unspecified
26
* background thread.
27
* @param aSourceBuffered
28
* true if aSource implements ReadSegments.
29
* @param aSinkBuffered
30
* true if aSink implements WriteSegments.
31
* @param aChunkSize
32
* specifies how many bytes to read/write at a time. this controls
33
* the granularity of the copying. it should match the segment size
34
* of the "buffered" streams involved.
35
* @param aCloseSource
36
* true if aSource should be closed after copying.
37
* @param aCloseSink
38
* true if aSink should be closed after copying.
39
*
40
* NOTE: at least one of the streams must be buffered. If you do not know
41
* whether your streams are buffered, you should use nsIAsyncStreamCopier2
42
* instead.
43
*/
44
void init(in nsIInputStream aSource,
45
in nsIOutputStream aSink,
46
in nsIEventTarget aTarget,
47
in boolean aSourceBuffered,
48
in boolean aSinkBuffered,
49
in unsigned long aChunkSize,
50
in boolean aCloseSource,
51
in boolean aCloseSink);
52
53
/**
54
* asyncCopy triggers the start of the copy. The observer will be notified
55
* when the copy completes.
56
*
57
* @param aObserver
58
* receives notifications.
59
* @param aObserverContext
60
* passed to observer methods.
61
*/
62
void asyncCopy(in nsIRequestObserver aObserver,
63
in nsISupports aObserverContext);
64
};