зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1391693 P11 Remove old nsHttpChannel interception bits. r=valentin
This commit is contained in:
Родитель
caf912a42a
Коммит
4d2d40a639
|
@ -3570,12 +3570,6 @@ HttpChannelChild::ForceIntercepted(bool aPostRedirectChannelShouldIntercept,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpChannelChild::ForceIntercepted(uint64_t aInterceptionID)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void
|
||||
HttpChannelChild::ForceIntercepted(nsIInputStream* aSynthesizedInput)
|
||||
{
|
||||
|
|
|
@ -98,7 +98,6 @@ public:
|
|||
NS_IMETHOD GetProtocolVersion(nsACString& aProtocolVersion) override;
|
||||
// nsIHttpChannelInternal
|
||||
NS_IMETHOD SetupFallbackChannel(const char *aFallbackKey) override;
|
||||
NS_IMETHOD ForceIntercepted(uint64_t aInterceptionID) override;
|
||||
// nsISupportsPriority
|
||||
NS_IMETHOD SetPriority(int32_t value) override;
|
||||
// nsIClassOfService
|
||||
|
|
|
@ -213,215 +213,6 @@ InterceptedChannelBase::SecureUpgradeChannelURI(nsIChannel* aChannel)
|
|||
return upgradedURI.forget();
|
||||
}
|
||||
|
||||
InterceptedChannelChrome::InterceptedChannelChrome(nsHttpChannel* aChannel,
|
||||
nsINetworkInterceptController* aController,
|
||||
nsICacheEntry* aEntry)
|
||||
: InterceptedChannelBase(aController)
|
||||
, mChannel(aChannel)
|
||||
, mSynthesizedCacheEntry(aEntry)
|
||||
{
|
||||
nsresult rv = mChannel->GetApplyConversion(&mOldApplyConversion);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
mOldApplyConversion = false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
InterceptedChannelChrome::NotifyController()
|
||||
{
|
||||
// Intercepted responses should already be decoded.
|
||||
mChannel->SetApplyConversion(false);
|
||||
|
||||
nsresult rv = mSynthesizedCacheEntry->OpenOutputStream(0, getter_AddRefs(mResponseBody));
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
DoNotifyController();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InterceptedChannelChrome::GetChannel(nsIChannel** aChannel)
|
||||
{
|
||||
NS_IF_ADDREF(*aChannel = mChannel);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InterceptedChannelChrome::ResetInterception()
|
||||
{
|
||||
if (mClosed) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
mReportCollector->FlushConsoleReports(mChannel);
|
||||
|
||||
mSynthesizedCacheEntry->AsyncDoom(nullptr);
|
||||
mSynthesizedCacheEntry = nullptr;
|
||||
|
||||
mChannel->SetApplyConversion(mOldApplyConversion);
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
mChannel->GetURI(getter_AddRefs(uri));
|
||||
|
||||
nsresult rv = mChannel->StartRedirectChannelToURI(uri, nsIChannelEventSink::REDIRECT_INTERNAL);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mResponseBody->Close();
|
||||
mResponseBody = nullptr;
|
||||
mClosed = true;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InterceptedChannelChrome::SynthesizeStatus(uint16_t aStatus, const nsACString& aReason)
|
||||
{
|
||||
if (!mSynthesizedCacheEntry) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
return DoSynthesizeStatus(aStatus, aReason);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InterceptedChannelChrome::SynthesizeHeader(const nsACString& aName, const nsACString& aValue)
|
||||
{
|
||||
if (!mSynthesizedCacheEntry) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
return DoSynthesizeHeader(aName, aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InterceptedChannelChrome::FinishSynthesizedResponse(const nsACString& aFinalURLSpec)
|
||||
{
|
||||
if (mClosed) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
// Make sure the cache entry's output stream is always closed. If the
|
||||
// channel was intercepted with a null-body response then its possible
|
||||
// the synthesis completed without a stream copy operation.
|
||||
mResponseBody->Close();
|
||||
|
||||
mReportCollector->FlushConsoleReports(mChannel);
|
||||
|
||||
EnsureSynthesizedResponse();
|
||||
|
||||
// If the synthesized response is a redirect, then we want to respect
|
||||
// the encoding of whatever is loaded as a result.
|
||||
if (nsHttpChannel::WillRedirect(mSynthesizedResponseHead.ref())) {
|
||||
nsresult rv = mChannel->SetApplyConversion(mOldApplyConversion);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
mChannel->MarkIntercepted();
|
||||
|
||||
// First we ensure the appropriate metadata is set on the synthesized cache entry
|
||||
// (i.e. the flattened response head)
|
||||
|
||||
nsCOMPtr<nsISupports> securityInfo;
|
||||
nsresult rv = mChannel->GetSecurityInfo(getter_AddRefs(securityInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
uint32_t expirationTime = 0;
|
||||
rv = DoUpdateExpirationTime(mChannel, mSynthesizedCacheEntry,
|
||||
mSynthesizedResponseHead.ref(),
|
||||
expirationTime);
|
||||
|
||||
rv = DoAddCacheEntryHeaders(mChannel, mSynthesizedCacheEntry,
|
||||
mChannel->GetRequestHead(),
|
||||
mSynthesizedResponseHead.ref(), securityInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIURI> originalURI;
|
||||
mChannel->GetURI(getter_AddRefs(originalURI));
|
||||
|
||||
nsCOMPtr<nsIURI> responseURI;
|
||||
if (!aFinalURLSpec.IsEmpty()) {
|
||||
rv = NS_NewURI(getter_AddRefs(responseURI), aFinalURLSpec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
responseURI = originalURI;
|
||||
}
|
||||
|
||||
bool equal = false;
|
||||
originalURI->Equals(responseURI, &equal);
|
||||
if (!equal) {
|
||||
rv =
|
||||
mChannel->StartRedirectChannelToURI(responseURI, nsIChannelEventSink::REDIRECT_INTERNAL);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
bool usingSSL = false;
|
||||
responseURI->SchemeIs("https", &usingSSL);
|
||||
|
||||
// Then we open a real cache entry to read the synthesized response from.
|
||||
rv = mChannel->OpenCacheEntry(usingSSL);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mSynthesizedCacheEntry = nullptr;
|
||||
|
||||
if (!mChannel->AwaitingCacheCallbacks()) {
|
||||
rv = mChannel->ContinueConnect();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
mClosed = true;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InterceptedChannelChrome::CancelInterception(nsresult aStatus)
|
||||
{
|
||||
MOZ_ASSERT(NS_FAILED(aStatus));
|
||||
|
||||
if (mClosed) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mReportCollector->FlushConsoleReports(mChannel);
|
||||
|
||||
// we need to use AsyncAbort instead of Cancel since there's no active pump
|
||||
// to cancel which will provide OnStart/OnStopRequest to the channel.
|
||||
nsresult rv = mChannel->AsyncAbort(aStatus);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mClosed = true;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InterceptedChannelChrome::SetChannelInfo(dom::ChannelInfo* aChannelInfo)
|
||||
{
|
||||
if (mClosed) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return aChannelInfo->ResurrectInfoOnChannel(mChannel);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InterceptedChannelChrome::GetInternalContentPolicyType(nsContentPolicyType* aPolicyType)
|
||||
{
|
||||
NS_ENSURE_ARG(aPolicyType);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
nsresult rv = mChannel->GetLoadInfo(getter_AddRefs(loadInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (loadInfo) {
|
||||
*aPolicyType = loadInfo->InternalContentPolicyType();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InterceptedChannelChrome::GetSecureUpgradedChannelURI(nsIURI** aURI)
|
||||
{
|
||||
return mChannel->GetURI(aURI);
|
||||
}
|
||||
|
||||
InterceptedChannelContent::InterceptedChannelContent(HttpChannelChild* aChannel,
|
||||
nsINetworkInterceptController* aController,
|
||||
InterceptStreamListener* aListener,
|
||||
|
|
|
@ -166,37 +166,6 @@ public:
|
|||
SecureUpgradeChannelURI(nsIChannel* aChannel);
|
||||
};
|
||||
|
||||
class InterceptedChannelChrome : public InterceptedChannelBase
|
||||
{
|
||||
// The actual channel being intercepted.
|
||||
RefPtr<nsHttpChannel> mChannel;
|
||||
|
||||
// Writeable cache entry for use when synthesizing a response in a parent process
|
||||
nsCOMPtr<nsICacheEntry> mSynthesizedCacheEntry;
|
||||
|
||||
// When a channel is intercepted, content decoding is disabled since the
|
||||
// ServiceWorker will have already extracted the decoded data. For parent
|
||||
// process channels we need to preserve the earlier value in case
|
||||
// ResetInterception is called.
|
||||
bool mOldApplyConversion;
|
||||
public:
|
||||
InterceptedChannelChrome(nsHttpChannel* aChannel,
|
||||
nsINetworkInterceptController* aController,
|
||||
nsICacheEntry* aEntry);
|
||||
|
||||
NS_IMETHOD ResetInterception() override;
|
||||
NS_IMETHOD FinishSynthesizedResponse(const nsACString& aFinalURLSpec) override;
|
||||
NS_IMETHOD GetChannel(nsIChannel** aChannel) override;
|
||||
NS_IMETHOD GetSecureUpgradedChannelURI(nsIURI** aURI) override;
|
||||
NS_IMETHOD SynthesizeStatus(uint16_t aStatus, const nsACString& aReason) override;
|
||||
NS_IMETHOD SynthesizeHeader(const nsACString& aName, const nsACString& aValue) override;
|
||||
NS_IMETHOD CancelInterception(nsresult aStatus) override;
|
||||
NS_IMETHOD SetChannelInfo(mozilla::dom::ChannelInfo* aChannelInfo) override;
|
||||
NS_IMETHOD GetInternalContentPolicyType(nsContentPolicyType *aInternalContentPolicyType) override;
|
||||
|
||||
virtual void NotifyController() override;
|
||||
};
|
||||
|
||||
class InterceptedChannelContent : public InterceptedChannelBase
|
||||
{
|
||||
// The actual channel being intercepted.
|
||||
|
|
|
@ -474,14 +474,6 @@ InterceptedHttpChannel::SetupFallbackChannel(const char* aFallbackKey)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InterceptedHttpChannel::ForceIntercepted(uint64_t aInterceptionID)
|
||||
{
|
||||
// This is a stale API call used in the old nsHttpChannel interception
|
||||
// code when e10s is enabled. It will be removed in the future.
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InterceptedHttpChannel::GetResponseSynthesized(bool* aResponseSynthesized)
|
||||
{
|
||||
|
|
|
@ -151,9 +151,6 @@ public:
|
|||
NS_IMETHOD
|
||||
SetupFallbackChannel(const char * aFallbackKey) override;
|
||||
|
||||
NS_IMETHOD
|
||||
ForceIntercepted(uint64_t aInterceptionID) override;
|
||||
|
||||
NS_IMETHOD
|
||||
GetResponseSynthesized(bool *aResponseSynthesized) override;
|
||||
|
||||
|
|
|
@ -122,9 +122,6 @@ namespace mozilla { namespace net {
|
|||
|
||||
namespace {
|
||||
|
||||
// Monotonically increasing ID for generating unique cache entries per
|
||||
// intercepted channel.
|
||||
static uint64_t gNumIntercepted = 0;
|
||||
static bool sRCWNEnabled = false;
|
||||
static uint32_t sRCWNQueueSizeNormal = 50;
|
||||
static uint32_t sRCWNQueueSizePriority = 10;
|
||||
|
@ -309,8 +306,6 @@ nsHttpChannel::nsHttpChannel()
|
|||
, mRequestTime(0)
|
||||
, mOfflineCacheLastModifiedTime(0)
|
||||
, mSuspendTotalTime(0)
|
||||
, mInterceptCache(DO_NOT_INTERCEPT)
|
||||
, mInterceptionID(gNumIntercepted++)
|
||||
, mCacheOpenWithPriority(false)
|
||||
, mCacheQueueSizeWhenOpen(0)
|
||||
, mCachedContentIsValid(false)
|
||||
|
@ -653,8 +648,7 @@ nsHttpChannel::TryHSTSPriming()
|
|||
mLoadInfo->GetForceHSTSPriming();
|
||||
|
||||
if (requireHSTSPriming &&
|
||||
nsMixedContentBlocker::sSendHSTSPriming &&
|
||||
mInterceptCache == DO_NOT_INTERCEPT) {
|
||||
nsMixedContentBlocker::sSendHSTSPriming) {
|
||||
if (!isHttpsScheme) {
|
||||
rv = HSTSPrimingListener::StartHSTSPriming(this, this);
|
||||
|
||||
|
@ -813,8 +807,7 @@ nsHttpChannel::ContinueConnect()
|
|||
// a CORS preflight. Bug: 1272440
|
||||
// If we need to start a CORS preflight, do it now!
|
||||
// Note that it is important to do this before the early returns below.
|
||||
if (!mIsCorsPreflightDone && mRequireCORSPreflight &&
|
||||
mInterceptCache != INTERCEPTED) {
|
||||
if (!mIsCorsPreflightDone && mRequireCORSPreflight) {
|
||||
MOZ_ASSERT(!mPreflightChannel);
|
||||
nsresult rv =
|
||||
nsCORSListenerProxy::StartCORSPreflight(this, this,
|
||||
|
@ -823,9 +816,7 @@ nsHttpChannel::ContinueConnect()
|
|||
return rv;
|
||||
}
|
||||
|
||||
MOZ_RELEASE_ASSERT(!(mRequireCORSPreflight &&
|
||||
mInterceptCache != INTERCEPTED) ||
|
||||
mIsCorsPreflightDone,
|
||||
MOZ_RELEASE_ASSERT(!mRequireCORSPreflight || mIsCorsPreflightDone,
|
||||
"CORS preflight must have been finished by the time we "
|
||||
"do the rest of ContinueConnect");
|
||||
|
||||
|
@ -848,10 +839,7 @@ nsHttpChannel::ContinueConnect()
|
|||
event->Revoke();
|
||||
}
|
||||
|
||||
// Don't accumulate the cache hit telemetry for intercepted channels.
|
||||
if (mInterceptCache != INTERCEPTED) {
|
||||
AccumulateCacheHitTelemetry(kCacheHit);
|
||||
}
|
||||
AccumulateCacheHitTelemetry(kCacheHit);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -1578,9 +1566,7 @@ nsHttpChannel::CallOnStartRequest()
|
|||
{
|
||||
LOG(("nsHttpChannel::CallOnStartRequest [this=%p]", this));
|
||||
|
||||
MOZ_RELEASE_ASSERT(!(mRequireCORSPreflight &&
|
||||
mInterceptCache != INTERCEPTED) ||
|
||||
mIsCorsPreflightDone,
|
||||
MOZ_RELEASE_ASSERT(!mRequireCORSPreflight || mIsCorsPreflightDone,
|
||||
"CORS preflight must have been finished by the time we "
|
||||
"call OnStartRequest");
|
||||
|
||||
|
@ -2996,16 +2982,6 @@ nsHttpChannel::StartRedirectChannelToURI(nsIURI *upgradedURI, uint32_t flags)
|
|||
// Inform consumers about this fake redirect
|
||||
mRedirectChannel = newChannel;
|
||||
|
||||
if (!(flags & nsIChannelEventSink::REDIRECT_STS_UPGRADE) &&
|
||||
mInterceptCache == INTERCEPTED) {
|
||||
// Mark the channel as intercepted in order to propagate the response URL.
|
||||
nsCOMPtr<nsIHttpChannelInternal> httpRedirect = do_QueryInterface(mRedirectChannel);
|
||||
if (httpRedirect) {
|
||||
rv = httpRedirect->ForceIntercepted(mInterceptionID);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
}
|
||||
}
|
||||
|
||||
PushRedirectAsyncFunc(
|
||||
&nsHttpChannel::ContinueAsyncRedirectChannelToURI);
|
||||
rv = gHttpHandler->AsyncOnChannelRedirect(this, newChannel, flags);
|
||||
|
@ -3801,7 +3777,7 @@ nsHttpChannel::OpenCacheEntry(bool isHttps)
|
|||
if (mPostID == 0)
|
||||
mPostID = gHttpHandler->GenerateUniqueID();
|
||||
}
|
||||
else if (!PossiblyIntercepted() && !mRequestHead.IsGet() && !mRequestHead.IsHead()) {
|
||||
else if (!mRequestHead.IsGet() && !mRequestHead.IsHead()) {
|
||||
// don't use the cache for other types of requests
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3819,7 +3795,7 @@ nsHttpChannel::OpenCacheEntry(bool isHttps)
|
|||
|
||||
// Pick up an application cache from the notification
|
||||
// callbacks if available and if we are not an intercepted channel.
|
||||
if (!PossiblyIntercepted() && !mApplicationCache &&
|
||||
if (!mApplicationCache &&
|
||||
mInheritApplicationCache) {
|
||||
nsCOMPtr<nsIApplicationCacheContainer> appCacheContainer;
|
||||
GetCallback(appCacheContainer);
|
||||
|
@ -3842,15 +3818,7 @@ nsHttpChannel::OpenCacheEntry(bool isHttps)
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else {
|
||||
// In the case of intercepted channels, we need to construct the cache
|
||||
// entry key based on the original URI, so that in case the intercepted
|
||||
// channel is redirected, the cache entry key before and after the
|
||||
// redirect is the same.
|
||||
if (PossiblyIntercepted()) {
|
||||
openURI = mOriginalURI;
|
||||
} else {
|
||||
openURI = mURI;
|
||||
}
|
||||
openURI = mURI;
|
||||
}
|
||||
|
||||
RefPtr<LoadContextInfo> info = GetLoadContextInfo(this);
|
||||
|
@ -3866,12 +3834,12 @@ nsHttpChannel::OpenCacheEntry(bool isHttps)
|
|||
nsAutoCString cacheControlRequestHeader;
|
||||
Unused << mRequestHead.GetHeader(nsHttp::Cache_Control, cacheControlRequestHeader);
|
||||
CacheControlParser cacheControlRequest(cacheControlRequestHeader);
|
||||
if (cacheControlRequest.NoStore() && !PossiblyIntercepted()) {
|
||||
if (cacheControlRequest.NoStore()) {
|
||||
goto bypassCacheEntryOpen;
|
||||
}
|
||||
|
||||
if (offline || (mLoadFlags & INHIBIT_CACHING)) {
|
||||
if (BYPASS_LOCAL_CACHE(mLoadFlags) && !offline && !PossiblyIntercepted()) {
|
||||
if (BYPASS_LOCAL_CACHE(mLoadFlags) && !offline) {
|
||||
goto bypassCacheEntryOpen;
|
||||
}
|
||||
cacheEntryOpenFlags = nsICacheStorage::OPEN_READONLY;
|
||||
|
@ -3898,10 +3866,6 @@ nsHttpChannel::OpenCacheEntry(bool isHttps)
|
|||
rv = cacheStorageService->AppCacheStorage(info,
|
||||
mApplicationCache,
|
||||
getter_AddRefs(cacheStorage));
|
||||
} else if (PossiblyIntercepted()) {
|
||||
// The synthesized cache has less restrictions on file size and so on.
|
||||
rv = cacheStorageService->SynthesizedCacheStorage(info,
|
||||
getter_AddRefs(cacheStorage));
|
||||
} else if (mLoadFlags & INHIBIT_PERSISTENT_CACHING) {
|
||||
rv = cacheStorageService->MemoryCacheStorage(info, // ? choose app cache as well...
|
||||
getter_AddRefs(cacheStorage));
|
||||
|
@ -3930,85 +3894,52 @@ nsHttpChannel::OpenCacheEntry(bool isHttps)
|
|||
if (mLoadFlags & LOAD_BYPASS_LOCAL_CACHE_IF_BUSY)
|
||||
cacheEntryOpenFlags |= nsICacheStorage::OPEN_BYPASS_IF_BUSY;
|
||||
|
||||
if (PossiblyIntercepted()) {
|
||||
extension.Append(nsPrintfCString("u%" PRIu64, mInterceptionID));
|
||||
} else if (mPostID) {
|
||||
if (mPostID) {
|
||||
extension.Append(nsPrintfCString("%d", mPostID));
|
||||
}
|
||||
|
||||
// If this channel should be intercepted, we do not open a cache entry for this channel
|
||||
// until the interception process is complete and the consumer decides what to do with it.
|
||||
if (mInterceptCache == MAYBE_INTERCEPT) {
|
||||
DebugOnly<bool> exists;
|
||||
MOZ_ASSERT(NS_FAILED(cacheStorage->Exists(openURI, extension, &exists)) || !exists,
|
||||
"The entry must not exist in the cache before we create it here");
|
||||
mCacheOpenWithPriority = cacheEntryOpenFlags & nsICacheStorage::OPEN_PRIORITY;
|
||||
mCacheQueueSizeWhenOpen = CacheStorageService::CacheQueueSize(mCacheOpenWithPriority);
|
||||
|
||||
nsCOMPtr<nsICacheEntry> entry;
|
||||
rv = cacheStorage->OpenTruncate(openURI, extension, getter_AddRefs(entry));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (sRCWNEnabled && maybeRCWN && !mApplicationCacheForWrite) {
|
||||
bool hasAltData = false;
|
||||
uint32_t sizeInKb = 0;
|
||||
rv = cacheStorage->GetCacheIndexEntryAttrs(openURI, extension,
|
||||
&hasAltData, &sizeInKb);
|
||||
|
||||
nsCOMPtr<nsINetworkInterceptController> controller;
|
||||
GetCallback(controller);
|
||||
|
||||
RefPtr<InterceptedChannelChrome> intercepted =
|
||||
new InterceptedChannelChrome(this, controller, entry);
|
||||
intercepted->NotifyController();
|
||||
} else {
|
||||
if (mInterceptCache == INTERCEPTED) {
|
||||
cacheEntryOpenFlags |= nsICacheStorage::OPEN_INTERCEPTED;
|
||||
// Clear OPEN_TRUNCATE for the fake cache entry, since otherwise
|
||||
// cache storage will close the current entry which breaks the
|
||||
// response synthesis.
|
||||
cacheEntryOpenFlags &= ~nsICacheStorage::OPEN_TRUNCATE;
|
||||
DebugOnly<bool> exists;
|
||||
MOZ_ASSERT(NS_SUCCEEDED(cacheStorage->Exists(openURI, extension, &exists)) && exists,
|
||||
"The entry must exist in the cache after we create it here");
|
||||
// We will attempt to race the network vs the cache if we've found
|
||||
// this entry in the cache index, and it has appropriate attributes
|
||||
// (doesn't have alt-data, and has a small size)
|
||||
if (NS_SUCCEEDED(rv) && !hasAltData &&
|
||||
sizeInKb < sRCWNSmallResourceSizeKB) {
|
||||
MaybeRaceCacheWithNetwork();
|
||||
}
|
||||
|
||||
mCacheOpenWithPriority = cacheEntryOpenFlags & nsICacheStorage::OPEN_PRIORITY;
|
||||
mCacheQueueSizeWhenOpen = CacheStorageService::CacheQueueSize(mCacheOpenWithPriority);
|
||||
|
||||
if (sRCWNEnabled && maybeRCWN && !mApplicationCacheForWrite &&
|
||||
mInterceptCache != INTERCEPTED) {
|
||||
bool hasAltData = false;
|
||||
uint32_t sizeInKb = 0;
|
||||
rv = cacheStorage->GetCacheIndexEntryAttrs(openURI, extension,
|
||||
&hasAltData, &sizeInKb);
|
||||
|
||||
// We will attempt to race the network vs the cache if we've found
|
||||
// this entry in the cache index, and it has appropriate attributes
|
||||
// (doesn't have alt-data, and has a small size)
|
||||
if (NS_SUCCEEDED(rv) && !hasAltData &&
|
||||
sizeInKb < sRCWNSmallResourceSizeKB) {
|
||||
MaybeRaceCacheWithNetwork();
|
||||
}
|
||||
}
|
||||
|
||||
if (!mCacheOpenDelay) {
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Should be called on the main thread");
|
||||
if (mNetworkTriggered) {
|
||||
mRaceCacheWithNetwork = sRCWNEnabled;
|
||||
}
|
||||
rv = cacheStorage->AsyncOpenURI(openURI, extension, cacheEntryOpenFlags, this);
|
||||
} else {
|
||||
// We pass `this` explicitly as a parameter due to the raw pointer
|
||||
// to refcounted object in lambda analysis.
|
||||
mCacheOpenFunc = [openURI, extension, cacheEntryOpenFlags, cacheStorage] (nsHttpChannel* self) -> void {
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Should be called on the main thread");
|
||||
if (self->mNetworkTriggered) {
|
||||
self->mRaceCacheWithNetwork = true;
|
||||
}
|
||||
cacheStorage->AsyncOpenURI(openURI, extension, cacheEntryOpenFlags, self);
|
||||
};
|
||||
|
||||
mCacheOpenTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
|
||||
// calls nsHttpChannel::Notify after `mCacheOpenDelay` milliseconds
|
||||
mCacheOpenTimer->InitWithCallback(this, mCacheOpenDelay, nsITimer::TYPE_ONE_SHOT);
|
||||
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (!mCacheOpenDelay) {
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Should be called on the main thread");
|
||||
if (mNetworkTriggered) {
|
||||
mRaceCacheWithNetwork = sRCWNEnabled;
|
||||
}
|
||||
rv = cacheStorage->AsyncOpenURI(openURI, extension, cacheEntryOpenFlags, this);
|
||||
} else {
|
||||
// We pass `this` explicitly as a parameter due to the raw pointer
|
||||
// to refcounted object in lambda analysis.
|
||||
mCacheOpenFunc = [openURI, extension, cacheEntryOpenFlags, cacheStorage] (nsHttpChannel* self) -> void {
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Should be called on the main thread");
|
||||
if (self->mNetworkTriggered) {
|
||||
self->mRaceCacheWithNetwork = true;
|
||||
}
|
||||
cacheStorage->AsyncOpenURI(openURI, extension, cacheEntryOpenFlags, self);
|
||||
};
|
||||
|
||||
mCacheOpenTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
|
||||
// calls nsHttpChannel::Notify after `mCacheOpenDelay` milliseconds
|
||||
mCacheOpenTimer->InitWithCallback(this, mCacheOpenDelay, nsITimer::TYPE_ONE_SHOT);
|
||||
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
waitFlags.Keep(WAIT_FOR_CACHE_ENTRY);
|
||||
|
||||
bypassCacheEntryOpen:
|
||||
|
@ -4229,7 +4160,7 @@ nsHttpChannel::OnCacheEntryCheck(nsICacheEntry* entry, nsIApplicationCache* appC
|
|||
// want to proceed since the LOAD_ONLY_IF_MODIFIED flag is
|
||||
// also set.
|
||||
MOZ_ASSERT(mLoadFlags & LOAD_ONLY_IF_MODIFIED);
|
||||
} else if (mInterceptCache != INTERCEPTED) {
|
||||
} else {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
@ -4330,10 +4261,6 @@ nsHttpChannel::OnCacheEntryCheck(nsICacheEntry* entry, nsIApplicationCache* appC
|
|||
mRedirectedCachekeys->AppendElement(cacheKey);
|
||||
}
|
||||
|
||||
if (doValidation && mInterceptCache == INTERCEPTED) {
|
||||
doValidation = false;
|
||||
}
|
||||
|
||||
mCachedContentIsValid = !doValidation;
|
||||
|
||||
if (doValidation) {
|
||||
|
@ -5657,17 +5584,6 @@ nsHttpChannel::SetupReplacementChannel(nsIURI *newURI,
|
|||
resumableChannel->ResumeAt(mStartPos, mEntityID);
|
||||
}
|
||||
|
||||
if (!(redirectFlags & nsIChannelEventSink::REDIRECT_STS_UPGRADE) &&
|
||||
mInterceptCache != INTERCEPTED &&
|
||||
mRedirectMode != nsIHttpChannelInternal::REDIRECT_MODE_MANUAL) {
|
||||
nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL;
|
||||
rv = newChannel->GetLoadFlags(&loadFlags);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
loadFlags |= nsIChannel::LOAD_BYPASS_SERVICE_WORKER;
|
||||
rv = newChannel->SetLoadFlags(loadFlags);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -6169,11 +6085,6 @@ nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mInterceptCache != INTERCEPTED && ShouldIntercept()) {
|
||||
mInterceptCache = MAYBE_INTERCEPT;
|
||||
SetCouldBeSynthesized();
|
||||
}
|
||||
|
||||
// Remember the cookie header that was set, if any
|
||||
nsAutoCString cookieHeader;
|
||||
if (NS_SUCCEEDED(mRequestHead.GetHeader(nsHttp::Cookie, cookieHeader))) {
|
||||
|
@ -6697,21 +6608,6 @@ nsHttpChannel::SetupFallbackChannel(const char *aFallbackKey)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::ForceIntercepted(uint64_t aInterceptionID)
|
||||
{
|
||||
ENSURE_CALLED_BEFORE_ASYNC_OPEN();
|
||||
|
||||
if (NS_WARN_IF(mLoadFlags & LOAD_BYPASS_SERVICE_WORKER)) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
MarkIntercepted();
|
||||
mResponseCouldBeSynthesized = true;
|
||||
mInterceptionID = aInterceptionID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::SetChannelIsForDownload(bool aChannelIsForDownload)
|
||||
{
|
||||
|
@ -8685,17 +8581,11 @@ nsHttpChannel::SetNotificationCallbacks(nsIInterfaceRequestor *aCallbacks)
|
|||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
nsHttpChannel::MarkIntercepted()
|
||||
{
|
||||
mInterceptCache = INTERCEPTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::GetResponseSynthesized(bool* aSynthesized)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSynthesized);
|
||||
*aSynthesized = (mInterceptCache == INTERCEPTED);
|
||||
*aSynthesized = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -9585,8 +9475,6 @@ nsHttpChannel::GetWarningReporter()
|
|||
nsresult
|
||||
nsHttpChannel::RedirectToInterceptedChannel()
|
||||
{
|
||||
mInterceptCache = INTERCEPTED;
|
||||
|
||||
nsCOMPtr<nsINetworkInterceptController> controller;
|
||||
GetCallback(controller);
|
||||
|
||||
|
|
|
@ -165,7 +165,6 @@ public:
|
|||
NS_IMETHOD GetEncodedBodySize(uint64_t *aEncodedBodySize) override;
|
||||
// nsIHttpChannelInternal
|
||||
NS_IMETHOD SetupFallbackChannel(const char *aFallbackKey) override;
|
||||
NS_IMETHOD ForceIntercepted(uint64_t aInterceptionID) override;
|
||||
NS_IMETHOD SetChannelIsForDownload(bool aChannelIsForDownload) override;
|
||||
// nsISupportsPriority
|
||||
NS_IMETHOD SetPriority(int32_t value) override;
|
||||
|
@ -264,7 +263,6 @@ public: /* internal necko use only */
|
|||
uint32_t mKeep : 2;
|
||||
};
|
||||
|
||||
void MarkIntercepted();
|
||||
NS_IMETHOD GetResponseSynthesized(bool* aSynthesized) override;
|
||||
bool AwaitingCacheCallbacks();
|
||||
void SetCouldBeSynthesized();
|
||||
|
@ -558,20 +556,6 @@ private:
|
|||
// telemetry in nsHttpChannel::OnStartRequest().
|
||||
uint32_t mSuspendTotalTime;
|
||||
|
||||
// States of channel interception
|
||||
enum {
|
||||
DO_NOT_INTERCEPT, // no interception will occur
|
||||
MAYBE_INTERCEPT, // interception in progress, but can be cancelled
|
||||
INTERCEPTED, // a synthesized response has been provided
|
||||
} mInterceptCache;
|
||||
// ID of this channel for the interception purposes. Unique unless this
|
||||
// channel is replacing an intercepted one via an redirection.
|
||||
uint64_t mInterceptionID;
|
||||
|
||||
bool PossiblyIntercepted() {
|
||||
return mInterceptCache != DO_NOT_INTERCEPT;
|
||||
}
|
||||
|
||||
// If the channel is associated with a cache, and the URI matched
|
||||
// a fallback namespace, this will hold the key for the fallback
|
||||
// cache entry.
|
||||
|
|
|
@ -225,13 +225,6 @@ interface nsIHttpChannelInternal : nsISupports
|
|||
|
||||
[must_use] readonly attribute PRTime lastModifiedTime;
|
||||
|
||||
/**
|
||||
* Force a channel that has not been AsyncOpen'ed to skip any check for possible
|
||||
* interception and proceed immediately to open a previously-synthesized cache
|
||||
* entry using the provided ID.
|
||||
*/
|
||||
[must_use] void forceIntercepted(in uint64_t aInterceptionID);
|
||||
|
||||
[must_use] readonly attribute boolean responseSynthesized;
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче