Bug 1396307 - Set mCacheAsyncOpenCalled back to flase when AsyncOpenURI fails r=michal
MozReview-Commit-ID: VnwI3ERHVt
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -3974,26 +3974,33 @@ nsHttpChannel::OpenCacheEntry(bool isHtt
if (!mCacheOpenDelay) {
MOZ_ASSERT(NS_IsMainThread(), "Should be called on the main thread");
mCacheAsyncOpenCalled = true;
if (mNetworkTriggered) {
mRaceCacheWithNetwork = sRCWNEnabled;
}
rv = cacheStorage->AsyncOpenURI(openURI, extension, cacheEntryOpenFlags, this);
+ if (NS_FAILED(rv)) {
+ // Drop the flag since the cache open failed
+ mCacheAsyncOpenCalled = false;
+ }
} 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");
self->mCacheAsyncOpenCalled = true;
if (self->mNetworkTriggered) {
self->mRaceCacheWithNetwork = true;
}
- cacheStorage->AsyncOpenURI(openURI, extension, cacheEntryOpenFlags, self);
+ nsresult rv = cacheStorage->AsyncOpenURI(openURI, extension, cacheEntryOpenFlags, self);
+ if (NS_FAILED(rv)) {
+ self->mCacheAsyncOpenCalled = false;
+ }
};
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);