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
* This holds a cached value of the user agent override.
98
*/
99
[notxpcom,nostdcall] attribute ACString userAgentOverride;
100
101
/**
102
* Increases/decrease the number of non-tailed requests in this context.
103
* If the count drops to zero, all tail-blocked callbacks are notified
104
* shortly after that to be unblocked.
105
*/
106
void addNonTailRequest();
107
void removeNonTailRequest();
108
109
/**
110
* If the request context is in tail-blocked state, the callback
111
* is queued and result is true. The callback will be notified
112
* about tail-unblocking or when the request context is canceled.
113
*/
114
[must_use] boolean isContextTailBlocked(in nsIRequestTailUnblockCallback callback);
115
116
/**
117
* Called when the request is sitting in the tail queue but has been
118
* canceled before untailing. This just removes the request from the
119
* queue so that it is not notified on untail and not referenced.
120
*/
121
void cancelTailedRequest(in nsIRequestTailUnblockCallback request);
122
123
/**
124
* This notifies all queued tail-blocked requests, they will be notified
125
* aResult and released afterwards. Called by the load group when
126
* it's canceled.
127
*/
128
void cancelTailPendingRequests(in nsresult aResult);
129
};
130
131
/**
132
* The nsIRequestContextService is how anyone gets access to a request
133
* context when they haven't been explicitly given a strong reference to an
134
* existing one. It is responsible for creating and handing out strong
135
* references to nsIRequestContexts, but only keeps weak references itself.
136
* The shared request context will go away once no one else is keeping a
137
* reference to it. If you ask for a request context that has no one else
138
* holding a reference to it, you'll get a brand new request context. Anyone
139
* who asks for the same request context while you're holding a reference
140
* will get a reference to the same request context you have.
141
*/
142
[uuid(7fcbf4da-d828-4acc-b144-e5435198f727)]
143
interface nsIRequestContextService : nsISupports
144
{
145
/**
146
* Get an existing request context from its ID
147
*/
148
nsIRequestContext getRequestContext(in unsigned long long id);
149
/**
150
* Shorthand to get request context from a load group
151
*/
152
nsIRequestContext getRequestContextFromLoadGroup(in nsILoadGroup lg);
153
154
/**
155
* Create a new request context
156
*/
157
nsIRequestContext newRequestContext();
158
159
/**
160
* Remove an existing request context from its ID
161
*/
162
void removeRequestContext(in unsigned long long id);
163
};