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
%{C++
9
// Forward-declare mozilla::net::SpdyPushCache
10
namespace mozilla {
11
namespace net {
12
class SpdyPushCache;
13
}
14
}
15
%}
16
17
interface nsILoadGroup;
18
interface nsIChannel;
19
interface nsIStreamListener;
20
21
[ptr] native SpdyPushCachePtr(mozilla::net::SpdyPushCache);
22
23
/**
24
* Requests capable of tail-blocking must implement this
25
* interfaces (typically channels).
26
* If the request is tail-blocked, it will be held in its request
27
* context queue until unblocked.
28
*/
29
[uuid(7EB361D4-37A5-42C9-AFAE-F6C88FE7C394)]
30
interface nsIRequestTailUnblockCallback : nsISupports
31
{
32
/**
33
* Called when the requests is unblocked and proceed.
34
* @param result
35
* NS_OK - the request is OK to go, unblocking is not
36
* caused by cancelation of the request.
37
* any error - the request must behave as it were canceled
38
* with the result as status.
39
*/
40
void onTailUnblock(in nsresult aResult);
41
};
42
43
/**
44
* The nsIRequestContext is used to maintain state about connections
45
* that are in some way associated with each other (often by being part
46
* of the same load group) and how they interact with blocking items like
47
* HEAD css/js loads.
48
*
49
* This used to be known as nsILoadGroupConnectionInfo and nsISchedulingContext.
50
*/
51
[uuid(658e3e6e-8633-4b1a-8d66-fa9f72293e63)]
52
interface nsIRequestContext : nsISupports
53
{
54
/**
55
* A unique identifier for this request context
56
*/
57
[notxpcom, nostdcall] readonly attribute unsigned long long ID;
58
59
/**
60
* Called by the associated document when its load starts. This resets
61
* context's internal states.
62
*/
63
void beginLoad();
64
65
/**
66
* Called when the associated document notified the DOMContentLoaded event.
67
*/
68
void DOMContentLoaded();
69
70
/**
71
* Number of active blocking transactions associated with this context
72
*/
73
readonly attribute unsigned long blockingTransactionCount;
74
75
/**
76
* Increase the number of active blocking transactions associated
77
* with this context by one.
78
*/
79
void addBlockingTransaction();
80
81
/**
82
* Decrease the number of active blocking transactions associated
83
* with this context by one. The return value is the number of remaining
84
* blockers.
85
*/
86
unsigned long removeBlockingTransaction();
87
88
/**
89
* This gives out a weak pointer to the push cache.
90
* The nsIRequestContext implementation owns the cache
91
* and will destroy it when overwritten or when the context
92
* ends.
93
*/
94
[notxpcom,nostdcall] attribute SpdyPushCachePtr spdyPushCache;
95
96
/**
97
* Increases/decrease the number of non-tailed requests in this context.
98
* If the count drops to zero, all tail-blocked callbacks are notified
99
* shortly after that to be unblocked.
100
*/
101
void addNonTailRequest();
102
void removeNonTailRequest();
103
104
/**
105
* If the request context is in tail-blocked state, the callback
106
* is queued and result is true. The callback will be notified
107
* about tail-unblocking or when the request context is canceled.
108
*/
109
[must_use] boolean isContextTailBlocked(in nsIRequestTailUnblockCallback callback);
110
111
/**
112
* Called when the request is sitting in the tail queue but has been
113
* canceled before untailing. This just removes the request from the
114
* queue so that it is not notified on untail and not referenced.
115
*/
116
void cancelTailedRequest(in nsIRequestTailUnblockCallback request);
117
118
/**
119
* This notifies all queued tail-blocked requests, they will be notified
120
* aResult and released afterwards. Called by the load group when
121
* it's canceled.
122
*/
123
void cancelTailPendingRequests(in nsresult aResult);
124
};
125
126
/**
127
* The nsIRequestContextService is how anyone gets access to a request
128
* context when they haven't been explicitly given a strong reference to an
129
* existing one. It is responsible for creating and handing out strong
130
* references to nsIRequestContexts, but only keeps weak references itself.
131
* The shared request context will go away once no one else is keeping a
132
* reference to it. If you ask for a request context that has no one else
133
* holding a reference to it, you'll get a brand new request context. Anyone
134
* who asks for the same request context while you're holding a reference
135
* will get a reference to the same request context you have.
136
*/
137
[uuid(7fcbf4da-d828-4acc-b144-e5435198f727)]
138
interface nsIRequestContextService : nsISupports
139
{
140
/**
141
* Get an existing request context from its ID
142
*/
143
nsIRequestContext getRequestContext(in unsigned long long id);
144
/**
145
* Shorthand to get request context from a load group
146
*/
147
nsIRequestContext getRequestContextFromLoadGroup(in nsILoadGroup lg);
148
149
/**
150
* Create a new request context
151
*/
152
nsIRequestContext newRequestContext();
153
154
/**
155
* Remove an existing request context from its ID
156
*/
157
void removeRequestContext(in unsigned long long id);
158
};