2014-07-10 00:35:02 +04: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"
|
2017-08-03 11:50:00 +03:00
|
|
|
#include "nsIContentPolicy.idl"
|
2014-07-10 00:35:02 +04:00
|
|
|
|
2015-02-19 04:34:29 +03:00
|
|
|
interface nsIChannel;
|
2015-11-03 22:20:56 +03:00
|
|
|
interface nsIConsoleReportCollector;
|
2017-10-17 23:38:55 +03:00
|
|
|
interface nsIInputStream;
|
2014-07-10 00:35:02 +04:00
|
|
|
interface nsIOutputStream;
|
|
|
|
interface nsIURI;
|
|
|
|
|
2015-05-25 21:21:05 +03:00
|
|
|
%{C++
|
2015-10-30 05:53:25 +03:00
|
|
|
#include "nsIConsoleReportCollector.h"
|
2015-05-25 21:21:05 +03:00
|
|
|
namespace mozilla {
|
2017-04-10 16:13:21 +03:00
|
|
|
class TimeStamp;
|
|
|
|
|
2015-05-25 21:21:05 +03:00
|
|
|
namespace dom {
|
|
|
|
class ChannelInfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
|
2017-04-10 16:13:21 +03:00
|
|
|
native TimeStamp(mozilla::TimeStamp);
|
|
|
|
|
2015-05-25 21:21:05 +03:00
|
|
|
[ptr] native ChannelInfo(mozilla::dom::ChannelInfo);
|
|
|
|
|
2017-10-17 23:38:55 +03:00
|
|
|
/**
|
|
|
|
* Interface allowing the nsIInterceptedChannel to callback when it is
|
|
|
|
* done reading from the body stream.
|
|
|
|
*/
|
|
|
|
[scriptable, uuid(51039eb6-bea0-40c7-b523-ccab56cc4fde)]
|
|
|
|
interface nsIInterceptedBodyCallback : nsISupports
|
|
|
|
{
|
|
|
|
void bodyComplete(in nsresult aRv);
|
|
|
|
};
|
|
|
|
|
2014-07-10 00:35:02 +04:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2015-11-02 19:27:00 +03:00
|
|
|
[scriptable, uuid(f4b82975-6a86-4cc4-87fe-9a1fd430c86d)]
|
2014-07-10 00:35:02 +04:00
|
|
|
interface nsIInterceptedChannel : nsISupports
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Instruct a channel that has been intercepted to continue with the original
|
|
|
|
* network request.
|
|
|
|
*/
|
|
|
|
void resetInterception();
|
|
|
|
|
2015-03-17 18:48:30 +03:00
|
|
|
/**
|
|
|
|
* Set the status and reason for the forthcoming synthesized response.
|
|
|
|
* Multiple calls overwrite existing values.
|
|
|
|
*/
|
|
|
|
void synthesizeStatus(in uint16_t status, in ACString reason);
|
|
|
|
|
2014-07-10 00:35:02 +04:00
|
|
|
/**
|
|
|
|
* Attach a header name/value pair to the forthcoming synthesized response.
|
|
|
|
* Overwrites any existing header value.
|
|
|
|
*/
|
|
|
|
void synthesizeHeader(in ACString name, in ACString value);
|
|
|
|
|
|
|
|
/**
|
2017-10-17 23:38:54 +03:00
|
|
|
* Instruct a channel that has been intercepted that a response is
|
|
|
|
* starting to be synthesized. No further header modification is allowed
|
2017-10-17 23:38:55 +03:00
|
|
|
* after this point. There are a few parameters:
|
|
|
|
* - A body stream may be optionally passed. If nullptr, then an
|
|
|
|
* empty body is assumed.
|
|
|
|
* - A callback may be optionally passed. It will be invoked
|
|
|
|
* when the body is complete. For a nullptr body this may be
|
|
|
|
* synchronously on the current thread. Otherwise it will be invoked
|
|
|
|
* asynchronously on the current thread.
|
|
|
|
* - The caller may optionally pass a spec for a URL that this response
|
|
|
|
* originates from; an empty string will cause the original
|
|
|
|
* intercepted request's URL to be used instead.
|
2014-07-10 00:35:02 +04:00
|
|
|
*/
|
2017-10-17 23:38:55 +03:00
|
|
|
void startSynthesizedResponse(in nsIInputStream body,
|
|
|
|
in nsIInterceptedBodyCallback callback,
|
|
|
|
in ACString finalURLSpec);
|
2017-10-17 23:38:54 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Instruct a channel that has been intercepted that response synthesis
|
|
|
|
* has completed and all outstanding resources can be closed.
|
|
|
|
*/
|
|
|
|
void finishSynthesizedResponse();
|
2015-02-19 04:34:29 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2017-10-09 20:03:40 +03:00
|
|
|
void cancelInterception(in nsresult status);
|
2015-02-19 04:34:29 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The underlying channel object that was intercepted.
|
|
|
|
*/
|
|
|
|
readonly attribute nsIChannel channel;
|
|
|
|
|
2015-11-02 19:27:00 +03:00
|
|
|
/**
|
|
|
|
* The URL of the underlying channel object, corrected for a potential
|
|
|
|
* secure upgrade.
|
|
|
|
*/
|
|
|
|
readonly attribute nsIURI secureUpgradedChannelURI;
|
|
|
|
|
2015-03-05 02:27:33 +03:00
|
|
|
/**
|
2015-05-25 21:21:05 +03:00
|
|
|
* This method allows to override the channel info for the channel.
|
2015-03-05 02:27:33 +03:00
|
|
|
*/
|
2015-05-25 21:21:05 +03:00
|
|
|
[noscript]
|
|
|
|
void setChannelInfo(in ChannelInfo channelInfo);
|
2015-09-17 21:56:41 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the internal load type from the underlying channel.
|
|
|
|
*/
|
|
|
|
[noscript]
|
|
|
|
readonly attribute nsContentPolicyType internalContentPolicyType;
|
2015-10-30 05:53:25 +03:00
|
|
|
|
2015-11-03 22:20:56 +03:00
|
|
|
[noscript]
|
|
|
|
readonly attribute nsIConsoleReportCollector consoleReportCollector;
|
|
|
|
|
2017-04-10 16:13:21 +03:00
|
|
|
/**
|
|
|
|
* Save the timestamps of various service worker interception phases.
|
|
|
|
*/
|
|
|
|
[noscript]
|
|
|
|
void SetLaunchServiceWorkerStart(in TimeStamp aTimeStamp);
|
|
|
|
|
2017-08-17 13:32:36 +03:00
|
|
|
// A hack to get sw launch start time for telemetry.
|
|
|
|
[noscript]
|
|
|
|
void GetLaunchServiceWorkerStart(out TimeStamp aTimeStamp);
|
|
|
|
|
2017-04-10 16:13:21 +03:00
|
|
|
[noscript]
|
|
|
|
void SetLaunchServiceWorkerEnd(in TimeStamp aTimeStamp);
|
|
|
|
|
2017-08-17 13:32:36 +03:00
|
|
|
// A hack to get sw launch end time for telemetry.
|
|
|
|
[noscript]
|
|
|
|
void GetLaunchServiceWorkerEnd(out TimeStamp aTimeStamp);
|
|
|
|
|
2017-04-10 16:13:21 +03:00
|
|
|
[noscript]
|
|
|
|
void SetDispatchFetchEventStart(in TimeStamp aTimeStamp);
|
|
|
|
|
|
|
|
[noscript]
|
|
|
|
void SetDispatchFetchEventEnd(in TimeStamp aTimeStamp);
|
|
|
|
|
|
|
|
[noscript]
|
|
|
|
void SetHandleFetchEventStart(in TimeStamp aTimeStamp);
|
|
|
|
|
|
|
|
[noscript]
|
|
|
|
void SetHandleFetchEventEnd(in TimeStamp aTimeStamp);
|
|
|
|
|
2017-04-26 01:16:57 +03:00
|
|
|
// Depending on the outcome we measure the time difference between
|
|
|
|
// |FinishResponseStart| and either |FinishSynthesizedResponseEnd| or
|
|
|
|
// |ChannelResetEnd|.
|
2017-04-10 16:13:21 +03:00
|
|
|
[noscript]
|
2017-04-26 01:16:57 +03:00
|
|
|
void SetFinishResponseStart(in TimeStamp aTimeStamp);
|
|
|
|
|
|
|
|
[noscript]
|
|
|
|
void SetFinishSynthesizedResponseEnd(in TimeStamp aTimeStamp);
|
|
|
|
|
|
|
|
[noscript]
|
|
|
|
void SetChannelResetEnd(in TimeStamp aTimeStamp);
|
|
|
|
|
|
|
|
[noscript]
|
|
|
|
void SaveTimeStamps();
|
2017-04-10 16:13:21 +03:00
|
|
|
|
2015-10-30 05:53:25 +03:00
|
|
|
%{C++
|
2015-11-03 22:20:56 +03:00
|
|
|
already_AddRefed<nsIConsoleReportCollector>
|
|
|
|
GetConsoleReportCollector()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIConsoleReportCollector> reporter;
|
|
|
|
GetConsoleReportCollector(getter_AddRefs(reporter));
|
|
|
|
return reporter.forget();
|
|
|
|
}
|
2015-10-30 05:53:25 +03:00
|
|
|
%}
|
2015-11-16 19:04:11 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allow the ServiceWorkerManager to set an RAII-style object on the
|
|
|
|
* intercepted channel that should be released once the channel is
|
|
|
|
* torn down.
|
|
|
|
*/
|
|
|
|
[noscript]
|
|
|
|
void setReleaseHandle(in nsISupports aHandle);
|
2014-07-10 00:35:02 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2016-01-05 01:40:04 +03:00
|
|
|
[scriptable, uuid(70d2b4fe-a552-48cd-8d93-1d8437a56b53)]
|
2014-07-10 00:35:02 +04:00
|
|
|
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
|
2015-02-19 04:34:29 +03:00
|
|
|
* @param aIsNavigate True if the request is for a navigation, false for a fetch.
|
2014-07-10 00:35:02 +04:00
|
|
|
*/
|
2015-10-07 05:40:36 +03:00
|
|
|
bool shouldPrepareForIntercept(in nsIURI aURI, in bool aIsNonSubresourceRequest);
|
2014-07-10 00:35:02 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2016-01-05 01:40:04 +03:00
|
|
|
void channelIntercepted(in nsIInterceptedChannel aChannel);
|
2014-07-10 00:35:02 +04:00
|
|
|
};
|