Bug 1525245 - Stabilize cookiePolicy/cookiePermission for live documents - part 3 - LocalStorage and SessionStorage, r=asuth

Differential Revision: https://phabricator.services.mozilla.com/D18951
This commit is contained in:
Andrea Marchesini
2019-03-06 17:00:54 +00:00
parent 66e8a3bf0d
commit fd1b4522c2
11 changed files with 58 additions and 228 deletions

View File

@@ -9,7 +9,7 @@
namespace mozilla {
namespace dom {
SessionStorageCache::SessionStorageCache() : mSessionDataSetActive(false) {}
SessionStorageCache::SessionStorageCache() = default;
SessionStorageCache::DataSet* SessionStorageCache::Set(
DataSetType aDataSetType) {
@@ -19,16 +19,6 @@ SessionStorageCache::DataSet* SessionStorageCache::Set(
MOZ_ASSERT(aDataSetType == eSessionSetType);
if (!mSessionDataSetActive) {
mSessionSet.mOriginQuotaUsage = mDefaultSet.mOriginQuotaUsage;
for (auto iter = mDefaultSet.mKeys.ConstIter(); !iter.Done(); iter.Next()) {
mSessionSet.mKeys.Put(iter.Key(), iter.Data());
}
mSessionDataSetActive = true;
}
return &mSessionSet;
}
@@ -121,17 +111,11 @@ void SessionStorageCache::Clear(DataSetType aDataSetType,
DataSet* dataSet = Set(aDataSetType);
dataSet->ProcessUsageDelta(-dataSet->mOriginQuotaUsage);
dataSet->mKeys.Clear();
if (!aByUserInteraction && aDataSetType == eSessionSetType) {
mSessionDataSetActive = false;
}
}
already_AddRefed<SessionStorageCache> SessionStorageCache::Clone() const {
RefPtr<SessionStorageCache> cache = new SessionStorageCache();
cache->mSessionDataSetActive = mSessionDataSetActive;
cache->mDefaultSet.mOriginQuotaUsage = mDefaultSet.mOriginQuotaUsage;
for (auto iter = mDefaultSet.mKeys.ConstIter(); !iter.Done(); iter.Next()) {
cache->mDefaultSet.mKeys.Put(iter.Key(), iter.Data());