mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 18:08:58 +00:00
Bug 1848833: Clean up mRedirectedCacheKeys r=valentin,necko-reviewers, a=dsmith
Differential Revision: https://phabricator.services.mozilla.com/D188744
This commit is contained in:
parent
251933af1b
commit
89f3287dae
@ -3513,7 +3513,9 @@ HttpBaseChannel::SetChannelIsForDownload(bool aChannelIsForDownload) {
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::SetCacheKeysRedirectChain(nsTArray<nsCString>* cacheKeys) {
|
||||
mRedirectedCachekeys = WrapUnique(cacheKeys);
|
||||
auto RedirectedCachekeys = mRedirectedCachekeys.Lock();
|
||||
auto& ref = RedirectedCachekeys.ref();
|
||||
ref = WrapUnique(cacheKeys);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -5010,14 +5012,17 @@ nsresult HttpBaseChannel::SetupReplacementChannel(nsIURI* newURI,
|
||||
|
||||
// if there is a chain of keys for redirect-responses we transfer it to
|
||||
// the new channel (see bug #561276)
|
||||
if (mRedirectedCachekeys) {
|
||||
LOG(
|
||||
("HttpBaseChannel::SetupReplacementChannel "
|
||||
"[this=%p] transferring chain of redirect cache-keys",
|
||||
this));
|
||||
rv = httpInternal->SetCacheKeysRedirectChain(
|
||||
mRedirectedCachekeys.release());
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
{
|
||||
auto redirectedCachekeys = mRedirectedCachekeys.Lock();
|
||||
auto& ref = redirectedCachekeys.ref();
|
||||
if (ref) {
|
||||
LOG(
|
||||
("HttpBaseChannel::SetupReplacementChannel "
|
||||
"[this=%p] transferring chain of redirect cache-keys",
|
||||
this));
|
||||
rv = httpInternal->SetCacheKeysRedirectChain(ref.release());
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
}
|
||||
}
|
||||
|
||||
// Preserve Request mode.
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "mozilla/AtomicBitfields.h"
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/dom/DOMTypes.h"
|
||||
#include "mozilla/DataMutex.h"
|
||||
#include "mozilla/net/DNS.h"
|
||||
#include "mozilla/net/NeckoChannelParams.h"
|
||||
#include "mozilla/net/NeckoCommon.h"
|
||||
@ -344,7 +345,8 @@ class HttpBaseChannel : public nsHashPropertyBag,
|
||||
nsILoadInfo::CrossOriginEmbedderPolicy* aOutPolicy) override;
|
||||
|
||||
inline void CleanRedirectCacheChainIfNecessary() {
|
||||
mRedirectedCachekeys = nullptr;
|
||||
auto redirectedCachekeys = mRedirectedCachekeys.Lock();
|
||||
redirectedCachekeys.ref() = nullptr;
|
||||
}
|
||||
NS_IMETHOD HTTPUpgrade(const nsACString& aProtocolName,
|
||||
nsIHttpUpgradeListener* aListener) override;
|
||||
@ -751,7 +753,9 @@ class HttpBaseChannel : public nsHashPropertyBag,
|
||||
nsCOMPtr<nsIConsoleReportCollector> mReportCollector;
|
||||
|
||||
RefPtr<nsHttpHandler> mHttpHandler; // keep gHttpHandler alive
|
||||
UniquePtr<nsTArray<nsCString>> mRedirectedCachekeys;
|
||||
// Accessed on MainThread and Cache2 IO thread
|
||||
DataMutex<UniquePtr<nsTArray<nsCString>>> mRedirectedCachekeys{
|
||||
"mRedirectedCacheKeys"};
|
||||
nsCOMPtr<nsIRequestContext> mRequestContext;
|
||||
|
||||
NetAddr mSelfAddr;
|
||||
|
@ -3969,9 +3969,11 @@ nsHttpChannel::OnCacheEntryCheck(nsICacheEntry* entry, uint32_t* aResult) {
|
||||
rv = GenerateCacheKey(mPostID, cacheKey);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
if (!mRedirectedCachekeys) {
|
||||
mRedirectedCachekeys = MakeUnique<nsTArray<nsCString>>();
|
||||
} else if (mRedirectedCachekeys->Contains(cacheKey)) {
|
||||
auto redirectedCachekeys = mRedirectedCachekeys.Lock();
|
||||
auto& ref = redirectedCachekeys.ref();
|
||||
if (!ref) {
|
||||
ref = MakeUnique<nsTArray<nsCString>>();
|
||||
} else if (ref->Contains(cacheKey)) {
|
||||
doValidation = true;
|
||||
}
|
||||
|
||||
@ -3980,7 +3982,7 @@ nsHttpChannel::OnCacheEntryCheck(nsICacheEntry* entry, uint32_t* aResult) {
|
||||
|
||||
// Append cacheKey if not in the chain already
|
||||
if (!doValidation) {
|
||||
mRedirectedCachekeys->AppendElement(cacheKey);
|
||||
ref->AppendElement(cacheKey);
|
||||
} else {
|
||||
prefetchStatus =
|
||||
Telemetry::LABELS_PREDICTOR_PREFETCH_USE_STATUS::Redirect;
|
||||
|
Loading…
Reference in New Issue
Block a user