mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 781866 - Clear up and simplify some names in localStorage code. r=honzab
This commit is contained in:
parent
50c0691da8
commit
0bccffdf13
@ -37,7 +37,7 @@ parent:
|
||||
|
||||
Init(bool useDB, bool sessionOnly, bool isPrivate,
|
||||
nsCString domain, nsCString scopeDBKey,
|
||||
nsCString quotaETLDplus1DomainDBKey, uint32_t storageType);
|
||||
nsCString quotaDBKey, uint32_t storageType);
|
||||
|
||||
sync GetKeys(bool callerSecure)
|
||||
returns (nsString[] keys);
|
||||
|
@ -84,7 +84,7 @@ StorageChild::InitRemote()
|
||||
AddIPDLReference();
|
||||
child->SendPStorageConstructor(this, null_t());
|
||||
SendInit(mUseDB, mSessionOnly, mInPrivateBrowsing, mDomain, mScopeDBKey,
|
||||
mQuotaETLDplus1DomainDBKey, mStorageType);
|
||||
mQuotaDBKey, mStorageType);
|
||||
}
|
||||
|
||||
void
|
||||
@ -234,7 +234,7 @@ StorageChild::CloneFrom(bool aCallerSecure, DOMStorageBase* aThat)
|
||||
AddIPDLReference();
|
||||
child->SendPStorageConstructor(this, clone);
|
||||
SendInit(mUseDB, mSessionOnly, mInPrivateBrowsing, mDomain,
|
||||
mScopeDBKey, mQuotaETLDplus1DomainDBKey, mStorageType);
|
||||
mScopeDBKey, mQuotaDBKey, mStorageType);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -32,11 +32,11 @@ StorageParent::RecvInit(const bool& aUseDB,
|
||||
const bool& aPrivate,
|
||||
const nsCString& aDomain,
|
||||
const nsCString& aScopeDBKey,
|
||||
const nsCString& aQuotaETLDplus1DomainDBKey,
|
||||
const nsCString& aQuotaDBKey,
|
||||
const uint32_t& aStorageType)
|
||||
{
|
||||
mStorage->InitFromChild(aUseDB, aSessionOnly, aPrivate, aDomain,
|
||||
aScopeDBKey, aQuotaETLDplus1DomainDBKey,
|
||||
aScopeDBKey, aQuotaDBKey,
|
||||
aStorageType);
|
||||
return true;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ private:
|
||||
const bool& aPrivate,
|
||||
const nsCString& aDomain,
|
||||
const nsCString& aScopeDBKey,
|
||||
const nsCString& aQuotaETLDplus1DomainDBKey,
|
||||
const nsCString& aQuotaDBKey,
|
||||
const uint32_t& aStorageType);
|
||||
|
||||
bool RecvUpdatePrivateState(const bool& aEnabled);
|
||||
|
@ -303,7 +303,7 @@ nsDOMStorageManager::Observe(nsISupports *aSubject,
|
||||
}
|
||||
|
||||
nsAutoCString key;
|
||||
rv = nsDOMStorageDBWrapper::CreateDomainScopeDBKey(aceDomain, key);
|
||||
rv = nsDOMStorageDBWrapper::CreateReversedDomain(aceDomain, key);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Clear the storage entries for matching domains
|
||||
@ -462,7 +462,7 @@ DOMStorageBase::DOMStorageBase(DOMStorageBase& aThat)
|
||||
, mSessionOnly(true)
|
||||
, mDomain(aThat.mDomain)
|
||||
, mScopeDBKey(aThat.mScopeDBKey)
|
||||
, mQuotaETLDplus1DomainDBKey(aThat.mQuotaETLDplus1DomainDBKey)
|
||||
, mQuotaDBKey(aThat.mQuotaDBKey)
|
||||
, mInPrivateBrowsing(aThat.mInPrivateBrowsing)
|
||||
{
|
||||
}
|
||||
@ -495,7 +495,7 @@ DOMStorageBase::InitAsLocalStorage(nsIURI* aDomainURI,
|
||||
// mPrincipal in bug 455070. It is not even used for localStorage.
|
||||
aDomainURI->GetAsciiHost(mDomain);
|
||||
|
||||
nsDOMStorageDBWrapper::CreateOriginScopeDBKey(aDomainURI, mScopeDBKey);
|
||||
nsDOMStorageDBWrapper::CreateScopeDBKey(aDomainURI, mScopeDBKey);
|
||||
|
||||
// XXX Bug 357323, we have to solve the issue how to define
|
||||
// origin for file URLs. In that case CreateOriginScopeDBKey
|
||||
@ -503,8 +503,7 @@ DOMStorageBase::InitAsLocalStorage(nsIURI* aDomainURI,
|
||||
// in that case because it produces broken entries w/o owner.
|
||||
mUseDB = !mScopeDBKey.IsEmpty();
|
||||
|
||||
nsDOMStorageDBWrapper::CreateQuotaDomainDBKey(mDomain,
|
||||
mQuotaETLDplus1DomainDBKey);
|
||||
nsDOMStorageDBWrapper::CreateQuotaDBKey(mDomain, mQuotaDBKey);
|
||||
mStorageType = nsPIDOMStorage::LocalStorage;
|
||||
mInPrivateBrowsing = aPrivate;
|
||||
}
|
||||
@ -593,7 +592,7 @@ DOMStorageImpl::InitFromChild(bool aUseDB,
|
||||
bool aSessionOnly, bool aPrivate,
|
||||
const nsACString& aDomain,
|
||||
const nsACString& aScopeDBKey,
|
||||
const nsACString& aQuotaETLDplus1DomainDBKey,
|
||||
const nsACString& aQuotaDBKey,
|
||||
uint32_t aStorageType)
|
||||
{
|
||||
mUseDB = aUseDB;
|
||||
@ -601,7 +600,7 @@ DOMStorageImpl::InitFromChild(bool aUseDB,
|
||||
mInPrivateBrowsing = aPrivate;
|
||||
mDomain = aDomain;
|
||||
mScopeDBKey = aScopeDBKey;
|
||||
mQuotaETLDplus1DomainDBKey = aQuotaETLDplus1DomainDBKey;
|
||||
mQuotaDBKey = aQuotaDBKey;
|
||||
mStorageType = static_cast<nsPIDOMStorage::nsDOMStorageType>(aStorageType);
|
||||
}
|
||||
|
||||
|
@ -167,9 +167,9 @@ public:
|
||||
nsCString& GetScopeDBKey() {return mScopeDBKey;}
|
||||
|
||||
// e.g. "moc.rab.%" - reversed eTLD+1 subpart of the domain.
|
||||
nsCString& GetQuotaDomainDBKey()
|
||||
nsCString& GetQuotaDBKey()
|
||||
{
|
||||
return mQuotaETLDplus1DomainDBKey;
|
||||
return mQuotaDBKey;
|
||||
}
|
||||
|
||||
virtual bool CacheStoragePermissions() = 0;
|
||||
@ -196,7 +196,7 @@ protected:
|
||||
// keys are used for database queries.
|
||||
// see comments of the getters bellow.
|
||||
nsCString mScopeDBKey;
|
||||
nsCString mQuotaETLDplus1DomainDBKey;
|
||||
nsCString mQuotaDBKey;
|
||||
|
||||
bool mInPrivateBrowsing;
|
||||
};
|
||||
@ -283,7 +283,7 @@ private:
|
||||
void InitFromChild(bool aUseDB, bool aSessionOnly,
|
||||
bool aPrivate, const nsACString& aDomain,
|
||||
const nsACString& aScopeDBKey,
|
||||
const nsACString& aQuotaETLDplus1DomainDBKey,
|
||||
const nsACString& aQuotaDBKey,
|
||||
uint32_t aStorageType);
|
||||
void SetSessionOnly(bool aSessionOnly);
|
||||
|
||||
|
@ -226,11 +226,11 @@ nsDOMStorageDBWrapper::GetUsage(const nsACString& aDomain,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMStorageDBWrapper::CreateOriginScopeDBKey(nsIURI* aUri, nsACString& aKey)
|
||||
nsDOMStorageDBWrapper::CreateScopeDBKey(nsIURI* aUri, nsACString& aKey)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
rv = CreateDomainScopeDBKey(aUri, aKey);
|
||||
rv = CreateReversedDomain(aUri, aKey);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@ -251,7 +251,7 @@ nsDOMStorageDBWrapper::CreateOriginScopeDBKey(nsIURI* aUri, nsACString& aKey)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMStorageDBWrapper::CreateDomainScopeDBKey(nsIURI* aUri, nsACString& aKey)
|
||||
nsDOMStorageDBWrapper::CreateReversedDomain(nsIURI* aUri, nsACString& aKey)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -280,15 +280,15 @@ nsDOMStorageDBWrapper::CreateDomainScopeDBKey(nsIURI* aUri, nsACString& aKey)
|
||||
}
|
||||
}
|
||||
|
||||
rv = CreateDomainScopeDBKey(domainScope, aKey);
|
||||
rv = CreateReversedDomain(domainScope, aKey);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMStorageDBWrapper::CreateDomainScopeDBKey(const nsACString& aAsciiDomain,
|
||||
nsACString& aKey)
|
||||
nsDOMStorageDBWrapper::CreateReversedDomain(const nsACString& aAsciiDomain,
|
||||
nsACString& aKey)
|
||||
{
|
||||
if (aAsciiDomain.IsEmpty())
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
@ -300,8 +300,8 @@ nsDOMStorageDBWrapper::CreateDomainScopeDBKey(const nsACString& aAsciiDomain,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMStorageDBWrapper::CreateQuotaDomainDBKey(const nsACString& aAsciiDomain,
|
||||
nsACString& aKey)
|
||||
nsDOMStorageDBWrapper::CreateQuotaDBKey(const nsACString& aAsciiDomain,
|
||||
nsACString& aKey)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -323,7 +323,7 @@ nsDOMStorageDBWrapper::CreateQuotaDomainDBKey(const nsACString& aAsciiDomain,
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
CreateDomainScopeDBKey(eTLDplusOne, subdomainsDBKey);
|
||||
CreateReversedDomain(eTLDplusOne, subdomainsDBKey);
|
||||
|
||||
aKey.Assign(subdomainsDBKey);
|
||||
return NS_OK;
|
||||
|
@ -138,7 +138,7 @@ public:
|
||||
RemoveAll();
|
||||
|
||||
/**
|
||||
* Returns usage for a storage using its GetQuotaDomainDBKey() as a key.
|
||||
* Returns usage for a storage using its GetQuotaDBKey() as a key.
|
||||
*/
|
||||
nsresult
|
||||
GetUsage(DOMStorageImpl* aStorage, int32_t *aUsage);
|
||||
@ -173,22 +173,22 @@ public:
|
||||
* i.e. reverses the host, appends a dot, appends the schema
|
||||
* and a port number.
|
||||
*/
|
||||
static nsresult CreateOriginScopeDBKey(nsIURI* aUri, nsACString& aKey);
|
||||
static nsresult CreateScopeDBKey(nsIURI* aUri, nsACString& aKey);
|
||||
|
||||
/**
|
||||
* Turns "http://foo.bar.com" to "moc.rab.oof.",
|
||||
* i.e. reverses the host and appends a dot.
|
||||
*/
|
||||
static nsresult CreateDomainScopeDBKey(nsIURI* aUri, nsACString& aKey);
|
||||
static nsresult CreateDomainScopeDBKey(const nsACString& aAsciiDomain, nsACString& aKey);
|
||||
static nsresult CreateReversedDomain(nsIURI* aUri, nsACString& aKey);
|
||||
static nsresult CreateReversedDomain(const nsACString& aAsciiDomain, nsACString& aKey);
|
||||
|
||||
/**
|
||||
* Turns "foo.bar.com" to "moc.rab.",
|
||||
* i.e. extracts eTLD+1 from the host, reverses the result
|
||||
* and appends a dot.
|
||||
*/
|
||||
static nsresult CreateQuotaDomainDBKey(const nsACString& aAsciiDomain,
|
||||
nsACString& aKey);
|
||||
static nsresult CreateQuotaDBKey(const nsACString& aAsciiDomain,
|
||||
nsACString& aKey);
|
||||
|
||||
static nsresult GetDomainFromScopeKey(const nsACString& aScope,
|
||||
nsACString& aDomain);
|
||||
|
@ -157,7 +157,7 @@ nsDOMStorageMemoryDB::SetKey(DOMStorageImpl* aStorage,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
int32_t usage = 0;
|
||||
if (!aStorage->GetQuotaDomainDBKey().IsEmpty()) {
|
||||
if (!aStorage->GetQuotaDBKey().IsEmpty()) {
|
||||
rv = GetUsage(aStorage, &usage);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
@ -300,7 +300,7 @@ nsresult
|
||||
nsDOMStorageMemoryDB::RemoveOwner(const nsACString& aOwner)
|
||||
{
|
||||
nsAutoCString subdomainsDBKey;
|
||||
nsDOMStorageDBWrapper::CreateDomainScopeDBKey(aOwner, subdomainsDBKey);
|
||||
nsDOMStorageDBWrapper::CreateReversedDomain(aOwner, subdomainsDBKey);
|
||||
|
||||
RemoveOwnersStruc struc;
|
||||
struc.mSubDomain = &subdomainsDBKey;
|
||||
@ -325,7 +325,7 @@ nsDOMStorageMemoryDB::RemoveAll()
|
||||
nsresult
|
||||
nsDOMStorageMemoryDB::GetUsage(DOMStorageImpl* aStorage, int32_t *aUsage)
|
||||
{
|
||||
return GetUsageInternal(aStorage->GetQuotaDomainDBKey(), aUsage);
|
||||
return GetUsageInternal(aStorage->GetQuotaDBKey(), aUsage);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -334,12 +334,11 @@ nsDOMStorageMemoryDB::GetUsage(const nsACString& aDomain,
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsAutoCString quotadomainDBKey;
|
||||
rv = nsDOMStorageDBWrapper::CreateQuotaDomainDBKey(aDomain,
|
||||
quotadomainDBKey);
|
||||
nsAutoCString quotaDBKey;
|
||||
rv = nsDOMStorageDBWrapper::CreateQuotaDBKey(aDomain, quotaDBKey);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return GetUsageInternal(quotadomainDBKey, aUsage);
|
||||
return GetUsageInternal(quotaDBKey, aUsage);
|
||||
}
|
||||
|
||||
struct GetUsageEnumStruc
|
||||
@ -363,17 +362,17 @@ GetUsageEnum(const nsACString& key,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMStorageMemoryDB::GetUsageInternal(const nsACString& aQuotaDomainDBKey,
|
||||
nsDOMStorageMemoryDB::GetUsageInternal(const nsACString& aQuotaDBKey,
|
||||
int32_t *aUsage)
|
||||
{
|
||||
GetUsageEnumStruc struc;
|
||||
struc.mUsage = 0;
|
||||
struc.mSubdomain = aQuotaDomainDBKey;
|
||||
struc.mSubdomain = aQuotaDBKey;
|
||||
|
||||
if (mPreloadDB) {
|
||||
nsresult rv;
|
||||
|
||||
rv = mPreloadDB->GetUsageInternal(aQuotaDomainDBKey, &struc.mUsage);
|
||||
rv = mPreloadDB->GetUsageInternal(aQuotaDBKey, &struc.mUsage);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ public:
|
||||
RemoveAll();
|
||||
|
||||
/**
|
||||
* Returns usage for a storage using its GetQuotaDomainDBKey() as a key.
|
||||
* Returns usage for a storage using its GetQuotaDBKey() as a key.
|
||||
*/
|
||||
nsresult
|
||||
GetUsage(DOMStorageImpl* aStorage, int32_t *aUsage);
|
||||
@ -139,7 +139,7 @@ protected:
|
||||
bool mPreloading;
|
||||
|
||||
nsresult
|
||||
GetUsageInternal(const nsACString& aQuotaDomainDBKey, int32_t *aUsage);
|
||||
GetUsageInternal(const nsACString& aQuotaDBKey, int32_t *aUsage);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -441,7 +441,7 @@ nsDOMStoragePersistentDB::SetKey(DOMStorageImpl* aStorage,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
int32_t usage = 0;
|
||||
if (!aStorage->GetQuotaDomainDBKey().IsEmpty()) {
|
||||
if (!aStorage->GetQuotaDBKey().IsEmpty()) {
|
||||
rv = GetUsage(aStorage, &usage);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
@ -487,7 +487,7 @@ nsDOMStoragePersistentDB::SetKey(DOMStorageImpl* aStorage,
|
||||
rv = stmt->Execute();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!aStorage->GetQuotaDomainDBKey().IsEmpty()) {
|
||||
if (!aStorage->GetQuotaDBKey().IsEmpty()) {
|
||||
// No need to set mCachedOwner since it was set by GetUsage()
|
||||
mCachedUsage = usage;
|
||||
}
|
||||
@ -555,7 +555,7 @@ nsDOMStoragePersistentDB::RemoveKey(DOMStorageImpl* aStorage,
|
||||
mozStorageStatementScoper scope(stmt);
|
||||
|
||||
if (DomainMaybeCached(
|
||||
aStorage->GetQuotaDomainDBKey())) {
|
||||
aStorage->GetQuotaDBKey())) {
|
||||
mCachedUsage = 0;
|
||||
mCachedOwner.Truncate();
|
||||
}
|
||||
@ -621,7 +621,7 @@ nsDOMStoragePersistentDB::RemoveOwner(const nsACString& aOwner)
|
||||
mozStorageStatementScoper scope(stmt);
|
||||
|
||||
nsAutoCString subdomainsDBKey;
|
||||
nsDOMStorageDBWrapper::CreateDomainScopeDBKey(aOwner, subdomainsDBKey);
|
||||
nsDOMStorageDBWrapper::CreateReversedDomain(aOwner, subdomainsDBKey);
|
||||
|
||||
if (DomainMaybeCached(subdomainsDBKey)) {
|
||||
mCachedUsage = 0;
|
||||
@ -668,7 +668,7 @@ nsresult
|
||||
nsDOMStoragePersistentDB::GetUsage(DOMStorageImpl* aStorage,
|
||||
int32_t *aUsage)
|
||||
{
|
||||
return GetUsageInternal(aStorage->GetQuotaDomainDBKey(), aUsage);
|
||||
return GetUsageInternal(aStorage->GetQuotaDBKey(), aUsage);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -677,19 +677,18 @@ nsDOMStoragePersistentDB::GetUsage(const nsACString& aDomain,
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsAutoCString quotadomainDBKey;
|
||||
rv = nsDOMStorageDBWrapper::CreateQuotaDomainDBKey(aDomain,
|
||||
quotadomainDBKey);
|
||||
nsAutoCString quotaDBKey;
|
||||
rv = nsDOMStorageDBWrapper::CreateQuotaDBKey(aDomain, quotaDBKey);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return GetUsageInternal(quotadomainDBKey, aUsage);
|
||||
return GetUsageInternal(quotaDBKey, aUsage);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMStoragePersistentDB::GetUsageInternal(const nsACString& aQuotaDomainDBKey,
|
||||
nsDOMStoragePersistentDB::GetUsageInternal(const nsACString& aQuotaDBKey,
|
||||
int32_t *aUsage)
|
||||
{
|
||||
if (aQuotaDomainDBKey == mCachedOwner) {
|
||||
if (aQuotaDBKey == mCachedOwner) {
|
||||
*aUsage = mCachedUsage;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -719,7 +718,7 @@ nsDOMStoragePersistentDB::GetUsageInternal(const nsACString& aQuotaDomainDBKey,
|
||||
NS_ENSURE_STATE(stmt);
|
||||
mozStorageStatementScoper scope(stmt);
|
||||
|
||||
nsAutoCString scopeValue(aQuotaDomainDBKey);
|
||||
nsAutoCString scopeValue(aQuotaDBKey);
|
||||
scopeValue += NS_LITERAL_CSTRING("*");
|
||||
|
||||
rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("scope"), scopeValue);
|
||||
@ -737,8 +736,8 @@ nsDOMStoragePersistentDB::GetUsageInternal(const nsACString& aQuotaDomainDBKey,
|
||||
rv = stmt->GetInt32(0, aUsage);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!aQuotaDomainDBKey.IsEmpty()) {
|
||||
mCachedOwner = aQuotaDomainDBKey;
|
||||
if (!aQuotaDBKey.IsEmpty()) {
|
||||
mCachedOwner = aQuotaDBKey;
|
||||
mCachedUsage = *aUsage;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
RemoveAll();
|
||||
|
||||
/**
|
||||
* Returns usage for a storage using its GetQuotaDomainDBKey() as a key.
|
||||
* Returns usage for a storage using its GetQuotaDBKey() as a key.
|
||||
*/
|
||||
nsresult
|
||||
GetUsage(DOMStorageImpl* aStorage, int32_t *aUsage);
|
||||
@ -161,7 +161,7 @@ protected:
|
||||
friend class nsDOMStorageDBWrapper;
|
||||
friend class nsDOMStorageMemoryDB;
|
||||
nsresult
|
||||
GetUsageInternal(const nsACString& aQuotaDomainDBKey, int32_t *aUsage);
|
||||
GetUsageInternal(const nsACString& aQuotaDBKey, int32_t *aUsage);
|
||||
|
||||
// Compares aDomain with the mCachedOwner and returns false if changes
|
||||
// in aDomain don't affect mCachedUsage.
|
||||
|
Loading…
Reference in New Issue
Block a user