зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
0c52f54aa3
Коммит
7982ac318d
|
@ -401,7 +401,7 @@ static PRBool NewRequestAndEntry(nsIURI *uri, imgRequest **request, imgCacheEntr
|
||||||
if (!*request)
|
if (!*request)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
|
|
||||||
*entry = new imgCacheEntry(*request, /* mustValidateIfExpired = */ isFile);
|
*entry = new imgCacheEntry(*request, /* mustValidate = */ isFile);
|
||||||
if (!*entry) {
|
if (!*entry) {
|
||||||
delete *request;
|
delete *request;
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
|
@ -425,6 +425,9 @@ static PRBool ShouldRevalidateEntry(imgCacheEntry *aEntry,
|
||||||
if (aFlags & nsIRequest::VALIDATE_ALWAYS) {
|
if (aFlags & nsIRequest::VALIDATE_ALWAYS) {
|
||||||
bValidateEntry = PR_TRUE;
|
bValidateEntry = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
else if (aEntry->GetMustValidate()) {
|
||||||
|
bValidateEntry = PR_TRUE;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// The cache entry has expired... Determine whether the stale cache
|
// The cache entry has expired... Determine whether the stale cache
|
||||||
// entry can be used without validation...
|
// entry can be used without validation...
|
||||||
|
@ -438,7 +441,7 @@ static PRBool ShouldRevalidateEntry(imgCacheEntry *aEntry,
|
||||||
if (aFlags & (nsIRequest::VALIDATE_NEVER |
|
if (aFlags & (nsIRequest::VALIDATE_NEVER |
|
||||||
nsIRequest::VALIDATE_ONCE_PER_SESSION))
|
nsIRequest::VALIDATE_ONCE_PER_SESSION))
|
||||||
{
|
{
|
||||||
bValidateEntry = aEntry->GetMustValidateIfExpired();
|
bValidateEntry = PR_FALSE;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// LOAD_FROM_CACHE allows a stale cache entry to be used... Otherwise,
|
// 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));
|
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),
|
: mRequest(request),
|
||||||
mDataSize(0),
|
mDataSize(0),
|
||||||
mTouchedTime(SecondsFromPRTime(PR_Now())),
|
mTouchedTime(SecondsFromPRTime(PR_Now())),
|
||||||
mExpiryTime(0),
|
mExpiryTime(0),
|
||||||
mMustValidateIfExpired(mustValidateIfExpired),
|
mMustValidate(mustValidate),
|
||||||
mEvicted(PR_FALSE),
|
mEvicted(PR_FALSE),
|
||||||
mHasNoProxies(PR_TRUE)
|
mHasNoProxies(PR_TRUE)
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -123,13 +123,13 @@ public:
|
||||||
Touch();
|
Touch();
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool GetMustValidateIfExpired() const
|
PRBool GetMustValidate() const
|
||||||
{
|
{
|
||||||
return mMustValidateIfExpired;
|
return mMustValidate;
|
||||||
}
|
}
|
||||||
void SetMustValidateIfExpired(PRBool aValidate)
|
void SetMustValidate(PRBool aValidate)
|
||||||
{
|
{
|
||||||
mMustValidateIfExpired = aValidate;
|
mMustValidate = aValidate;
|
||||||
Touch();
|
Touch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ private: // data
|
||||||
PRInt32 mTouchedTime;
|
PRInt32 mTouchedTime;
|
||||||
PRInt32 mExpiryTime;
|
PRInt32 mExpiryTime;
|
||||||
nsExpirationState mExpirationState;
|
nsExpirationState mExpirationState;
|
||||||
PRPackedBool mMustValidateIfExpired : 1;
|
PRPackedBool mMustValidate : 1;
|
||||||
PRPackedBool mEvicted : 1;
|
PRPackedBool mEvicted : 1;
|
||||||
PRPackedBool mHasNoProxies : 1;
|
PRPackedBool mHasNoProxies : 1;
|
||||||
};
|
};
|
||||||
|
|
|
@ -530,13 +530,8 @@ void imgRequest::SetCacheValidation(imgCacheEntry* aCacheEntry, nsIRequest* aReq
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Determine whether the cache entry must be revalidated when we try to use it.
|
||||||
// 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.
|
|
||||||
//
|
|
||||||
// Currently, only HTTP specifies this information...
|
// Currently, only HTTP specifies this information...
|
||||||
//
|
|
||||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aRequest));
|
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aRequest));
|
||||||
if (httpChannel) {
|
if (httpChannel) {
|
||||||
PRBool bMustRevalidate = PR_FALSE;
|
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
|
// multiple calls to this function don't override an earlier decision to
|
||||||
// validate by making validation a one-way decision.
|
// validate by making validation a one-way decision.
|
||||||
if (bMustRevalidate)
|
if (bMustRevalidate)
|
||||||
aCacheEntry->SetMustValidateIfExpired(bMustRevalidate);
|
aCacheEntry->SetMustValidate(bMustRevalidate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче