2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2010-06-24 10:55:19 +04:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
2019-03-05 04:35:41 +03:00
|
|
|
interface nsIAsyncOutputStream;
|
2018-10-17 15:27:37 +03:00
|
|
|
interface nsIInputStream;
|
2018-10-17 15:27:37 +03:00
|
|
|
|
Bug 1487100 - Allow calling nsICacheInfoChannel.preferAlternativeDataType(altDataType, contentType) multiple times r=michal,luke
This patch changes the way we set and handle the preferred alternate data type.
It is no longer just one choice, but a set of preferences, each conditional
on the contentType of the resource.
For example:
var cc = chan.QueryInterface(Ci.nsICacheInfoChannel);
cc.preferAlternativeDataType("js-bytecode", "text/javascript");
cc.preferAlternativeDataType("ammended-text", "text/plain");
cc.preferAlternativeDataType("something-else", "");
When loaded from the cache, the available alt-data type will be checked against
"js-bytecode" if the contentType is "text/javascript", "ammended-text" if the contentType is "text/plain" or "something-else" for all contentTypes.
Note that the alt-data type could be "something-else" even if the contentType is "text/javascript".
The preferences are saved as an nsTArray<mozilla::Tuple<nsCString, nsCString>>.
Differential Revision: https://phabricator.services.mozilla.com/D8071
--HG--
extra : rebase_source : eb4961f05a52e557e7d2d986d59e0a2cf18a3447
extra : source : dd1c31ea78c2b15d14750d137037a54d50719997
2018-10-17 16:58:30 +03:00
|
|
|
%{C++
|
2020-10-21 11:00:18 +03:00
|
|
|
#include "nsTArray.h"
|
Bug 1487100 - Allow calling nsICacheInfoChannel.preferAlternativeDataType(altDataType, contentType) multiple times r=michal,luke
This patch changes the way we set and handle the preferred alternate data type.
It is no longer just one choice, but a set of preferences, each conditional
on the contentType of the resource.
For example:
var cc = chan.QueryInterface(Ci.nsICacheInfoChannel);
cc.preferAlternativeDataType("js-bytecode", "text/javascript");
cc.preferAlternativeDataType("ammended-text", "text/plain");
cc.preferAlternativeDataType("something-else", "");
When loaded from the cache, the available alt-data type will be checked against
"js-bytecode" if the contentType is "text/javascript", "ammended-text" if the contentType is "text/plain" or "something-else" for all contentTypes.
Note that the alt-data type could be "something-else" even if the contentType is "text/javascript".
The preferences are saved as an nsTArray<mozilla::Tuple<nsCString, nsCString>>.
Differential Revision: https://phabricator.services.mozilla.com/D8071
--HG--
extra : rebase_source : eb4961f05a52e557e7d2d986d59e0a2cf18a3447
extra : source : dd1c31ea78c2b15d14750d137037a54d50719997
2018-10-17 16:58:30 +03:00
|
|
|
namespace mozilla {
|
2019-02-20 13:05:42 +03:00
|
|
|
namespace net {
|
|
|
|
class PreferredAlternativeDataTypeParams;
|
|
|
|
}
|
Bug 1487100 - Allow calling nsICacheInfoChannel.preferAlternativeDataType(altDataType, contentType) multiple times r=michal,luke
This patch changes the way we set and handle the preferred alternate data type.
It is no longer just one choice, but a set of preferences, each conditional
on the contentType of the resource.
For example:
var cc = chan.QueryInterface(Ci.nsICacheInfoChannel);
cc.preferAlternativeDataType("js-bytecode", "text/javascript");
cc.preferAlternativeDataType("ammended-text", "text/plain");
cc.preferAlternativeDataType("something-else", "");
When loaded from the cache, the available alt-data type will be checked against
"js-bytecode" if the contentType is "text/javascript", "ammended-text" if the contentType is "text/plain" or "something-else" for all contentTypes.
Note that the alt-data type could be "something-else" even if the contentType is "text/javascript".
The preferences are saved as an nsTArray<mozilla::Tuple<nsCString, nsCString>>.
Differential Revision: https://phabricator.services.mozilla.com/D8071
--HG--
extra : rebase_source : eb4961f05a52e557e7d2d986d59e0a2cf18a3447
extra : source : dd1c31ea78c2b15d14750d137037a54d50719997
2018-10-17 16:58:30 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
%}
|
|
|
|
|
2019-02-20 13:05:42 +03:00
|
|
|
[ref] native ConstPreferredAlternativeDataTypeArray(const nsTArray<mozilla::net::PreferredAlternativeDataTypeParams>);
|
Bug 1487100 - Allow calling nsICacheInfoChannel.preferAlternativeDataType(altDataType, contentType) multiple times r=michal,luke
This patch changes the way we set and handle the preferred alternate data type.
It is no longer just one choice, but a set of preferences, each conditional
on the contentType of the resource.
For example:
var cc = chan.QueryInterface(Ci.nsICacheInfoChannel);
cc.preferAlternativeDataType("js-bytecode", "text/javascript");
cc.preferAlternativeDataType("ammended-text", "text/plain");
cc.preferAlternativeDataType("something-else", "");
When loaded from the cache, the available alt-data type will be checked against
"js-bytecode" if the contentType is "text/javascript", "ammended-text" if the contentType is "text/plain" or "something-else" for all contentTypes.
Note that the alt-data type could be "something-else" even if the contentType is "text/javascript".
The preferences are saved as an nsTArray<mozilla::Tuple<nsCString, nsCString>>.
Differential Revision: https://phabricator.services.mozilla.com/D8071
--HG--
extra : rebase_source : eb4961f05a52e557e7d2d986d59e0a2cf18a3447
extra : source : dd1c31ea78c2b15d14750d137037a54d50719997
2018-10-17 16:58:30 +03:00
|
|
|
|
2018-10-17 15:27:37 +03:00
|
|
|
[scriptable, uuid(1fb8ccf2-5fa5-45ec-bc57-8c8022a5d0d3)]
|
|
|
|
interface nsIInputStreamReceiver : nsISupports
|
|
|
|
{
|
|
|
|
void onInputStreamReady(in nsIInputStream aStream);
|
|
|
|
};
|
|
|
|
|
2019-05-13 22:51:49 +03:00
|
|
|
[scriptable, builtinclass, uuid(72c34415-c6eb-48af-851f-772fa9ee5972)]
|
2010-06-24 10:55:19 +04:00
|
|
|
interface nsICacheInfoChannel : nsISupports
|
|
|
|
{
|
2017-06-05 15:06:19 +03:00
|
|
|
/**
|
|
|
|
* Get the number of times the cache entry has been opened. This attribute is
|
|
|
|
* equivalent to nsICachingChannel.cacheToken.fetchCount.
|
|
|
|
*
|
|
|
|
* @throws NS_ERROR_NOT_AVAILABLE if the cache entry or the alternate data
|
|
|
|
* cache entry cannot be read.
|
|
|
|
*/
|
2022-08-04 19:20:17 +03:00
|
|
|
readonly attribute uint32_t cacheTokenFetchCount;
|
2017-06-05 15:06:19 +03:00
|
|
|
|
2010-06-24 10:55:19 +04:00
|
|
|
/**
|
|
|
|
* Get expiration time from cache token. This attribute is equivalent to
|
|
|
|
* nsICachingChannel.cacheToken.expirationTime.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
readonly attribute uint32_t cacheTokenExpirationTime;
|
2010-06-24 10:55:19 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TRUE if this channel's data is being loaded from the cache. This value
|
|
|
|
* is undefined before the channel fires its OnStartRequest notification
|
|
|
|
* and after the channel fires its OnStopRequest notification.
|
|
|
|
*/
|
|
|
|
boolean isFromCache();
|
2015-05-10 03:26:39 +03:00
|
|
|
|
2019-04-15 05:52:00 +03:00
|
|
|
/**
|
|
|
|
* Returns true if the channel raced the cache and network requests.
|
|
|
|
* In order to determine if the response is coming from the cache or the
|
|
|
|
* network, the consumer can check isFromCache().
|
|
|
|
* The method can only be called after the channel fires its OnStartRequest
|
|
|
|
* notification.
|
|
|
|
*/
|
|
|
|
boolean isRacing();
|
|
|
|
|
2017-10-12 09:25:00 +03:00
|
|
|
/**
|
|
|
|
* The unique ID of the corresponding nsICacheEntry from which the response is
|
|
|
|
* retrieved. By comparing the returned value, we can judge whether the data
|
|
|
|
* of two distinct nsICacheInfoChannels is from the same nsICacheEntry. This
|
|
|
|
* scenario could be useful when verifying whether the alternative data from
|
|
|
|
* one nsICacheInfochannel matches the main data from another one.
|
|
|
|
*
|
|
|
|
* Note: NS_ERROR_NOT_AVAILABLE is thrown when a nsICacheInfoChannel has no
|
|
|
|
* valid corresponding nsICacheEntry.
|
|
|
|
*/
|
|
|
|
uint64_t getCacheEntryId();
|
|
|
|
|
2015-05-10 03:26:39 +03:00
|
|
|
/**
|
2018-03-06 06:19:42 +03:00
|
|
|
* Set/get the cache key. This integer uniquely identifies the data in
|
|
|
|
* the cache for this channel.
|
2015-05-10 03:26:39 +03:00
|
|
|
*
|
2015-05-14 20:05:34 +03:00
|
|
|
* A cache key retrieved from a particular instance of nsICacheInfoChannel
|
|
|
|
* could be set on another instance of nsICacheInfoChannel provided the
|
2018-03-06 06:19:42 +03:00
|
|
|
* underlying implementations are compatible and provided the new
|
2015-05-10 03:26:39 +03:00
|
|
|
* channel instance was created with the same URI. The implementation of
|
2015-05-14 20:05:34 +03:00
|
|
|
* nsICacheInfoChannel would be expected to use the cache entry identified
|
2015-05-10 03:26:39 +03:00
|
|
|
* by the cache token. Depending on the value of nsIRequest::loadFlags,
|
|
|
|
* the cache entry may be validated, overwritten, or simply read.
|
|
|
|
*
|
2018-03-06 06:19:42 +03:00
|
|
|
* The cache key may be 0 indicating that the URI of the channel is
|
|
|
|
* sufficient to locate the same cache entry. Setting a 0 cache key
|
2015-05-10 03:26:39 +03:00
|
|
|
* is likewise valid.
|
|
|
|
*/
|
2018-03-06 06:19:42 +03:00
|
|
|
attribute unsigned long cacheKey;
|
2016-01-19 17:28:00 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tells the channel to behave as if the LOAD_FROM_CACHE flag has been set,
|
|
|
|
* but without affecting the loads for the entire loadGroup in case of this
|
|
|
|
* channel being the default load group's channel.
|
|
|
|
*/
|
|
|
|
attribute boolean allowStaleCacheContent;
|
2016-04-11 06:17:02 +03:00
|
|
|
|
Bug 1572933: Introduce an attribute to raise the cache priority. r=pbro,mayhemer
For now, when we turn on `disable cache` switch in DevTools[1], web page loads
the contents without using the cache. Furthermore, DevTools as well comes to
load the contents DevTools inspects without using the cache. And, if the loaded
contents from the web page and DevTools was different, becomes impossible to
inspect the content correctly.
Thus, in order to make DevTools refer the same content the web page loaded,
makes DevTools load the contents inspecting from the cache at first, no matter
if disables the switch or not.
When turns on disable cache in DevTools, `LOAD_BYPASS_CACHE` flag is set into
`loadFlags` in the `docshell`.[2] The other hand, the content DevTools inspects
is loaded from a channel DevTools creates with `LOAD_FROM_CACHE` flag.[3]
However, because this channel is belong to same `loadGroup` of the `docshell`,
`LOAD_BYPASS_CACHE` is inherited and is choosen even if `LOAD_FROM_CACHE` is set.
Thus, in this patch, we introduce an attribute `preferCacheLoadOverBypass`
which raises the priority for `LOAD_FROM_CACHE` above `LOAD_BYPASS_CACHE` and
`LOAD_BYPASS_LOCAL_CACHE`.
[1] https://developer.mozilla.org/en-US/docs/Tools/Settings#Advanced_settings
[2] https://searchfox.org/mozilla-central/source/devtools/server/actors/targets/browsing-context.js#1227
[3] https://searchfox.org/mozilla-central/source/devtools/shared/DevToolsUtils.js#542-544
Differential Revision: https://phabricator.services.mozilla.com/D44626
--HG--
extra : moz-landing-system : lando
2019-09-09 03:57:05 +03:00
|
|
|
/**
|
|
|
|
* Tells the priority for LOAD_CACHE is raised over LOAD_BYPASS_CACHE or
|
|
|
|
* LOAD_BYPASS_LOCAL_CACHE in case those flags are set at the same time.
|
|
|
|
*/
|
|
|
|
attribute boolean preferCacheLoadOverBypass;
|
|
|
|
|
2021-10-16 00:13:43 +03:00
|
|
|
cenum PreferredAlternativeDataDeliveryType : 8 {
|
|
|
|
/**
|
|
|
|
* Do not deliver alternative data stream.
|
|
|
|
*/
|
|
|
|
NONE = 0,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deliver alternative data stream upon additional request.
|
|
|
|
*/
|
|
|
|
ASYNC = 1,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deliver alternative data stream during IPC parent/child serialization.
|
|
|
|
*/
|
|
|
|
SERIALIZE = 2,
|
|
|
|
};
|
|
|
|
|
2021-10-28 19:11:56 +03:00
|
|
|
/**
|
|
|
|
* Tells the channel to be force validated during soft reload.
|
|
|
|
*/
|
|
|
|
attribute boolean forceValidateCacheContent;
|
|
|
|
|
2016-04-11 06:17:02 +03:00
|
|
|
/**
|
|
|
|
* Calling this method instructs the channel to serve the alternative data
|
|
|
|
* if that was previously saved in the cache, otherwise it will serve the
|
|
|
|
* real data.
|
Bug 1487100 - Allow calling nsICacheInfoChannel.preferAlternativeDataType(altDataType, contentType) multiple times r=michal,luke
This patch changes the way we set and handle the preferred alternate data type.
It is no longer just one choice, but a set of preferences, each conditional
on the contentType of the resource.
For example:
var cc = chan.QueryInterface(Ci.nsICacheInfoChannel);
cc.preferAlternativeDataType("js-bytecode", "text/javascript");
cc.preferAlternativeDataType("ammended-text", "text/plain");
cc.preferAlternativeDataType("something-else", "");
When loaded from the cache, the available alt-data type will be checked against
"js-bytecode" if the contentType is "text/javascript", "ammended-text" if the contentType is "text/plain" or "something-else" for all contentTypes.
Note that the alt-data type could be "something-else" even if the contentType is "text/javascript".
The preferences are saved as an nsTArray<mozilla::Tuple<nsCString, nsCString>>.
Differential Revision: https://phabricator.services.mozilla.com/D8071
--HG--
extra : rebase_source : eb4961f05a52e557e7d2d986d59e0a2cf18a3447
extra : source : dd1c31ea78c2b15d14750d137037a54d50719997
2018-10-17 16:58:30 +03:00
|
|
|
* @param type
|
|
|
|
* a string identifying the alt-data format
|
|
|
|
* @param contentType
|
|
|
|
* the contentType for which the preference applies.
|
|
|
|
* an empty contentType means the preference applies for ANY contentType
|
2019-02-20 13:05:42 +03:00
|
|
|
* @param deliverAltData
|
|
|
|
* if false, also if alt-data is available, the channel will deliver
|
|
|
|
* the original data.
|
Bug 1487100 - Allow calling nsICacheInfoChannel.preferAlternativeDataType(altDataType, contentType) multiple times r=michal,luke
This patch changes the way we set and handle the preferred alternate data type.
It is no longer just one choice, but a set of preferences, each conditional
on the contentType of the resource.
For example:
var cc = chan.QueryInterface(Ci.nsICacheInfoChannel);
cc.preferAlternativeDataType("js-bytecode", "text/javascript");
cc.preferAlternativeDataType("ammended-text", "text/plain");
cc.preferAlternativeDataType("something-else", "");
When loaded from the cache, the available alt-data type will be checked against
"js-bytecode" if the contentType is "text/javascript", "ammended-text" if the contentType is "text/plain" or "something-else" for all contentTypes.
Note that the alt-data type could be "something-else" even if the contentType is "text/javascript".
The preferences are saved as an nsTArray<mozilla::Tuple<nsCString, nsCString>>.
Differential Revision: https://phabricator.services.mozilla.com/D8071
--HG--
extra : rebase_source : eb4961f05a52e557e7d2d986d59e0a2cf18a3447
extra : source : dd1c31ea78c2b15d14750d137037a54d50719997
2018-10-17 16:58:30 +03:00
|
|
|
*
|
|
|
|
* The method may be called several times, with different type and contentType.
|
|
|
|
*
|
2016-04-11 06:17:02 +03:00
|
|
|
* Must be called before AsyncOpen.
|
|
|
|
*/
|
2019-02-20 13:05:42 +03:00
|
|
|
void preferAlternativeDataType(in ACString type, in ACString contentType,
|
2021-10-16 00:13:43 +03:00
|
|
|
in nsICacheInfoChannel_PreferredAlternativeDataDeliveryType deliverAltData);
|
2016-04-11 06:17:02 +03:00
|
|
|
|
2017-12-04 09:39:10 +03:00
|
|
|
/**
|
|
|
|
* Get the preferred alternative data type set by preferAlternativeDataType().
|
Bug 1487100 - Allow calling nsICacheInfoChannel.preferAlternativeDataType(altDataType, contentType) multiple times r=michal,luke
This patch changes the way we set and handle the preferred alternate data type.
It is no longer just one choice, but a set of preferences, each conditional
on the contentType of the resource.
For example:
var cc = chan.QueryInterface(Ci.nsICacheInfoChannel);
cc.preferAlternativeDataType("js-bytecode", "text/javascript");
cc.preferAlternativeDataType("ammended-text", "text/plain");
cc.preferAlternativeDataType("something-else", "");
When loaded from the cache, the available alt-data type will be checked against
"js-bytecode" if the contentType is "text/javascript", "ammended-text" if the contentType is "text/plain" or "something-else" for all contentTypes.
Note that the alt-data type could be "something-else" even if the contentType is "text/javascript".
The preferences are saved as an nsTArray<mozilla::Tuple<nsCString, nsCString>>.
Differential Revision: https://phabricator.services.mozilla.com/D8071
--HG--
extra : rebase_source : eb4961f05a52e557e7d2d986d59e0a2cf18a3447
extra : source : dd1c31ea78c2b15d14750d137037a54d50719997
2018-10-17 16:58:30 +03:00
|
|
|
* The returned types stand for the desired data type instead of the type of the
|
2017-12-04 09:39:10 +03:00
|
|
|
* information retrieved from the network stack.
|
|
|
|
*/
|
Bug 1487100 - Allow calling nsICacheInfoChannel.preferAlternativeDataType(altDataType, contentType) multiple times r=michal,luke
This patch changes the way we set and handle the preferred alternate data type.
It is no longer just one choice, but a set of preferences, each conditional
on the contentType of the resource.
For example:
var cc = chan.QueryInterface(Ci.nsICacheInfoChannel);
cc.preferAlternativeDataType("js-bytecode", "text/javascript");
cc.preferAlternativeDataType("ammended-text", "text/plain");
cc.preferAlternativeDataType("something-else", "");
When loaded from the cache, the available alt-data type will be checked against
"js-bytecode" if the contentType is "text/javascript", "ammended-text" if the contentType is "text/plain" or "something-else" for all contentTypes.
Note that the alt-data type could be "something-else" even if the contentType is "text/javascript".
The preferences are saved as an nsTArray<mozilla::Tuple<nsCString, nsCString>>.
Differential Revision: https://phabricator.services.mozilla.com/D8071
--HG--
extra : rebase_source : eb4961f05a52e557e7d2d986d59e0a2cf18a3447
extra : source : dd1c31ea78c2b15d14750d137037a54d50719997
2018-10-17 16:58:30 +03:00
|
|
|
[noscript, notxpcom, nostdcall]
|
2019-02-20 13:05:42 +03:00
|
|
|
ConstPreferredAlternativeDataTypeArray preferredAlternativeDataTypes();
|
2017-12-04 09:39:10 +03:00
|
|
|
|
2016-04-11 06:17:02 +03:00
|
|
|
/**
|
|
|
|
* Holds the type of the alternative data representation that the channel
|
|
|
|
* is returning.
|
|
|
|
* Is empty string if no alternative data representation was requested, or
|
|
|
|
* if the requested representation wasn't found in the cache.
|
|
|
|
* Can only be called during or after OnStartRequest.
|
|
|
|
*/
|
|
|
|
readonly attribute ACString alternativeDataType;
|
|
|
|
|
2019-02-20 13:05:42 +03:00
|
|
|
/**
|
|
|
|
* If preferAlternativeDataType() has been called passing deliverAltData
|
2021-10-16 00:13:43 +03:00
|
|
|
* equal to false, this attribute will expose the alt-data inputStream if
|
|
|
|
* avaiable.
|
2019-02-20 13:05:42 +03:00
|
|
|
*/
|
2021-10-16 00:13:43 +03:00
|
|
|
readonly attribute nsIInputStream alternativeDataInputStream;
|
2019-02-20 13:05:42 +03:00
|
|
|
|
2018-10-17 15:27:37 +03:00
|
|
|
/**
|
|
|
|
* Sometimes when the channel is delivering alt-data, we may want to somehow
|
2019-05-20 21:04:40 +03:00
|
|
|
* access the original content too. This method asynchronously opens the
|
|
|
|
* input stream and delivers it to the receiver.
|
2018-10-17 15:27:37 +03:00
|
|
|
*/
|
2019-05-20 21:04:40 +03:00
|
|
|
void getOriginalInputStream(in nsIInputStreamReceiver aReceiver);
|
2018-10-17 15:27:37 +03:00
|
|
|
|
2016-04-11 06:17:02 +03:00
|
|
|
/**
|
|
|
|
* Opens and returns an output stream that a consumer may use to save an
|
|
|
|
* alternate representation of the data.
|
|
|
|
* Must be called after the OnStopRequest that delivered the real data.
|
|
|
|
* The consumer may choose to replace the saved alt representation.
|
|
|
|
* Opening the output stream will fail if there are any open input streams
|
2019-03-05 04:35:41 +03:00
|
|
|
* reading the already saved alt representation. After successfully opening
|
|
|
|
* an output stream, if there is an error before the entire alt data can be
|
|
|
|
* written successfully, the client must signal failure by passing an error
|
|
|
|
* code to CloseWithStatus().
|
2018-04-25 07:01:00 +03:00
|
|
|
*
|
|
|
|
* @param type
|
|
|
|
* type of the alternative data representation
|
|
|
|
* @param predictedSize
|
|
|
|
* Predicted size of the data that will be written. It's used to decide
|
|
|
|
* whether the resulting entry would exceed size limit, in which case
|
|
|
|
* an error is thrown. If the size isn't known in advance, -1 should be
|
|
|
|
* passed.
|
2016-04-11 06:17:02 +03:00
|
|
|
*/
|
2019-03-05 04:35:41 +03:00
|
|
|
nsIAsyncOutputStream openAlternativeOutputStream(in ACString type, in long long predictedSize);
|
2010-06-24 10:55:19 +04:00
|
|
|
};
|
2021-10-16 00:13:43 +03:00
|
|
|
|
|
|
|
%{ C++
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
|
|
|
using PreferredAlternativeDataDeliveryTypeIPC = nsICacheInfoChannel::PreferredAlternativeDataDeliveryType;
|
|
|
|
|
|
|
|
}
|
|
|
|
} // namespace mozilla
|
|
|
|
%}
|