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"
9 // Forward-declare mozilla::net::SpdyPushCache
17 interface nsILoadGroup
;
19 interface nsIStreamListener
;
21 [ptr] native SpdyPushCachePtr
(mozilla
::net
::SpdyPushCache
);
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.
29 [uuid(7EB361D4
-37A5
-42C9
-AFAE
-F6C88FE7C394
)]
30 interface nsIRequestTailUnblockCallback
: nsISupports
33 * Called when the requests is unblocked and proceed.
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.
40 void onTailUnblock
(in nsresult aResult
);
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
49 * This used to be known as nsILoadGroupConnectionInfo and nsISchedulingContext.
51 [uuid(658e3e6e
-8633
-4b1a
-8d66
-fa9f72293e63
)]
52 interface nsIRequestContext
: nsISupports
55 * A unique identifier for this request context
57 [notxpcom
, nostdcall
] readonly attribute
unsigned long long ID;
60 * Called by the associated document when its load starts. This resets
61 * context's internal states.
66 * Called when the associated document notified the DOMContentLoaded event.
68 void DOMContentLoaded
();
71 * Number of active blocking transactions associated with this context
73 readonly attribute
unsigned long blockingTransactionCount
;
76 * Increase the number of active blocking transactions associated
77 * with this context by one.
79 void addBlockingTransaction
();
82 * Decrease the number of active blocking transactions associated
83 * with this context by one. The return value is the number of remaining
86 unsigned long removeBlockingTransaction
();
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
94 [notxpcom
,nostdcall
] attribute SpdyPushCachePtr spdyPushCache
;
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.
101 void addNonTailRequest
();
102 void removeNonTailRequest
();
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.
109 [must_use
] boolean isContextTailBlocked
(in nsIRequestTailUnblockCallback
callback);
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.
116 void cancelTailedRequest
(in nsIRequestTailUnblockCallback request
);
119 * This notifies all queued tail-blocked requests, they will be notified
120 * aResult and released afterwards. Called by the load group when
123 void cancelTailPendingRequests
(in nsresult aResult
);
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.
137 [uuid(7fcbf4da
-d828
-4acc
-b144
-e5435198f727
)]
138 interface nsIRequestContextService
: nsISupports
141 * Get an existing request context from its ID
143 nsIRequestContext getRequestContext
(in unsigned long long id);
145 * Shorthand to get request context from a load group
147 nsIRequestContext getRequestContextFromLoadGroup
(in nsILoadGroup lg
);
150 * Create a new request context
152 nsIRequestContext newRequestContext
();
155 * Remove an existing request context from its ID
157 void removeRequestContext
(in unsigned long long id);