mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-26 03:35:33 +00:00
5d40efa578
This refactoring patch separates the preparation of the fetch event object from its dispatching, so that consumers would be able to dispatch the event asynchronously.
135 lines
4.1 KiB
Plaintext
135 lines
4.1 KiB
Plaintext
/* -*- 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"
|
|
#include "nsIContentPolicyBase.idl"
|
|
|
|
interface nsIChannel;
|
|
interface nsIOutputStream;
|
|
interface nsIURI;
|
|
|
|
%{C++
|
|
namespace mozilla {
|
|
namespace dom {
|
|
class ChannelInfo;
|
|
}
|
|
}
|
|
%}
|
|
|
|
[ptr] native ChannelInfo(mozilla::dom::ChannelInfo);
|
|
|
|
/**
|
|
* Interface to allow implementors of nsINetworkInterceptController to control the behaviour
|
|
* of intercepted channels without tying implementation details of the interception to
|
|
* the actual channel. nsIInterceptedChannel is expected to be implemented by objects
|
|
* which do not implement nsIChannel.
|
|
*/
|
|
|
|
[scriptable, uuid(91d430cc-7e04-4df1-a3c0-879fa30f7ab9)]
|
|
interface nsIInterceptedChannel : nsISupports
|
|
{
|
|
/**
|
|
* Instruct a channel that has been intercepted to continue with the original
|
|
* network request.
|
|
*/
|
|
void resetInterception();
|
|
|
|
/**
|
|
* Set the status and reason for the forthcoming synthesized response.
|
|
* Multiple calls overwrite existing values.
|
|
*/
|
|
void synthesizeStatus(in uint16_t status, in ACString reason);
|
|
|
|
/**
|
|
* Attach a header name/value pair to the forthcoming synthesized response.
|
|
* Overwrites any existing header value.
|
|
*/
|
|
void synthesizeHeader(in ACString name, in ACString value);
|
|
|
|
/**
|
|
* Instruct a channel that has been intercepted that a response has been
|
|
* synthesized and can now be read. No further header modification is allowed
|
|
* after this point.
|
|
*/
|
|
void finishSynthesizedResponse();
|
|
|
|
/**
|
|
* Cancel the pending intercepted request.
|
|
* @return NS_ERROR_FAILURE if the response has already been synthesized or
|
|
* the original request has been instructed to continue.
|
|
*/
|
|
void cancel(in nsresult status);
|
|
|
|
/**
|
|
* The synthesized response body to be produced.
|
|
*/
|
|
readonly attribute nsIOutputStream responseBody;
|
|
|
|
/**
|
|
* The underlying channel object that was intercepted.
|
|
*/
|
|
readonly attribute nsIChannel channel;
|
|
|
|
/**
|
|
* True if the underlying request was caused by a navigation attempt.
|
|
*/
|
|
readonly attribute bool isNavigation;
|
|
|
|
/**
|
|
* This method allows to override the channel info for the channel.
|
|
*/
|
|
[noscript]
|
|
void setChannelInfo(in ChannelInfo channelInfo);
|
|
|
|
/**
|
|
* Get the internal load type from the underlying channel.
|
|
*/
|
|
[noscript]
|
|
readonly attribute nsContentPolicyType internalContentPolicyType;
|
|
};
|
|
|
|
/**
|
|
* Interface to allow consumers to dispatch the fetch event asynchronously.
|
|
* Consumers get access to this interface by calling channelIntercepted(),
|
|
* and they can choose to either dispatch() immediately or do that at some
|
|
* later time.
|
|
*/
|
|
|
|
[scriptable, uuid(799504e4-36f8-4ab5-b9d2-53f0c0c40c04)]
|
|
interface nsIFetchEventDispatcher : nsISupports
|
|
{
|
|
/**
|
|
* Actually dispatches the fetch event to the service worker.
|
|
*/
|
|
void dispatch();
|
|
};
|
|
|
|
/**
|
|
* Interface to allow consumers to attach themselves to a channel's
|
|
* notification callbacks/loadgroup and determine if a given channel
|
|
* request should be intercepted before any network request is initiated.
|
|
*/
|
|
|
|
[scriptable, uuid(7157fe12-20e3-45db-b09e-68fdf6d0614f)]
|
|
interface nsINetworkInterceptController : nsISupports
|
|
{
|
|
/**
|
|
* Returns true if a channel should avoid initiating any network
|
|
* requests until specifically instructed to do so.
|
|
*
|
|
* @param aURI the URI being requested by a channel
|
|
* @param aIsNavigate True if the request is for a navigation, false for a fetch.
|
|
*/
|
|
bool shouldPrepareForIntercept(in nsIURI aURI, in bool aIsNavigate, in nsContentPolicyType aType);
|
|
|
|
/**
|
|
* Notification when a given intercepted channel is prepared to accept a synthesized
|
|
* response via the provided stream.
|
|
*
|
|
* @param aChannel the controlling interface for a channel that has been intercepted
|
|
*/
|
|
nsIFetchEventDispatcher channelIntercepted(in nsIInterceptedChannel aChannel);
|
|
};
|