Bug 1416774 - Ensure that imgRequestProxy::CancelAndForgetObserver removes itself from the cache validator. r=tnikkel

An imgRequestProxy may defer notifications when it needs to block on an
imgCacheValidator. It may also be cancelled before the validator has
completed its operation, but before this change, we did not remove the
request from the set of proxies, imgCacheValidator::mProxies. When the
deferral was completed, it would assert to ensure each proxy was still
expecting a deferral before issuing the notifications. Cancelling a
request can actually reset that state, which means we fail the assert.

Failing the assert is actually harmless; in release we suffer no
negative consequences as a result of this sequence of events. Now we
just remove the proxy from the validator set to avoid asserting.
This commit is contained in:
Andrew Osmond 2017-11-14 12:02:59 -05:00
parent 3898a0e472
commit a230c70963
3 changed files with 15 additions and 2 deletions

View File

@ -2908,6 +2908,12 @@ imgCacheValidator::AddProxy(imgRequestProxy* aProxy)
mProxies.AppendObject(aProxy);
}
void
imgCacheValidator::RemoveProxy(imgRequestProxy* aProxy)
{
mProxies.RemoveObject(aProxy);
}
/** nsIRequestObserver methods **/
NS_IMETHODIMP

View File

@ -555,6 +555,7 @@ public:
bool forcePrincipalCheckForCacheEntry);
void AddProxy(imgRequestProxy* aProxy);
void RemoveProxy(imgRequestProxy* aProxy);
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER

View File

@ -517,8 +517,14 @@ imgRequestProxy::CancelAndForgetObserver(nsresult aStatus)
mCanceled = true;
mForceDispatchLoadGroup = true;
if (GetOwner()) {
GetOwner()->RemoveProxy(this, aStatus);
imgRequest* owner = GetOwner();
if (owner) {
imgCacheValidator* validator = owner->GetValidator();
if (validator) {
validator->RemoveProxy(this);
}
owner->RemoveProxy(this, aStatus);
}
RemoveFromLoadGroup();