Source code

Revision control

Other Tools

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/. */
5
6
#include "nsISupports.idl"
7
8
interface nsIInputStream;
9
interface nsIAsyncInputStream;
10
11
/**
12
* An instance of this interface can be used to throttle the uploads
13
* of a group of associated channels.
14
*/
15
[scriptable, uuid(6b4b96fe-3c67-4587-af7b-58b6b17da411)]
16
interface nsIInputChannelThrottleQueue : nsISupports
17
{
18
/**
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.
22
*
23
* @param aMeanBytesPerSecond
24
* Mean number of bytes per second.
25
* @param aMaxBytesPerSecond
26
* Maximum number of bytes per second.
27
*/
28
void init(in unsigned long aMeanBytesPerSecond, in unsigned long aMaxBytesPerSecond);
29
30
/**
31
* Return the number of bytes that are available to the caller in
32
* this time slice.
33
*
34
* @param aRemaining
35
* The number of bytes available to be processed
36
* @return the number of bytes allowed to be processed during this
37
* time slice; this will never be greater than aRemaining.
38
*/
39
unsigned long available(in unsigned long aRemaining);
40
41
/**
42
* Record a successful read.
43
*
44
* @param aBytesRead
45
* The number of bytes actually read.
46
*/
47
void recordRead(in unsigned long aBytesRead);
48
49
/**
50
* Return the number of bytes allowed through this queue. This is
51
* the sum of all the values passed to recordRead. This method is
52
* primarily useful for testing.
53
*/
54
unsigned long long bytesProcessed();
55
56
/**
57
* Wrap the given input stream in a new input stream which
58
* throttles the incoming data.
59
*
60
* @param aInputStream the input stream to wrap
61
* @return a new input stream that throttles the data.
62
*/
63
nsIAsyncInputStream wrapStream(in nsIInputStream aInputStream);
64
};
65
66
/**
67
* A throttled input channel can be managed by an
68
* nsIInputChannelThrottleQueue to limit how much data is sent during
69
* a given time slice.
70
*/
71
[scriptable, uuid(0a32a100-c031-45b6-9e8b-0444c7d4a143)]
72
interface nsIThrottledInputChannel : nsISupports
73
{
74
/**
75
* The queue that manages this channel. Multiple channels can
76
* share a single queue. A null value means that no throttling
77
* will be done.
78
*/
79
attribute nsIInputChannelThrottleQueue throttleQueue;
80
};