зеркало из https://github.com/mozilla/pjs.git
Bug 707915 - Broken invalidation of mCachedUsage in nsDOMStoragePersistentDB
This commit is contained in:
Родитель
ebec881be7
Коммит
0643e829e6
|
@ -744,7 +744,7 @@ nsDOMStoragePersistentDB::SetKey(DOMStorageImpl* aStorage,
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (!aStorage->GetQuotaDomainDBKey(!aExcludeOfflineFromUsage).IsEmpty()) {
|
if (!aStorage->GetQuotaDomainDBKey(!aExcludeOfflineFromUsage).IsEmpty()) {
|
||||||
mCachedOwner = aStorage->GetQuotaDomainDBKey(!aExcludeOfflineFromUsage);
|
// No need to set mCachedOwner since it was set by GetUsage()
|
||||||
mCachedUsage = usage;
|
mCachedUsage = usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,8 +807,10 @@ nsDOMStoragePersistentDB::RemoveKey(DOMStorageImpl* aStorage,
|
||||||
|
|
||||||
mozStorageStatementScoper scope(mRemoveKeyStatement);
|
mozStorageStatementScoper scope(mRemoveKeyStatement);
|
||||||
|
|
||||||
if (aStorage->GetQuotaDomainDBKey(!aExcludeOfflineFromUsage) == mCachedOwner) {
|
if (DomainMaybeCached(
|
||||||
mCachedUsage -= aKeyUsage;
|
aStorage->GetQuotaDomainDBKey(!aExcludeOfflineFromUsage))) {
|
||||||
|
mCachedUsage = 0;
|
||||||
|
mCachedOwner.Truncate();
|
||||||
}
|
}
|
||||||
|
|
||||||
Binder binder(mRemoveKeyStatement, &rv);
|
Binder binder(mRemoveKeyStatement, &rv);
|
||||||
|
@ -877,15 +879,15 @@ nsDOMStoragePersistentDB::RemoveOwner(const nsACString& aOwner,
|
||||||
nsCAutoString subdomainsDBKey;
|
nsCAutoString subdomainsDBKey;
|
||||||
nsDOMStorageDBWrapper::CreateDomainScopeDBKey(aOwner, subdomainsDBKey);
|
nsDOMStorageDBWrapper::CreateDomainScopeDBKey(aOwner, subdomainsDBKey);
|
||||||
|
|
||||||
if (!aIncludeSubDomains)
|
if (DomainMaybeCached(subdomainsDBKey)) {
|
||||||
subdomainsDBKey.AppendLiteral(":");
|
|
||||||
subdomainsDBKey.AppendLiteral("*");
|
|
||||||
|
|
||||||
if (subdomainsDBKey == mCachedOwner) {
|
|
||||||
mCachedUsage = 0;
|
mCachedUsage = 0;
|
||||||
mCachedOwner.Truncate();
|
mCachedOwner.Truncate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!aIncludeSubDomains)
|
||||||
|
subdomainsDBKey.AppendLiteral(":");
|
||||||
|
subdomainsDBKey.AppendLiteral("*");
|
||||||
|
|
||||||
Binder binder(mRemoveOwnerStatement, &rv);
|
Binder binder(mRemoveOwnerStatement, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
@ -960,6 +962,11 @@ nsDOMStoragePersistentDB::RemoveOwners(const nsTArray<nsString> &aOwners,
|
||||||
rv = nsDOMStorageDBWrapper::CreateDomainScopeDBKey(
|
rv = nsDOMStorageDBWrapper::CreateDomainScopeDBKey(
|
||||||
NS_ConvertUTF16toUTF8(aOwners[i]), quotaKey);
|
NS_ConvertUTF16toUTF8(aOwners[i]), quotaKey);
|
||||||
|
|
||||||
|
if (DomainMaybeCached(quotaKey)) {
|
||||||
|
mCachedUsage = 0;
|
||||||
|
mCachedOwner.Truncate();
|
||||||
|
}
|
||||||
|
|
||||||
if (!aIncludeSubDomains)
|
if (!aIncludeSubDomains)
|
||||||
quotaKey.AppendLiteral(":");
|
quotaKey.AppendLiteral(":");
|
||||||
quotaKey.AppendLiteral("*");
|
quotaKey.AppendLiteral("*");
|
||||||
|
@ -1120,3 +1127,17 @@ nsDOMStoragePersistentDB::MaybeCommitInsertTransaction()
|
||||||
|
|
||||||
return NS_OK;
|
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;
|
friend class nsDOMStorageMemoryDB;
|
||||||
nsresult
|
nsresult
|
||||||
GetUsageInternal(const nsACString& aQuotaDomainDBKey, bool aExcludeOfflineFromUsage, PRInt32 *aUsage);
|
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___ */
|
#endif /* nsDOMStorageDB_h___ */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче