Bug 552605 - Change "must validate if expired" to "must always validate" in the image cache, to fit with the spirit of the HTTP spec. r=jrmuizel f=bz

This commit is contained in:
Joe Drew 2011-06-30 21:58:28 -04:00
Родитель 0c52f54aa3
Коммит 7982ac318d
3 изменённых файлов: 14 добавлений и 16 удалений

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

@ -401,7 +401,7 @@ static PRBool NewRequestAndEntry(nsIURI *uri, imgRequest **request, imgCacheEntr
if (!*request)
return PR_FALSE;
*entry = new imgCacheEntry(*request, /* mustValidateIfExpired = */ isFile);
*entry = new imgCacheEntry(*request, /* mustValidate = */ isFile);
if (!*entry) {
delete *request;
return PR_FALSE;
@ -425,6 +425,9 @@ static PRBool ShouldRevalidateEntry(imgCacheEntry *aEntry,
if (aFlags & nsIRequest::VALIDATE_ALWAYS) {
bValidateEntry = PR_TRUE;
}
else if (aEntry->GetMustValidate()) {
bValidateEntry = PR_TRUE;
}
//
// The cache entry has expired... Determine whether the stale cache
// entry can be used without validation...
@ -438,7 +441,7 @@ static PRBool ShouldRevalidateEntry(imgCacheEntry *aEntry,
if (aFlags & (nsIRequest::VALIDATE_NEVER |
nsIRequest::VALIDATE_ONCE_PER_SESSION))
{
bValidateEntry = aEntry->GetMustValidateIfExpired();
bValidateEntry = PR_FALSE;
}
//
// LOAD_FROM_CACHE allows a stale cache entry to be used... Otherwise,
@ -526,12 +529,12 @@ static PRUint32 SecondsFromPRTime(PRTime prTime)
return PRUint32(PRInt64(prTime) / PRInt64(PR_USEC_PER_SEC));
}
imgCacheEntry::imgCacheEntry(imgRequest *request, PRBool mustValidateIfExpired /* = PR_FALSE */)
imgCacheEntry::imgCacheEntry(imgRequest *request, PRBool mustValidate /* = PR_FALSE */)
: mRequest(request),
mDataSize(0),
mTouchedTime(SecondsFromPRTime(PR_Now())),
mExpiryTime(0),
mMustValidateIfExpired(mustValidateIfExpired),
mMustValidate(mustValidate),
mEvicted(PR_FALSE),
mHasNoProxies(PR_TRUE)
{}

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

@ -123,13 +123,13 @@ public:
Touch();
}
PRBool GetMustValidateIfExpired() const
PRBool GetMustValidate() const
{
return mMustValidateIfExpired;
return mMustValidate;
}
void SetMustValidateIfExpired(PRBool aValidate)
void SetMustValidate(PRBool aValidate)
{
mMustValidateIfExpired = aValidate;
mMustValidate = aValidate;
Touch();
}
@ -178,7 +178,7 @@ private: // data
PRInt32 mTouchedTime;
PRInt32 mExpiryTime;
nsExpirationState mExpirationState;
PRPackedBool mMustValidateIfExpired : 1;
PRPackedBool mMustValidate : 1;
PRPackedBool mEvicted : 1;
PRPackedBool mHasNoProxies : 1;
};

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

@ -530,13 +530,8 @@ void imgRequest::SetCacheValidation(imgCacheEntry* aCacheEntry, nsIRequest* aReq
}
}
//
// Determine whether the cache entry must be revalidated when it expires.
// If so, then the cache entry must *not* be used during HISTORY loads if
// it has expired.
//
// Determine whether the cache entry must be revalidated when we try to use it.
// Currently, only HTTP specifies this information...
//
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aRequest));
if (httpChannel) {
PRBool bMustRevalidate = PR_FALSE;
@ -561,7 +556,7 @@ void imgRequest::SetCacheValidation(imgCacheEntry* aCacheEntry, nsIRequest* aReq
// multiple calls to this function don't override an earlier decision to
// validate by making validation a one-way decision.
if (bMustRevalidate)
aCacheEntry->SetMustValidateIfExpired(bMustRevalidate);
aCacheEntry->SetMustValidate(bMustRevalidate);
}
}
}