Bug 1409156 - Do not prefetch tracking resources. r=valentin

MozReview-Commit-ID: IKKHOLd2b4Y

--HG--
extra : rebase_source : 93c402435d67ed5cb0b2d84bc401ca6e058abd5a
This commit is contained in:
Nicholas Hurley 2017-08-07 12:45:49 -07:00
Родитель 2a020d2e77
Коммит e1ff7a7d15
3 изменённых файлов: 18 добавлений и 9 удалений

Просмотреть файл

@ -2586,7 +2586,7 @@ Predictor::UpdateCacheability(nsIURI *sourceURI, nsIURI *targetURI,
uint32_t httpStatus,
nsHttpRequestHead &requestHead,
nsHttpResponseHead *responseHead,
nsILoadContextInfo *lci)
nsILoadContextInfo *lci, bool isTracking)
{
MOZ_ASSERT(NS_IsMainThread());
@ -2610,7 +2610,8 @@ Predictor::UpdateCacheability(nsIURI *sourceURI, nsIURI *targetURI,
nsAutoCString method;
requestHead.Method(method);
self->UpdateCacheabilityInternal(sourceURI, targetURI, httpStatus,
method, *lci->OriginAttributesPtr());
method, *lci->OriginAttributesPtr(),
isTracking);
}
}
@ -2618,7 +2619,8 @@ void
Predictor::UpdateCacheabilityInternal(nsIURI *sourceURI, nsIURI *targetURI,
uint32_t httpStatus,
const nsCString &method,
const OriginAttributes& originAttributes)
const OriginAttributes& originAttributes,
bool isTracking)
{
PREDICTOR_LOG(("Predictor::UpdateCacheability httpStatus=%u", httpStatus));
@ -2655,7 +2657,8 @@ Predictor::UpdateCacheabilityInternal(nsIURI *sourceURI, nsIURI *targetURI,
nsICacheStorage::OPEN_SECRETLY |
nsICacheStorage::CHECK_MULTITHREADED;
RefPtr<Predictor::CacheabilityAction> action =
new Predictor::CacheabilityAction(targetURI, httpStatus, method, this);
new Predictor::CacheabilityAction(targetURI, httpStatus, method, isTracking,
this);
nsAutoCString uri;
targetURI->GetAsciiSpec(uri);
PREDICTOR_LOG((" uri=%s action=%p", uri.get(), action.get()));
@ -2730,7 +2733,9 @@ Predictor::CacheabilityAction::OnCacheEntryAvailable(nsICacheEntry *entry,
}
if (strTargetURI.Equals(uri)) {
if (mHttpStatus == 200 && mMethod.EqualsLiteral("GET") && !hasQueryString) {
if (mHttpStatus == 200 && mMethod.EqualsLiteral("GET") &&
!hasQueryString &&
!mIsTracking) {
PREDICTOR_LOG((" marking %s cacheable", key));
flags |= FLAG_PREFETCHABLE;
} else {

Просмотреть файл

@ -66,7 +66,7 @@ public:
uint32_t httpStatus,
nsHttpRequestHead &requestHead,
nsHttpResponseHead *reqponseHead,
nsILoadContextInfo *lci);
nsILoadContextInfo *lci, bool isTracking);
private:
virtual ~Predictor();
@ -139,10 +139,12 @@ private:
NS_DECL_NSICACHEENTRYMETADATAVISITOR
CacheabilityAction(nsIURI *targetURI, uint32_t httpStatus,
const nsCString &method, Predictor *predictor)
const nsCString &method, bool isTracking,
Predictor *predictor)
:mTargetURI(targetURI)
,mHttpStatus(httpStatus)
,mMethod(method)
,mIsTracking(isTracking)
,mPredictor(predictor)
{ }
@ -152,6 +154,7 @@ private:
nsCOMPtr<nsIURI> mTargetURI;
uint32_t mHttpStatus;
nsCString mMethod;
bool mIsTracking;
RefPtr<Predictor> mPredictor;
nsTArray<nsCString> mKeysToCheck;
nsTArray<nsCString> mValuesToCheck;
@ -422,7 +425,8 @@ private:
// and httpStatus is the status code we got while loading targetURI.
void UpdateCacheabilityInternal(nsIURI *sourceURI, nsIURI *targetURI,
uint32_t httpStatus, const nsCString &method,
const OriginAttributes& originAttributes);
const OriginAttributes& originAttributes,
bool isTracking);
// Make sure our prefs are in their expected range of values
void SanitizePrefs();

Просмотреть файл

@ -2354,7 +2354,7 @@ nsHttpChannel::ProcessResponse()
nsCOMPtr<nsILoadContextInfo> lci = GetLoadContextInfo(this);
mozilla::net::Predictor::UpdateCacheability(referrer, mURI, httpStatus,
mRequestHead, mResponseHead,
lci);
lci, mIsTrackingResource);
}
if (mTransaction && mTransaction->ProxyConnectFailed()) {