tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 5a9bb43f63a583676b21122b1d96bd837a568542
parent 70bdd49f89cbb97b45e9941bd1009595bd0f5334
Author: Tooru Fujisawa <arai_a@mac.com>
Date:   Mon, 10 Nov 2025 08:30:05 +0000

Bug 1998926 - Part 1: Add nsICacheInfoChannel.hasCacheEntry. r=valentin,necko-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D271871

Diffstat:
Mnetwerk/base/nsICacheInfoChannel.idl | 6++++++
Mnetwerk/protocol/http/HttpChannelChild.cpp | 6++++++
Mnetwerk/protocol/http/InterceptedHttpChannel.cpp | 9+++++++++
Mnetwerk/protocol/http/nsHttpChannel.cpp | 6++++++
4 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/netwerk/base/nsICacheInfoChannel.idl b/netwerk/base/nsICacheInfoChannel.idl @@ -50,6 +50,12 @@ interface nsICacheInfoChannel : nsISupports boolean isFromCache(); /** + * True if this channel has a corresponding cache entry. This can be true + * even if isFromCache() is false. + */ + boolean hasCacheEntry(); + + /** * 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(). diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp @@ -2782,6 +2782,12 @@ HttpChannelChild::IsFromCache(bool* value) { } NS_IMETHODIMP +HttpChannelChild::HasCacheEntry(bool* value) { + *value = mCacheEntryAvailable; + return NS_OK; +} + +NS_IMETHODIMP HttpChannelChild::GetCacheEntryId(uint64_t* aCacheEntryId) { bool fromCache = false; if (NS_FAILED(IsFromCache(&fromCache)) || !fromCache || diff --git a/netwerk/protocol/http/InterceptedHttpChannel.cpp b/netwerk/protocol/http/InterceptedHttpChannel.cpp @@ -1342,6 +1342,15 @@ InterceptedHttpChannel::IsFromCache(bool* value) { } NS_IMETHODIMP +InterceptedHttpChannel::HasCacheEntry(bool* value) { + if (mSynthesizedCacheInfo) { + return mSynthesizedCacheInfo->HasCacheEntry(value); + } + *value = false; + return NS_OK; +} + +NS_IMETHODIMP InterceptedHttpChannel::IsRacing(bool* value) { if (mSynthesizedCacheInfo) { return mSynthesizedCacheInfo->IsRacing(value); diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp @@ -10568,6 +10568,12 @@ nsHttpChannel::IsFromCache(bool* value) { } NS_IMETHODIMP +nsHttpChannel::HasCacheEntry(bool* value) { + *value = !!mCacheEntry; + return NS_OK; +} + +NS_IMETHODIMP nsHttpChannel::GetCacheEntryId(uint64_t* aCacheEntryId) { bool fromCache = false; if (NS_FAILED(IsFromCache(&fromCache)) || !fromCache || !mCacheEntry ||