1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include
"nsISupports.idl"
8 interface nsIInputStream
;
9 interface nsIAsyncInputStream
;
12 * An instance of this interface can be used to throttle the uploads
13 * of a group of associated channels.
15 [scriptable
, uuid(6b4b96fe
-3c67
-4587-af7b
-58b6b17da411
)]
16 interface nsIInputChannelThrottleQueue
: nsISupports
19 * Initialize this object with the mean and maximum bytes per
20 * second that will be allowed. Neither value may be zero, and
21 * the maximum must not be less than the mean.
23 * @param aMeanBytesPerSecond
24 * Mean number of bytes per second.
25 * @param aMaxBytesPerSecond
26 * Maximum number of bytes per second.
28 void init
(in unsigned long aMeanBytesPerSecond
, in unsigned long aMaxBytesPerSecond
);
31 * Internal use only. Get the values set by init method.
33 [noscript
] readonly attribute
unsigned long meanBytesPerSecond
;
34 [noscript
] readonly attribute
unsigned long maxBytesPerSecond
;
38 * Return the number of bytes that are available to the caller in
42 * The number of bytes available to be processed
43 * @return the number of bytes allowed to be processed during this
44 * time slice; this will never be greater than aRemaining.
46 unsigned long available
(in unsigned long aRemaining
);
49 * Record a successful read.
52 * The number of bytes actually read.
54 void recordRead
(in unsigned long aBytesRead
);
57 * Return the number of bytes allowed through this queue. This is
58 * the sum of all the values passed to recordRead. This method is
59 * primarily useful for testing.
61 unsigned long long bytesProcessed
();
64 * Wrap the given input stream in a new input stream which
65 * throttles the incoming data.
67 * @param aInputStream the input stream to wrap
68 * @return a new input stream that throttles the data.
70 nsIAsyncInputStream wrapStream
(in nsIInputStream aInputStream
);
74 * A throttled input channel can be managed by an
75 * nsIInputChannelThrottleQueue to limit how much data is sent during
78 [scriptable
, uuid(0a32a100
-c031
-45b6
-9e8b
-0444c7d4a143
)]
79 interface nsIThrottledInputChannel
: nsISupports
82 * The queue that manages this channel. Multiple channels can
83 * share a single queue. A null value means that no throttling
86 attribute nsIInputChannelThrottleQueue throttleQueue
;