mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 707915 - Broken invalidation of mCachedUsage in nsDOMStoragePersistentDB
This commit is contained in:
parent
3555280633
commit
591fb05e38
@ -744,7 +744,7 @@ nsDOMStoragePersistentDB::SetKey(DOMStorageImpl* aStorage,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!aStorage->GetQuotaDomainDBKey(!aExcludeOfflineFromUsage).IsEmpty()) {
|
||||
mCachedOwner = aStorage->GetQuotaDomainDBKey(!aExcludeOfflineFromUsage);
|
||||
// No need to set mCachedOwner since it was set by GetUsage()
|
||||
mCachedUsage = usage;
|
||||
}
|
||||
|
||||
@ -807,8 +807,10 @@ nsDOMStoragePersistentDB::RemoveKey(DOMStorageImpl* aStorage,
|
||||
|
||||
mozStorageStatementScoper scope(mRemoveKeyStatement);
|
||||
|
||||
if (aStorage->GetQuotaDomainDBKey(!aExcludeOfflineFromUsage) == mCachedOwner) {
|
||||
mCachedUsage -= aKeyUsage;
|
||||
if (DomainMaybeCached(
|
||||
aStorage->GetQuotaDomainDBKey(!aExcludeOfflineFromUsage))) {
|
||||
mCachedUsage = 0;
|
||||
mCachedOwner.Truncate();
|
||||
}
|
||||
|
||||
Binder binder(mRemoveKeyStatement, &rv);
|
||||
@ -877,15 +879,15 @@ nsDOMStoragePersistentDB::RemoveOwner(const nsACString& aOwner,
|
||||
nsCAutoString subdomainsDBKey;
|
||||
nsDOMStorageDBWrapper::CreateDomainScopeDBKey(aOwner, subdomainsDBKey);
|
||||
|
||||
if (!aIncludeSubDomains)
|
||||
subdomainsDBKey.AppendLiteral(":");
|
||||
subdomainsDBKey.AppendLiteral("*");
|
||||
|
||||
if (subdomainsDBKey == mCachedOwner) {
|
||||
if (DomainMaybeCached(subdomainsDBKey)) {
|
||||
mCachedUsage = 0;
|
||||
mCachedOwner.Truncate();
|
||||
}
|
||||
|
||||
if (!aIncludeSubDomains)
|
||||
subdomainsDBKey.AppendLiteral(":");
|
||||
subdomainsDBKey.AppendLiteral("*");
|
||||
|
||||
Binder binder(mRemoveOwnerStatement, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -960,6 +962,11 @@ nsDOMStoragePersistentDB::RemoveOwners(const nsTArray<nsString> &aOwners,
|
||||
rv = nsDOMStorageDBWrapper::CreateDomainScopeDBKey(
|
||||
NS_ConvertUTF16toUTF8(aOwners[i]), quotaKey);
|
||||
|
||||
if (DomainMaybeCached(quotaKey)) {
|
||||
mCachedUsage = 0;
|
||||
mCachedOwner.Truncate();
|
||||
}
|
||||
|
||||
if (!aIncludeSubDomains)
|
||||
quotaKey.AppendLiteral(":");
|
||||
quotaKey.AppendLiteral("*");
|
||||
@ -1120,3 +1127,17 @@ nsDOMStoragePersistentDB::MaybeCommitInsertTransaction()
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDOMStoragePersistentDB::DomainMaybeCached(const nsACString& aDomain)
|
||||
{
|
||||
if (mCachedOwner.IsEmpty())
|
||||
return false;
|
||||
|
||||
// if cached owner contains colon we must ignore it
|
||||
if (mCachedOwner[mCachedOwner.Length() - 1] == ':')
|
||||
return StringBeginsWith(aDomain, Substring(mCachedOwner, 0,
|
||||
mCachedOwner.Length() - 1));
|
||||
else
|
||||
return StringBeginsWith(aDomain, mCachedOwner);
|
||||
}
|
||||
|
@ -219,6 +219,11 @@ protected:
|
||||
friend class nsDOMStorageMemoryDB;
|
||||
nsresult
|
||||
GetUsageInternal(const nsACString& aQuotaDomainDBKey, bool aExcludeOfflineFromUsage, PRInt32 *aUsage);
|
||||
|
||||
// Compares aDomain with the mCachedOwner and returns false if changes
|
||||
// in aDomain don't affect mCachedUsage.
|
||||
bool DomainMaybeCached(const nsACString& aDomain);
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsDOMStorageDB_h___ */
|
||||
|
Loading…
Reference in New Issue
Block a user