Bug 1729952 [wpt PR 30477] - Fix timeout in grid-positioned-item-dynamic-change-006...
[gecko.git] / netwerk / base / nsIRequestContext.idl
blob6c9f265af232b9bf72597a95dc5110493cb68644
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 %{C++
9 // Forward-declare mozilla::net::SpdyPushCache
10 namespace mozilla {
11 namespace net {
12 class SpdyPushCache;
17 interface nsILoadGroup;
18 interface nsIChannel;
19 interface nsIStreamListener;
21 [ptr] native SpdyPushCachePtr(mozilla::net::SpdyPushCache);
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.
29 [uuid(7EB361D4-37A5-42C9-AFAE-F6C88FE7C394)]
30 interface nsIRequestTailUnblockCallback : nsISupports
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.
40 void onTailUnblock(in nsresult aResult);
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.
49 * This used to be known as nsILoadGroupConnectionInfo and nsISchedulingContext.
51 [uuid(658e3e6e-8633-4b1a-8d66-fa9f72293e63)]
52 interface nsIRequestContext : nsISupports
54 /**
55 * A unique identifier for this request context
57 [notxpcom, nostdcall] readonly attribute unsigned long long ID;
59 /**
60 * Called by the associated document when its load starts. This resets
61 * context's internal states.
63 void beginLoad();
65 /**
66 * Called when the associated document notified the DOMContentLoaded event.
68 void DOMContentLoaded();
70 /**
71 * Number of active blocking transactions associated with this context
73 readonly attribute unsigned long blockingTransactionCount;
75 /**
76 * Increase the number of active blocking transactions associated
77 * with this context by one.
79 void addBlockingTransaction();
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.
86 unsigned long removeBlockingTransaction();
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.
94 [notxpcom,nostdcall] attribute SpdyPushCachePtr spdyPushCache;
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.
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
121 * it's canceled.
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);