2015-07-31 20:50:08 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
|
|
|
%{C++
|
|
|
|
// Forward-declare mozilla::net::SpdyPushCache
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
class SpdyPushCache;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
|
2017-08-30 13:32:00 +00:00
|
|
|
interface nsILoadGroup;
|
|
|
|
interface nsIChannel;
|
|
|
|
interface nsIStreamListener;
|
|
|
|
|
2015-07-31 20:50:08 +00:00
|
|
|
[ptr] native SpdyPushCachePtr(mozilla::net::SpdyPushCache);
|
|
|
|
|
2017-08-30 13:32:00 +00:00
|
|
|
/**
|
|
|
|
* Requests capable of tail-blocking must implement this
|
|
|
|
* interfaces (typically channels).
|
|
|
|
* If the request is tail-blocked, it will be held in its request
|
|
|
|
* context queue until unblocked.
|
|
|
|
*/
|
|
|
|
[scriptable, uuid(7EB361D4-37A5-42C9-AFAE-F6C88FE7C394)]
|
|
|
|
interface nsIRequestTailUnblockCallback : nsISupports
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Called when the requests is unblocked and proceed.
|
|
|
|
* @param result
|
|
|
|
* NS_OK - the request is OK to go, unblocking is not
|
|
|
|
* caused by cancelation of the request.
|
|
|
|
* any error - the request must behave as it were canceled
|
|
|
|
* with the result as status.
|
|
|
|
*/
|
|
|
|
void onTailUnblock(in nsresult aResult);
|
|
|
|
};
|
|
|
|
|
2015-07-31 20:50:08 +00:00
|
|
|
/**
|
2016-04-21 14:59:17 +00:00
|
|
|
* The nsIRequestContext is used to maintain state about connections
|
2015-07-31 20:50:08 +00:00
|
|
|
* that are in some way associated with each other (often by being part
|
|
|
|
* of the same load group) and how they interact with blocking items like
|
|
|
|
* HEAD css/js loads.
|
|
|
|
*
|
2016-04-21 14:59:17 +00:00
|
|
|
* This used to be known as nsILoadGroupConnectionInfo and nsISchedulingContext.
|
2015-07-31 20:50:08 +00:00
|
|
|
*/
|
|
|
|
[scriptable, uuid(658e3e6e-8633-4b1a-8d66-fa9f72293e63)]
|
2016-04-21 14:59:17 +00:00
|
|
|
interface nsIRequestContext : nsISupports
|
2015-07-31 20:50:08 +00:00
|
|
|
{
|
|
|
|
/**
|
2016-04-21 14:59:17 +00:00
|
|
|
* A unique identifier for this request context
|
2015-07-31 20:50:08 +00:00
|
|
|
*/
|
2017-03-23 14:40:36 +00:00
|
|
|
[noscript] readonly attribute unsigned long long ID;
|
2015-07-31 20:50:08 +00:00
|
|
|
|
2017-08-30 13:32:00 +00:00
|
|
|
/**
|
|
|
|
* Called by the associated document when its load starts. This resets
|
|
|
|
* context's internal states.
|
|
|
|
*/
|
|
|
|
void beginLoad();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the associated document notified the DOMContentLoaded event.
|
|
|
|
*/
|
|
|
|
void DOMContentLoaded();
|
|
|
|
|
2015-07-31 20:50:08 +00:00
|
|
|
/**
|
|
|
|
* Number of active blocking transactions associated with this context
|
|
|
|
*/
|
|
|
|
readonly attribute unsigned long blockingTransactionCount;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Increase the number of active blocking transactions associated
|
|
|
|
* with this context by one.
|
|
|
|
*/
|
|
|
|
void addBlockingTransaction();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Decrease the number of active blocking transactions associated
|
|
|
|
* with this context by one. The return value is the number of remaining
|
|
|
|
* blockers.
|
|
|
|
*/
|
|
|
|
unsigned long removeBlockingTransaction();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This gives out a weak pointer to the push cache.
|
2016-04-21 14:59:17 +00:00
|
|
|
* The nsIRequestContext implementation owns the cache
|
2015-07-31 20:50:08 +00:00
|
|
|
* and will destroy it when overwritten or when the context
|
|
|
|
* ends.
|
|
|
|
*/
|
|
|
|
[noscript] attribute SpdyPushCachePtr spdyPushCache;
|
2016-04-21 14:59:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This holds a cached value of the user agent override.
|
|
|
|
*/
|
|
|
|
[noscript] attribute ACString userAgentOverride;
|
2017-08-30 13:32:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Increases/decrease the number of non-tailed requests in this context.
|
|
|
|
* If the count drops to zero, all tail-blocked callbacks are notified
|
|
|
|
* shortly after that to be unblocked.
|
|
|
|
*/
|
|
|
|
void addNonTailRequest();
|
|
|
|
void removeNonTailRequest();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If the request context is in tail-blocked state, the callback
|
|
|
|
* is queued and result is true. The callback will be notified
|
|
|
|
* about tail-unblocking or when the request context is canceled.
|
|
|
|
*/
|
|
|
|
[must_use] boolean isContextTailBlocked(in nsIRequestTailUnblockCallback callback);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the request is sitting in the tail queue but has been
|
|
|
|
* canceled before untailing. This just removes the request from the
|
|
|
|
* queue so that it is not notified on untail and not referenced.
|
|
|
|
*/
|
|
|
|
void cancelTailedRequest(in nsIRequestTailUnblockCallback request);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This notifies all queued tail-blocked requests, they will be notified
|
|
|
|
* aResult and released afterwards. Called by the load group when
|
|
|
|
* it's canceled.
|
|
|
|
*/
|
|
|
|
void cancelTailPendingRequests(in nsresult aResult);
|
2015-07-31 20:50:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2016-04-21 14:59:17 +00:00
|
|
|
* The nsIRequestContextService is how anyone gets access to a request
|
2015-07-31 20:50:08 +00:00
|
|
|
* context when they haven't been explicitly given a strong reference to an
|
|
|
|
* existing one. It is responsible for creating and handing out strong
|
2016-04-21 14:59:17 +00:00
|
|
|
* references to nsIRequestContexts, but only keeps weak references itself.
|
|
|
|
* The shared request context will go away once no one else is keeping a
|
|
|
|
* reference to it. If you ask for a request context that has no one else
|
|
|
|
* holding a reference to it, you'll get a brand new request context. Anyone
|
|
|
|
* who asks for the same request context while you're holding a reference
|
|
|
|
* will get a reference to the same request context you have.
|
2015-07-31 20:50:08 +00:00
|
|
|
*/
|
|
|
|
[uuid(7fcbf4da-d828-4acc-b144-e5435198f727)]
|
2016-04-21 14:59:17 +00:00
|
|
|
interface nsIRequestContextService : nsISupports
|
2015-07-31 20:50:08 +00:00
|
|
|
{
|
|
|
|
/**
|
2016-04-21 14:59:17 +00:00
|
|
|
* Get an existing request context from its ID
|
2015-07-31 20:50:08 +00:00
|
|
|
*/
|
2017-03-23 14:40:36 +00:00
|
|
|
nsIRequestContext getRequestContext(in unsigned long long id);
|
2017-08-30 13:32:00 +00:00
|
|
|
/**
|
|
|
|
* Shorthand to get request context from a load group
|
|
|
|
*/
|
|
|
|
nsIRequestContext getRequestContextFromLoadGroup(in nsILoadGroup lg);
|
2015-07-31 20:50:08 +00:00
|
|
|
|
|
|
|
/**
|
2017-03-15 04:10:10 +00:00
|
|
|
* Create a new request context
|
2015-07-31 20:50:08 +00:00
|
|
|
*/
|
2017-03-15 04:10:10 +00:00
|
|
|
nsIRequestContext newRequestContext();
|
2015-07-31 20:50:08 +00:00
|
|
|
|
|
|
|
/**
|
2016-04-21 14:59:17 +00:00
|
|
|
* Remove an existing request context from its ID
|
2015-07-31 20:50:08 +00:00
|
|
|
*/
|
2017-03-23 14:40:36 +00:00
|
|
|
void removeRequestContext(in unsigned long long id);
|
2015-07-31 20:50:08 +00:00
|
|
|
};
|