Bug 1311057 - Part 2: Remove isApp from quota manager and its clients; r=asuth

This commit is contained in:
Jan Varga 2017-03-06 18:38:42 +01:00
Родитель e161ee742d
Коммит dcc35b89e6
11 изменённых файлов: 94 добавлений и 224 удалений

Просмотреть файл

@ -351,7 +351,6 @@ public:
mWriteParams(aWriteParams), mWriteParams(aWriteParams),
mState(eInitial), mState(eInitial),
mResult(JS::AsmJSCache_InternalError), mResult(JS::AsmJSCache_InternalError),
mIsApp(false),
mEnforcingQuota(true), mEnforcingQuota(true),
mDeleteReceived(false), mDeleteReceived(false),
mActorDestroyed(false), mActorDestroyed(false),
@ -581,7 +580,6 @@ private:
State mState; State mState;
JS::AsmJSCacheResult mResult; JS::AsmJSCacheResult mResult;
bool mIsApp;
bool mEnforcingQuota; bool mEnforcingQuota;
bool mDeleteReceived; bool mDeleteReceived;
bool mActorDestroyed; bool mActorDestroyed;
@ -603,12 +601,11 @@ ParentRunnable::InitOnMainThread()
} }
rv = QuotaManager::GetInfoFromPrincipal(principal, &mSuffix, &mGroup, rv = QuotaManager::GetInfoFromPrincipal(principal, &mSuffix, &mGroup,
&mOrigin, &mIsApp); &mOrigin);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
mEnforcingQuota = mEnforcingQuota =
QuotaManager::IsQuotaEnforced(quota::PERSISTENCE_TYPE_TEMPORARY, mOrigin, QuotaManager::IsQuotaEnforced(quota::PERSISTENCE_TYPE_TEMPORARY);
mIsApp);
return NS_OK; return NS_OK;
} }
@ -627,7 +624,6 @@ ParentRunnable::OpenDirectory()
QuotaManager::Get()->OpenDirectory(quota::PERSISTENCE_TYPE_TEMPORARY, QuotaManager::Get()->OpenDirectory(quota::PERSISTENCE_TYPE_TEMPORARY,
mGroup, mGroup,
mOrigin, mOrigin,
mIsApp,
quota::Client::ASMJS, quota::Client::ASMJS,
/* aExclusive */ true, /* aExclusive */ true,
this); this);
@ -644,8 +640,7 @@ ParentRunnable::ReadMetadata()
nsresult rv = nsresult rv =
qm->EnsureOriginIsInitialized(quota::PERSISTENCE_TYPE_TEMPORARY, mSuffix, qm->EnsureOriginIsInitialized(quota::PERSISTENCE_TYPE_TEMPORARY, mSuffix,
mGroup, mOrigin, mIsApp, mGroup, mOrigin, getter_AddRefs(mDirectory));
getter_AddRefs(mDirectory));
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
mResult = JS::AsmJSCache_StorageInitFailure; mResult = JS::AsmJSCache_StorageInitFailure;
return rv; return rv;

Просмотреть файл

@ -3059,8 +3059,7 @@ nsDOMWindowUtils::GetFileReferences(const nsAString& aDatabaseName, int64_t aId,
nsCString origin; nsCString origin;
nsresult rv = nsresult rv =
quota::QuotaManager::GetInfoFromWindow(window, nullptr, nullptr, &origin, quota::QuotaManager::GetInfoFromWindow(window, nullptr, nullptr, &origin);
nullptr);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
IDBOpenDBOptions options; IDBOpenDBOptions options;

5
dom/cache/Context.cpp поставляемый
Просмотреть файл

@ -260,7 +260,6 @@ Context::QuotaInitRunnable::OpenDirectory()
QuotaManager::Get()->OpenDirectory(PERSISTENCE_TYPE_DEFAULT, QuotaManager::Get()->OpenDirectory(PERSISTENCE_TYPE_DEFAULT,
mQuotaInfo.mGroup, mQuotaInfo.mGroup,
mQuotaInfo.mOrigin, mQuotaInfo.mOrigin,
mQuotaInfo.mIsApp,
quota::Client::DOMCACHE, quota::Client::DOMCACHE,
/* aExclusive */ false, /* aExclusive */ false,
this); this);
@ -377,8 +376,7 @@ Context::QuotaInitRunnable::Run()
nsresult rv = QuotaManager::GetInfoFromPrincipal(principal, nsresult rv = QuotaManager::GetInfoFromPrincipal(principal,
&mQuotaInfo.mSuffix, &mQuotaInfo.mSuffix,
&mQuotaInfo.mGroup, &mQuotaInfo.mGroup,
&mQuotaInfo.mOrigin, &mQuotaInfo.mOrigin);
&mQuotaInfo.mIsApp);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
resolver->Resolve(rv); resolver->Resolve(rv);
break; break;
@ -437,7 +435,6 @@ Context::QuotaInitRunnable::Run()
mQuotaInfo.mSuffix, mQuotaInfo.mSuffix,
mQuotaInfo.mGroup, mQuotaInfo.mGroup,
mQuotaInfo.mOrigin, mQuotaInfo.mOrigin,
mQuotaInfo.mIsApp,
getter_AddRefs(mQuotaInfo.mDir)); getter_AddRefs(mQuotaInfo.mDir));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
resolver->Resolve(rv); resolver->Resolve(rv);

3
dom/cache/ManagerId.cpp поставляемый
Просмотреть файл

@ -30,8 +30,7 @@ ManagerId::Create(nsIPrincipal* aPrincipal, ManagerId** aManagerIdOut)
nsresult rv = QuotaManager::GetInfoFromPrincipal(aPrincipal, nsresult rv = QuotaManager::GetInfoFromPrincipal(aPrincipal,
nullptr, // suffix nullptr, // suffix
nullptr, // group nullptr, // group
&quotaOrigin, &quotaOrigin);
nullptr); // is app
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
RefPtr<ManagerId> ref = new ManagerId(aPrincipal, quotaOrigin); RefPtr<ManagerId> ref = new ManagerId(aPrincipal, quotaOrigin);

2
dom/cache/Types.h поставляемый
Просмотреть файл

@ -29,12 +29,10 @@ static const CacheId INVALID_CACHE_ID = -1;
struct QuotaInfo struct QuotaInfo
{ {
QuotaInfo() : mIsApp(false) { }
nsCOMPtr<nsIFile> mDir; nsCOMPtr<nsIFile> mDir;
nsCString mSuffix; nsCString mSuffix;
nsCString mGroup; nsCString mGroup;
nsCString mOrigin; nsCString mOrigin;
bool mIsApp;
}; };
} // namespace cache } // namespace cache

Просмотреть файл

@ -7482,7 +7482,6 @@ protected:
nsCString mDatabaseId; nsCString mDatabaseId;
nsString mDatabaseFilePath; nsString mDatabaseFilePath;
State mState; State mState;
bool mIsApp;
bool mEnforcingQuota; bool mEnforcingQuota;
const bool mDeleting; const bool mDeleting;
bool mBlockedDatabaseOpen; bool mBlockedDatabaseOpen;
@ -17087,7 +17086,6 @@ Cursor::RecvContinue(const CursorRequestParams& aParams)
FileManager::FileManager(PersistenceType aPersistenceType, FileManager::FileManager(PersistenceType aPersistenceType,
const nsACString& aGroup, const nsACString& aGroup,
const nsACString& aOrigin, const nsACString& aOrigin,
bool aIsApp,
const nsAString& aDatabaseName, const nsAString& aDatabaseName,
bool aEnforcingQuota) bool aEnforcingQuota)
: mPersistenceType(aPersistenceType) : mPersistenceType(aPersistenceType)
@ -17095,7 +17093,6 @@ FileManager::FileManager(PersistenceType aPersistenceType,
, mOrigin(aOrigin) , mOrigin(aOrigin)
, mDatabaseName(aDatabaseName) , mDatabaseName(aDatabaseName)
, mLastFileId(0) , mLastFileId(0)
, mIsApp(aIsApp)
, mEnforcingQuota(aEnforcingQuota) , mEnforcingQuota(aEnforcingQuota)
, mInvalidated(false) , mInvalidated(false)
{ } { }
@ -18646,14 +18643,12 @@ Maintenance::DirectoryWork()
int64_t dummyTimeStamp; int64_t dummyTimeStamp;
nsCString dummySuffix; nsCString dummySuffix;
bool dummyIsApp;
if (NS_WARN_IF(NS_FAILED( if (NS_WARN_IF(NS_FAILED(
quotaManager->GetDirectoryMetadata2(originDir, quotaManager->GetDirectoryMetadata2(originDir,
&dummyTimeStamp, &dummyTimeStamp,
dummySuffix, dummySuffix,
group, group,
origin, origin)))) {
&dummyIsApp)))) {
// Not much we can do here... // Not much we can do here...
continue; continue;
} }
@ -19486,7 +19481,6 @@ UpgradeFileIdsFunction::Init(nsIFile* aFMDirectory,
new FileManager(PERSISTENCE_TYPE_INVALID, new FileManager(PERSISTENCE_TYPE_INVALID,
EmptyCString(), EmptyCString(),
EmptyCString(), EmptyCString(),
false,
EmptyString(), EmptyString(),
false); false);
@ -20735,7 +20729,6 @@ FactoryOp::FactoryOp(Factory* aFactory,
, mContentParent(Move(aContentParent)) , mContentParent(Move(aContentParent))
, mCommonParams(aCommonParams) , mCommonParams(aCommonParams)
, mState(State::Initial) , mState(State::Initial)
, mIsApp(false)
, mEnforcingQuota(true) , mEnforcingQuota(true)
, mDeleting(aDeleting) , mDeleting(aDeleting)
, mBlockedDatabaseOpen(false) , mBlockedDatabaseOpen(false)
@ -21084,13 +21077,12 @@ FactoryOp::CheckPermission(ContentParent* aContentParent,
} }
if (State::Initial == mState) { if (State::Initial == mState) {
QuotaManager::GetInfoForChrome(&mSuffix, &mGroup, &mOrigin, &mIsApp); QuotaManager::GetInfoForChrome(&mSuffix, &mGroup, &mOrigin);
MOZ_ASSERT(!QuotaManager::IsFirstPromptRequired(persistenceType, mOrigin, MOZ_ASSERT(!QuotaManager::IsFirstPromptRequired(persistenceType,
mIsApp)); mOrigin));
mEnforcingQuota = mEnforcingQuota = QuotaManager::IsQuotaEnforced(persistenceType);
QuotaManager::IsQuotaEnforced(persistenceType, mOrigin, mIsApp);
} }
*aPermission = PermissionRequestBase::kPermissionAllowed; *aPermission = PermissionRequestBase::kPermissionAllowed;
@ -21109,27 +21101,24 @@ FactoryOp::CheckPermission(ContentParent* aContentParent,
nsCString suffix; nsCString suffix;
nsCString group; nsCString group;
nsCString origin; nsCString origin;
bool isApp;
rv = QuotaManager::GetInfoFromPrincipal(principal, rv = QuotaManager::GetInfoFromPrincipal(principal,
&suffix, &suffix,
&group, &group,
&origin, &origin);
&isApp);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
#ifdef IDB_MOBILE #ifdef IDB_MOBILE
if (persistenceType == PERSISTENCE_TYPE_PERSISTENT && if (persistenceType == PERSISTENCE_TYPE_PERSISTENT &&
!QuotaManager::IsOriginWhitelistedForPersistentStorage(origin) && !QuotaManager::IsOriginWhitelistedForPersistentStorage(origin)) {
!isApp) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
} }
#endif #endif
PermissionRequestBase::PermissionValue permission; PermissionRequestBase::PermissionValue permission;
if (QuotaManager::IsFirstPromptRequired(persistenceType, origin, isApp)) { if (QuotaManager::IsFirstPromptRequired(persistenceType, origin)) {
rv = PermissionRequestBase::GetCurrentPermission(principal, &permission); rv = PermissionRequestBase::GetCurrentPermission(principal, &permission);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
@ -21143,10 +21132,8 @@ FactoryOp::CheckPermission(ContentParent* aContentParent,
mSuffix = suffix; mSuffix = suffix;
mGroup = group; mGroup = group;
mOrigin = origin; mOrigin = origin;
mIsApp = isApp;
mEnforcingQuota = mEnforcingQuota = QuotaManager::IsQuotaEnforced(persistenceType);
QuotaManager::IsQuotaEnforced(persistenceType, mOrigin, mIsApp);
} }
*aPermission = permission; *aPermission = permission;
@ -21303,7 +21290,6 @@ FactoryOp::OpenDirectory()
quotaManager->OpenDirectory(persistenceType, quotaManager->OpenDirectory(persistenceType,
mGroup, mGroup,
mOrigin, mOrigin,
mIsApp,
Client::IDB, Client::IDB,
/* aExclusive */ false, /* aExclusive */ false,
this); this);
@ -21558,7 +21544,6 @@ OpenDatabaseOp::DoDatabaseWork()
mSuffix, mSuffix,
mGroup, mGroup,
mOrigin, mOrigin,
mIsApp,
getter_AddRefs(dbDirectory)); getter_AddRefs(dbDirectory));
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
@ -21682,7 +21667,6 @@ OpenDatabaseOp::DoDatabaseWork()
fileManager = new FileManager(persistenceType, fileManager = new FileManager(persistenceType,
mGroup, mGroup,
mOrigin, mOrigin,
mIsApp,
databaseName, databaseName,
mEnforcingQuota); mEnforcingQuota);

Просмотреть файл

@ -42,7 +42,6 @@ class FileManager final
// Protected by IndexedDatabaseManager::FileMutex() // Protected by IndexedDatabaseManager::FileMutex()
nsDataHashtable<nsUint64HashKey, FileInfo*> mFileInfos; nsDataHashtable<nsUint64HashKey, FileInfo*> mFileInfos;
const bool mIsApp;
const bool mEnforcingQuota; const bool mEnforcingQuota;
bool mInvalidated; bool mInvalidated;
@ -67,7 +66,6 @@ public:
FileManager(PersistenceType aPersistenceType, FileManager(PersistenceType aPersistenceType,
const nsACString& aGroup, const nsACString& aGroup,
const nsACString& aOrigin, const nsACString& aOrigin,
bool aIsApp,
const nsAString& aDatabaseName, const nsAString& aDatabaseName,
bool aEnforcingQuota); bool aEnforcingQuota);
@ -89,12 +87,6 @@ public:
return mOrigin; return mOrigin;
} }
bool
IsApp() const
{
return mIsApp;
}
const nsAString& const nsAString&
DatabaseName() const DatabaseName() const
{ {

Просмотреть файл

@ -1092,7 +1092,7 @@ IDBDatabase::GetQuotaInfo(nsACString& aOrigin,
MOZ_CRASH("Is this needed?!"); MOZ_CRASH("Is this needed?!");
case PrincipalInfo::TSystemPrincipalInfo: case PrincipalInfo::TSystemPrincipalInfo:
QuotaManager::GetInfoForChrome(nullptr, nullptr, &aOrigin, nullptr); QuotaManager::GetInfoForChrome(nullptr, nullptr, &aOrigin);
return NS_OK; return NS_OK;
case PrincipalInfo::TContentPrincipalInfo: { case PrincipalInfo::TContentPrincipalInfo: {
@ -1106,8 +1106,7 @@ IDBDatabase::GetQuotaInfo(nsACString& aOrigin,
rv = QuotaManager::GetInfoFromPrincipal(principal, rv = QuotaManager::GetInfoFromPrincipal(principal,
nullptr, nullptr,
nullptr, nullptr,
&aOrigin, &aOrigin);
nullptr);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }

Просмотреть файл

@ -1366,7 +1366,6 @@ DeleteFilesRunnable::Open()
quotaManager->OpenDirectory(mFileManager->Type(), quotaManager->OpenDirectory(mFileManager->Type(),
mFileManager->Group(), mFileManager->Group(),
mFileManager->Origin(), mFileManager->Origin(),
mFileManager->IsApp(),
Client::IDB, Client::IDB,
/* aExclusive */ false, /* aExclusive */ false,
this); this);

Просмотреть файл

@ -242,7 +242,6 @@ class DirectoryLockImpl final
const Nullable<PersistenceType> mPersistenceType; const Nullable<PersistenceType> mPersistenceType;
const nsCString mGroup; const nsCString mGroup;
const OriginScope mOriginScope; const OriginScope mOriginScope;
const Nullable<bool> mIsApp;
const Nullable<Client::Type> mClientType; const Nullable<Client::Type> mClientType;
RefPtr<OpenDirectoryListener> mOpenListener; RefPtr<OpenDirectoryListener> mOpenListener;
@ -262,7 +261,6 @@ public:
const Nullable<PersistenceType>& aPersistenceType, const Nullable<PersistenceType>& aPersistenceType,
const nsACString& aGroup, const nsACString& aGroup,
const OriginScope& aOriginScope, const OriginScope& aOriginScope,
const Nullable<bool>& aIsApp,
const Nullable<Client::Type>& aClientType, const Nullable<Client::Type>& aClientType,
bool aExclusive, bool aExclusive,
bool aInternal, bool aInternal,
@ -294,12 +292,6 @@ public:
return mOriginScope; return mOriginScope;
} }
const Nullable<bool>&
GetIsApp() const
{
return mIsApp;
}
const Nullable<Client::Type>& const Nullable<Client::Type>&
GetClientType() const GetClientType() const
{ {
@ -489,10 +481,10 @@ class OriginInfo final
friend class QuotaObject; friend class QuotaObject;
public: public:
OriginInfo(GroupInfo* aGroupInfo, const nsACString& aOrigin, bool aIsApp, OriginInfo(GroupInfo* aGroupInfo, const nsACString& aOrigin,
uint64_t aUsage, int64_t aAccessTime) uint64_t aUsage, int64_t aAccessTime)
: mGroupInfo(aGroupInfo), mOrigin(aOrigin), mUsage(aUsage), : mGroupInfo(aGroupInfo), mOrigin(aOrigin), mUsage(aUsage),
mAccessTime(aAccessTime), mIsApp(aIsApp) mAccessTime(aAccessTime)
{ {
MOZ_COUNT_CTOR(OriginInfo); MOZ_COUNT_CTOR(OriginInfo);
} }
@ -531,7 +523,6 @@ private:
const nsCString mOrigin; const nsCString mOrigin;
uint64_t mUsage; uint64_t mUsage;
int64_t mAccessTime; int64_t mAccessTime;
const bool mIsApp;
}; };
class OriginInfoLRUComparator class OriginInfoLRUComparator
@ -1047,7 +1038,6 @@ class GetUsageOp final
const UsageParams mParams; const UsageParams mParams;
nsCString mSuffix; nsCString mSuffix;
nsCString mGroup; nsCString mGroup;
bool mIsApp;
bool mGetGroupUsage; bool mGetGroupUsage;
public: public:
@ -1369,7 +1359,6 @@ struct StorageDirectoryHelper::OriginProps
nsCString mOrigin; nsCString mOrigin;
Type mType; Type mType;
bool mIsApp;
bool mNeedsRestore; bool mNeedsRestore;
bool mIgnore; bool mIgnore;
@ -1377,7 +1366,6 @@ public:
explicit OriginProps() explicit OriginProps()
: mTimestamp(0) : mTimestamp(0)
, mType(eContent) , mType(eContent)
, mIsApp(false)
, mNeedsRestore(false) , mNeedsRestore(false)
, mIgnore(false) , mIgnore(false)
{ } { }
@ -1571,22 +1559,15 @@ SanitizeOriginString(nsCString& aOrigin)
} }
bool bool
IsTreatedAsPersistent(PersistenceType aPersistenceType, IsTreatedAsPersistent(PersistenceType aPersistenceType)
bool aIsApp)
{ {
if (aPersistenceType == PERSISTENCE_TYPE_PERSISTENT || return aPersistenceType == PERSISTENCE_TYPE_PERSISTENT;
(aPersistenceType == PERSISTENCE_TYPE_DEFAULT && aIsApp)) {
return true;
}
return false;
} }
bool bool
IsTreatedAsTemporary(PersistenceType aPersistenceType, IsTreatedAsTemporary(PersistenceType aPersistenceType)
bool aIsApp)
{ {
return !IsTreatedAsPersistent(aPersistenceType, aIsApp); return !IsTreatedAsPersistent(aPersistenceType);
} }
nsresult nsresult
@ -1871,7 +1852,7 @@ GetJarPrefix(uint32_t aAppId,
nsresult nsresult
CreateDirectoryMetadata(nsIFile* aDirectory, int64_t aTimestamp, CreateDirectoryMetadata(nsIFile* aDirectory, int64_t aTimestamp,
const nsACString& aSuffix, const nsACString& aGroup, const nsACString& aSuffix, const nsACString& aGroup,
const nsACString& aOrigin, bool aIsApp) const nsACString& aOrigin)
{ {
AssertIsOnIOThread(); AssertIsOnIOThread();
@ -1933,7 +1914,8 @@ CreateDirectoryMetadata(nsIFile* aDirectory, int64_t aTimestamp,
return rv; return rv;
} }
rv = stream->WriteBoolean(aIsApp); // Currently unused (used to be isApp).
rv = stream->WriteBoolean(false);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -1944,7 +1926,7 @@ CreateDirectoryMetadata(nsIFile* aDirectory, int64_t aTimestamp,
nsresult nsresult
CreateDirectoryMetadata2(nsIFile* aDirectory, int64_t aTimestamp, CreateDirectoryMetadata2(nsIFile* aDirectory, int64_t aTimestamp,
const nsACString& aSuffix, const nsACString& aGroup, const nsACString& aSuffix, const nsACString& aGroup,
const nsACString& aOrigin, bool aIsApp) const nsACString& aOrigin)
{ {
AssertIsOnIOThread(); AssertIsOnIOThread();
@ -1997,7 +1979,8 @@ CreateDirectoryMetadata2(nsIFile* aDirectory, int64_t aTimestamp,
return rv; return rv;
} }
rv = stream->WriteBoolean(aIsApp); // Currently unused (used to be isApp).
rv = stream->WriteBoolean(false);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -2119,7 +2102,6 @@ DirectoryLockImpl::DirectoryLockImpl(QuotaManager* aQuotaManager,
const Nullable<PersistenceType>& aPersistenceType, const Nullable<PersistenceType>& aPersistenceType,
const nsACString& aGroup, const nsACString& aGroup,
const OriginScope& aOriginScope, const OriginScope& aOriginScope,
const Nullable<bool>& aIsApp,
const Nullable<Client::Type>& aClientType, const Nullable<Client::Type>& aClientType,
bool aExclusive, bool aExclusive,
bool aInternal, bool aInternal,
@ -2128,7 +2110,6 @@ DirectoryLockImpl::DirectoryLockImpl(QuotaManager* aQuotaManager,
, mPersistenceType(aPersistenceType) , mPersistenceType(aPersistenceType)
, mGroup(aGroup) , mGroup(aGroup)
, mOriginScope(aOriginScope) , mOriginScope(aOriginScope)
, mIsApp(aIsApp)
, mClientType(aClientType) , mClientType(aClientType)
, mOpenListener(aOpenListener) , mOpenListener(aOpenListener)
, mExclusive(aExclusive) , mExclusive(aExclusive)
@ -2143,7 +2124,6 @@ DirectoryLockImpl::DirectoryLockImpl(QuotaManager* aQuotaManager,
aPersistenceType.Value() != PERSISTENCE_TYPE_INVALID); aPersistenceType.Value() != PERSISTENCE_TYPE_INVALID);
MOZ_ASSERT_IF(!aInternal, !aGroup.IsEmpty()); MOZ_ASSERT_IF(!aInternal, !aGroup.IsEmpty());
MOZ_ASSERT_IF(!aInternal, aOriginScope.IsOrigin()); MOZ_ASSERT_IF(!aInternal, aOriginScope.IsOrigin());
MOZ_ASSERT_IF(!aInternal, !aIsApp.IsNull());
MOZ_ASSERT_IF(!aInternal, !aClientType.IsNull()); MOZ_ASSERT_IF(!aInternal, !aClientType.IsNull());
MOZ_ASSERT_IF(!aInternal, aClientType.Value() != Client::TYPE_MAX); MOZ_ASSERT_IF(!aInternal, aClientType.Value() != Client::TYPE_MAX);
MOZ_ASSERT_IF(!aInternal, aOpenListener); MOZ_ASSERT_IF(!aInternal, aOpenListener);
@ -2811,7 +2791,6 @@ auto
QuotaManager::CreateDirectoryLock(const Nullable<PersistenceType>& aPersistenceType, QuotaManager::CreateDirectoryLock(const Nullable<PersistenceType>& aPersistenceType,
const nsACString& aGroup, const nsACString& aGroup,
const OriginScope& aOriginScope, const OriginScope& aOriginScope,
const Nullable<bool>& aIsApp,
const Nullable<Client::Type>& aClientType, const Nullable<Client::Type>& aClientType,
bool aExclusive, bool aExclusive,
bool aInternal, bool aInternal,
@ -2825,7 +2804,6 @@ QuotaManager::CreateDirectoryLock(const Nullable<PersistenceType>& aPersistenceT
aPersistenceType.Value() != PERSISTENCE_TYPE_INVALID); aPersistenceType.Value() != PERSISTENCE_TYPE_INVALID);
MOZ_ASSERT_IF(!aInternal, !aGroup.IsEmpty()); MOZ_ASSERT_IF(!aInternal, !aGroup.IsEmpty());
MOZ_ASSERT_IF(!aInternal, aOriginScope.IsOrigin()); MOZ_ASSERT_IF(!aInternal, aOriginScope.IsOrigin());
MOZ_ASSERT_IF(!aInternal, !aIsApp.IsNull());
MOZ_ASSERT_IF(!aInternal, !aClientType.IsNull()); MOZ_ASSERT_IF(!aInternal, !aClientType.IsNull());
MOZ_ASSERT_IF(!aInternal, aClientType.Value() != Client::TYPE_MAX); MOZ_ASSERT_IF(!aInternal, aClientType.Value() != Client::TYPE_MAX);
MOZ_ASSERT_IF(!aInternal, aOpenListener); MOZ_ASSERT_IF(!aInternal, aOpenListener);
@ -2834,7 +2812,6 @@ QuotaManager::CreateDirectoryLock(const Nullable<PersistenceType>& aPersistenceT
aPersistenceType, aPersistenceType,
aGroup, aGroup,
aOriginScope, aOriginScope,
aIsApp,
aClientType, aClientType,
aExclusive, aExclusive,
aInternal, aInternal,
@ -2866,8 +2843,7 @@ QuotaManager::CreateDirectoryLock(const Nullable<PersistenceType>& aPersistenceT
auto auto
QuotaManager::CreateDirectoryLockForEviction(PersistenceType aPersistenceType, QuotaManager::CreateDirectoryLockForEviction(PersistenceType aPersistenceType,
const nsACString& aGroup, const nsACString& aGroup,
const nsACString& aOrigin, const nsACString& aOrigin)
bool aIsApp)
-> already_AddRefed<DirectoryLockImpl> -> already_AddRefed<DirectoryLockImpl>
{ {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
@ -2879,7 +2855,6 @@ QuotaManager::CreateDirectoryLockForEviction(PersistenceType aPersistenceType,
Nullable<PersistenceType>(aPersistenceType), Nullable<PersistenceType>(aPersistenceType),
aGroup, aGroup,
OriginScope::FromOrigin(aOrigin), OriginScope::FromOrigin(aOrigin),
Nullable<bool>(aIsApp),
Nullable<Client::Type>(), Nullable<Client::Type>(),
/* aExclusive */ true, /* aExclusive */ true,
/* aInternal */ true, /* aInternal */ true,
@ -2994,8 +2969,8 @@ QuotaManager::CollectOriginsForEviction(
nsTArray<OriginInfo*>& aInactiveOriginInfos) nsTArray<OriginInfo*>& aInactiveOriginInfos)
{ {
for (OriginInfo* originInfo : aOriginInfos) { for (OriginInfo* originInfo : aOriginInfos) {
MOZ_ASSERT(IsTreatedAsTemporary(originInfo->mGroupInfo->mPersistenceType, MOZ_ASSERT(
originInfo->mIsApp)); IsTreatedAsTemporary(originInfo->mGroupInfo->mPersistenceType));
OriginScope originScope = OriginScope::FromOrigin(originInfo->mOrigin); OriginScope originScope = OriginScope::FromOrigin(originInfo->mOrigin);
@ -3098,8 +3073,7 @@ QuotaManager::CollectOriginsForEviction(
RefPtr<DirectoryLockImpl> lock = RefPtr<DirectoryLockImpl> lock =
CreateDirectoryLockForEviction(originInfo->mGroupInfo->mPersistenceType, CreateDirectoryLockForEviction(originInfo->mGroupInfo->mPersistenceType,
originInfo->mGroupInfo->mGroup, originInfo->mGroupInfo->mGroup,
originInfo->mOrigin, originInfo->mOrigin);
originInfo->mIsApp);
aLocks.AppendElement(lock.forget()); aLocks.AppendElement(lock.forget());
} }
@ -3249,12 +3223,11 @@ void
QuotaManager::InitQuotaForOrigin(PersistenceType aPersistenceType, QuotaManager::InitQuotaForOrigin(PersistenceType aPersistenceType,
const nsACString& aGroup, const nsACString& aGroup,
const nsACString& aOrigin, const nsACString& aOrigin,
bool aIsApp,
uint64_t aUsageBytes, uint64_t aUsageBytes,
int64_t aAccessTime) int64_t aAccessTime)
{ {
AssertIsOnIOThread(); AssertIsOnIOThread();
MOZ_ASSERT(IsTreatedAsTemporary(aPersistenceType, aIsApp)); MOZ_ASSERT(IsTreatedAsTemporary(aPersistenceType));
MutexAutoLock lock(mQuotaMutex); MutexAutoLock lock(mQuotaMutex);
@ -3272,7 +3245,7 @@ QuotaManager::InitQuotaForOrigin(PersistenceType aPersistenceType,
} }
RefPtr<OriginInfo> originInfo = RefPtr<OriginInfo> originInfo =
new OriginInfo(groupInfo, aOrigin, aIsApp, aUsageBytes, aAccessTime); new OriginInfo(groupInfo, aOrigin, aUsageBytes, aAccessTime);
groupInfo->LockedAddOriginInfo(originInfo); groupInfo->LockedAddOriginInfo(originInfo);
} }
@ -3521,13 +3494,11 @@ QuotaManager::GetDirectoryMetadata2(nsIFile* aDirectory,
int64_t* aTimestamp, int64_t* aTimestamp,
nsACString& aSuffix, nsACString& aSuffix,
nsACString& aGroup, nsACString& aGroup,
nsACString& aOrigin, nsACString& aOrigin)
bool* aIsApp)
{ {
MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aDirectory); MOZ_ASSERT(aDirectory);
MOZ_ASSERT(aTimestamp); MOZ_ASSERT(aTimestamp);
MOZ_ASSERT(aIsApp);
MOZ_ASSERT(mStorageInitialized); MOZ_ASSERT(mStorageInitialized);
nsCOMPtr<nsIBinaryInputStream> binaryStream; nsCOMPtr<nsIBinaryInputStream> binaryStream;
@ -3572,8 +3543,9 @@ QuotaManager::GetDirectoryMetadata2(nsIFile* aDirectory,
rv = binaryStream->ReadCString(origin); rv = binaryStream->ReadCString(origin);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
bool isApp; // Currently unused (used to be isApp).
rv = binaryStream->ReadBoolean(&isApp); bool dummy;
rv = binaryStream->ReadBoolean(&dummy);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -3582,7 +3554,6 @@ QuotaManager::GetDirectoryMetadata2(nsIFile* aDirectory,
aSuffix = suffix; aSuffix = suffix;
aGroup = group; aGroup = group;
aOrigin = origin; aOrigin = origin;
*aIsApp = isApp;
return NS_OK; return NS_OK;
} }
@ -3592,15 +3563,13 @@ QuotaManager::GetDirectoryMetadata2WithRestore(nsIFile* aDirectory,
int64_t* aTimestamp, int64_t* aTimestamp,
nsACString& aSuffix, nsACString& aSuffix,
nsACString& aGroup, nsACString& aGroup,
nsACString& aOrigin, nsACString& aOrigin)
bool* aIsApp)
{ {
nsresult rv = GetDirectoryMetadata2(aDirectory, nsresult rv = GetDirectoryMetadata2(aDirectory,
aTimestamp, aTimestamp,
aSuffix, aSuffix,
aGroup, aGroup,
aOrigin, aOrigin);
aIsApp);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
rv = RestoreDirectoryMetadata2(aDirectory, aPersistent); rv = RestoreDirectoryMetadata2(aDirectory, aPersistent);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
@ -3611,8 +3580,7 @@ QuotaManager::GetDirectoryMetadata2WithRestore(nsIFile* aDirectory,
aTimestamp, aTimestamp,
aSuffix, aSuffix,
aGroup, aGroup,
aOrigin, aOrigin);
aIsApp);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -3736,23 +3704,17 @@ QuotaManager::InitializeRepository(PersistenceType aPersistenceType)
nsCString suffix; nsCString suffix;
nsCString group; nsCString group;
nsCString origin; nsCString origin;
bool isApp;
rv = GetDirectoryMetadata2WithRestore(childDirectory, rv = GetDirectoryMetadata2WithRestore(childDirectory,
/* aPersistent */ false, /* aPersistent */ false,
&timestamp, &timestamp,
suffix, suffix,
group, group,
origin, origin);
&isApp);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
if (IsTreatedAsPersistent(aPersistenceType, isApp)) { rv = InitializeOrigin(aPersistenceType, group, origin, timestamp,
continue;
}
rv = InitializeOrigin(aPersistenceType, group, origin, isApp, timestamp,
childDirectory); childDirectory);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
@ -3800,7 +3762,6 @@ nsresult
QuotaManager::InitializeOrigin(PersistenceType aPersistenceType, QuotaManager::InitializeOrigin(PersistenceType aPersistenceType,
const nsACString& aGroup, const nsACString& aGroup,
const nsACString& aOrigin, const nsACString& aOrigin,
bool aIsApp,
int64_t aAccessTime, int64_t aAccessTime,
nsIFile* aDirectory) nsIFile* aDirectory)
{ {
@ -3808,7 +3769,7 @@ QuotaManager::InitializeOrigin(PersistenceType aPersistenceType,
nsresult rv; nsresult rv;
bool trackQuota = IsQuotaEnforced(aPersistenceType, aOrigin, aIsApp); bool trackQuota = IsQuotaEnforced(aPersistenceType);
// We need to initialize directories of all clients if they exists and also // We need to initialize directories of all clients if they exists and also
// get the total usage to initialize the quota. // get the total usage to initialize the quota.
@ -3866,7 +3827,7 @@ QuotaManager::InitializeOrigin(PersistenceType aPersistenceType,
} }
if (trackQuota) { if (trackQuota) {
InitQuotaForOrigin(aPersistenceType, aGroup, aOrigin, aIsApp, InitQuotaForOrigin(aPersistenceType, aGroup, aOrigin,
usageInfo->TotalUsage(), aAccessTime); usageInfo->TotalUsage(), aAccessTime);
} }
@ -4402,7 +4363,6 @@ void
QuotaManager::OpenDirectory(PersistenceType aPersistenceType, QuotaManager::OpenDirectory(PersistenceType aPersistenceType,
const nsACString& aGroup, const nsACString& aGroup,
const nsACString& aOrigin, const nsACString& aOrigin,
bool aIsApp,
Client::Type aClientType, Client::Type aClientType,
bool aExclusive, bool aExclusive,
OpenDirectoryListener* aOpenListener) OpenDirectoryListener* aOpenListener)
@ -4413,7 +4373,6 @@ QuotaManager::OpenDirectory(PersistenceType aPersistenceType,
CreateDirectoryLock(Nullable<PersistenceType>(aPersistenceType), CreateDirectoryLock(Nullable<PersistenceType>(aPersistenceType),
aGroup, aGroup,
OriginScope::FromOrigin(aOrigin), OriginScope::FromOrigin(aOrigin),
Nullable<bool>(aIsApp),
Nullable<Client::Type>(aClientType), Nullable<Client::Type>(aClientType),
aExclusive, aExclusive,
false, false,
@ -4434,7 +4393,6 @@ QuotaManager::OpenDirectoryInternal(const Nullable<PersistenceType>& aPersistenc
CreateDirectoryLock(aPersistenceType, CreateDirectoryLock(aPersistenceType,
EmptyCString(), EmptyCString(),
aOriginScope, aOriginScope,
Nullable<bool>(),
Nullable<Client::Type>(aClientType), Nullable<Client::Type>(aClientType),
aExclusive, aExclusive,
true, true,
@ -4490,7 +4448,6 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType,
const nsACString& aSuffix, const nsACString& aSuffix,
const nsACString& aGroup, const nsACString& aGroup,
const nsACString& aOrigin, const nsACString& aOrigin,
bool aIsApp,
nsIFile** aDirectory) nsIFile** aDirectory)
{ {
AssertIsOnIOThread(); AssertIsOnIOThread();
@ -4504,7 +4461,7 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType,
getter_AddRefs(directory)); getter_AddRefs(directory));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
if (IsTreatedAsPersistent(aPersistenceType, aIsApp)) { if (IsTreatedAsPersistent(aPersistenceType)) {
if (mInitializedOrigins.Contains(OriginKey(aPersistenceType, aOrigin))) { if (mInitializedOrigins.Contains(OriginKey(aPersistenceType, aOrigin))) {
directory.forget(aDirectory); directory.forget(aDirectory);
return NS_OK; return NS_OK;
@ -4586,7 +4543,7 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType,
rv = EnsureDirectory(directory, &created); rv = EnsureDirectory(directory, &created);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
if (IsTreatedAsPersistent(aPersistenceType, aIsApp)) { if (IsTreatedAsPersistent(aPersistenceType)) {
if (created) { if (created) {
timestamp = PR_Now(); timestamp = PR_Now();
@ -4594,8 +4551,7 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType,
timestamp, timestamp,
aSuffix, aSuffix,
aGroup, aGroup,
aOrigin, aOrigin);
aIsApp);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -4604,8 +4560,7 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType,
timestamp, timestamp,
aSuffix, aSuffix,
aGroup, aGroup,
aOrigin, aOrigin);
aIsApp);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} else { } else {
bool persistent = aPersistenceType == PERSISTENCE_TYPE_PERSISTENT; bool persistent = aPersistenceType == PERSISTENCE_TYPE_PERSISTENT;
@ -4619,7 +4574,7 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType,
MOZ_ASSERT(timestamp <= PR_Now()); MOZ_ASSERT(timestamp <= PR_Now());
} }
rv = InitializeOrigin(aPersistenceType, aGroup, aOrigin, aIsApp, timestamp, rv = InitializeOrigin(aPersistenceType, aGroup, aOrigin, timestamp,
directory); directory);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -4631,8 +4586,7 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType,
timestamp, timestamp,
aSuffix, aSuffix,
aGroup, aGroup,
aOrigin, aOrigin);
aIsApp);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -4641,11 +4595,10 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType,
timestamp, timestamp,
aSuffix, aSuffix,
aGroup, aGroup,
aOrigin, aOrigin);
aIsApp);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = InitializeOrigin(aPersistenceType, aGroup, aOrigin, aIsApp, timestamp, rv = InitializeOrigin(aPersistenceType, aGroup, aOrigin, timestamp,
directory); directory);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} }
@ -4656,12 +4609,11 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType,
void void
QuotaManager::OriginClearCompleted(PersistenceType aPersistenceType, QuotaManager::OriginClearCompleted(PersistenceType aPersistenceType,
const nsACString& aOrigin, const nsACString& aOrigin)
bool aIsApp)
{ {
AssertIsOnIOThread(); AssertIsOnIOThread();
if (IsTreatedAsPersistent(aPersistenceType, aIsApp)) { if (IsTreatedAsPersistent(aPersistenceType)) {
mInitializedOrigins.RemoveElement(OriginKey(aPersistenceType, aOrigin)); mInitializedOrigins.RemoveElement(OriginKey(aPersistenceType, aOrigin));
} }
@ -4763,14 +4715,13 @@ nsresult
QuotaManager::GetInfoFromPrincipal(nsIPrincipal* aPrincipal, QuotaManager::GetInfoFromPrincipal(nsIPrincipal* aPrincipal,
nsACString* aSuffix, nsACString* aSuffix,
nsACString* aGroup, nsACString* aGroup,
nsACString* aOrigin, nsACString* aOrigin)
bool* aIsApp)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPrincipal); MOZ_ASSERT(aPrincipal);
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) { if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
GetInfoForChrome(aSuffix, aGroup, aOrigin, aIsApp); GetInfoForChrome(aSuffix, aGroup, aOrigin);
return NS_OK; return NS_OK;
} }
@ -4828,11 +4779,6 @@ QuotaManager::GetInfoFromPrincipal(nsIPrincipal* aPrincipal,
aOrigin->Assign(origin); aOrigin->Assign(origin);
} }
if (aIsApp) {
*aIsApp = aPrincipal->GetAppStatus() !=
nsIPrincipal::APP_STATUS_NOT_INSTALLED;
}
return NS_OK; return NS_OK;
} }
@ -4841,8 +4787,7 @@ nsresult
QuotaManager::GetInfoFromWindow(nsPIDOMWindowOuter* aWindow, QuotaManager::GetInfoFromWindow(nsPIDOMWindowOuter* aWindow,
nsACString* aSuffix, nsACString* aSuffix,
nsACString* aGroup, nsACString* aGroup,
nsACString* aOrigin, nsACString* aOrigin)
bool* aIsApp)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aWindow); MOZ_ASSERT(aWindow);
@ -4854,7 +4799,7 @@ QuotaManager::GetInfoFromWindow(nsPIDOMWindowOuter* aWindow,
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE); NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
nsresult rv = nsresult rv =
GetInfoFromPrincipal(principal, aSuffix, aGroup, aOrigin, aIsApp); GetInfoFromPrincipal(principal, aSuffix, aGroup, aOrigin);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
return NS_OK; return NS_OK;
@ -4864,8 +4809,7 @@ QuotaManager::GetInfoFromWindow(nsPIDOMWindowOuter* aWindow,
void void
QuotaManager::GetInfoForChrome(nsACString* aSuffix, QuotaManager::GetInfoForChrome(nsACString* aSuffix,
nsACString* aGroup, nsACString* aGroup,
nsACString* aOrigin, nsACString* aOrigin)
bool* aIsApp)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(nsContentUtils::LegacyIsCallerChromeOrNativeCode()); MOZ_ASSERT(nsContentUtils::LegacyIsCallerChromeOrNativeCode());
@ -4879,9 +4823,6 @@ QuotaManager::GetInfoForChrome(nsACString* aSuffix,
if (aOrigin) { if (aOrigin) {
ChromeOrigin(*aOrigin); ChromeOrigin(*aOrigin);
} }
if (aIsApp) {
*aIsApp = false;
}
} }
// static // static
@ -4903,10 +4844,9 @@ QuotaManager::IsOriginWhitelistedForPersistentStorage(const nsACString& aOrigin)
// static // static
bool bool
QuotaManager::IsFirstPromptRequired(PersistenceType aPersistenceType, QuotaManager::IsFirstPromptRequired(PersistenceType aPersistenceType,
const nsACString& aOrigin, const nsACString& aOrigin)
bool aIsApp)
{ {
if (IsTreatedAsTemporary(aPersistenceType, aIsApp)) { if (IsTreatedAsTemporary(aPersistenceType)) {
return false; return false;
} }
@ -4915,11 +4855,9 @@ QuotaManager::IsFirstPromptRequired(PersistenceType aPersistenceType,
// static // static
bool bool
QuotaManager::IsQuotaEnforced(PersistenceType aPersistenceType, QuotaManager::IsQuotaEnforced(PersistenceType aPersistenceType)
const nsACString& aOrigin,
bool aIsApp)
{ {
return IsTreatedAsTemporary(aPersistenceType, aIsApp); return IsTreatedAsTemporary(aPersistenceType);
} }
// static // static
@ -5103,21 +5041,19 @@ QuotaManager::CheckTemporaryStorageLimits()
doomedOriginInfo->mGroupInfo->mPersistenceType; doomedOriginInfo->mGroupInfo->mPersistenceType;
nsCString group = doomedOriginInfo->mGroupInfo->mGroup; nsCString group = doomedOriginInfo->mGroupInfo->mGroup;
nsCString origin = doomedOriginInfo->mOrigin; nsCString origin = doomedOriginInfo->mOrigin;
bool isApp = doomedOriginInfo->mIsApp;
LockedRemoveQuotaForOrigin(persistenceType, group, origin); LockedRemoveQuotaForOrigin(persistenceType, group, origin);
#ifdef DEBUG #ifdef DEBUG
doomedOriginInfos[index] = nullptr; doomedOriginInfos[index] = nullptr;
#endif #endif
doomedOrigins.AppendElement(OriginParams(persistenceType, origin, isApp)); doomedOrigins.AppendElement(OriginParams(persistenceType, origin));
} }
} }
for (const OriginParams& doomedOrigin : doomedOrigins) { for (const OriginParams& doomedOrigin : doomedOrigins) {
OriginClearCompleted(doomedOrigin.mPersistenceType, OriginClearCompleted(doomedOrigin.mPersistenceType,
doomedOrigin.mOrigin, doomedOrigin.mOrigin);
doomedOrigin.mIsApp);
} }
} }
@ -5595,8 +5531,7 @@ FinalizeOriginEvictionOp::DoDirectoryWork(QuotaManager* aQuotaManager)
for (RefPtr<DirectoryLockImpl>& lock : mLocks) { for (RefPtr<DirectoryLockImpl>& lock : mLocks) {
aQuotaManager->OriginClearCompleted(lock->GetPersistenceType().Value(), aQuotaManager->OriginClearCompleted(lock->GetPersistenceType().Value(),
lock->GetOriginScope().GetOrigin(), lock->GetOriginScope().GetOrigin());
lock->GetIsApp().Value());
} }
return NS_OK; return NS_OK;
@ -5971,8 +5906,8 @@ GetUsageOp::DoInitOnMainThread()
// Figure out which origin we're dealing with. // Figure out which origin we're dealing with.
nsCString origin; nsCString origin;
rv = QuotaManager::GetInfoFromPrincipal(principal, &mSuffix, &mGroup, &origin, rv = QuotaManager::GetInfoFromPrincipal(principal, &mSuffix, &mGroup,
&mIsApp); &origin);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -6003,7 +5938,7 @@ GetUsageOp::AddToUsage(QuotaManager* aQuotaManager,
if (exists && !mUsageInfo.Canceled()) { if (exists && !mUsageInfo.Canceled()) {
bool initialized; bool initialized;
if (IsTreatedAsPersistent(aPersistenceType, mIsApp)) { if (IsTreatedAsPersistent(aPersistenceType)) {
nsCString originKey = nsCString originKey =
OriginKey(aPersistenceType, mOriginScope.GetOrigin()); OriginKey(aPersistenceType, mOriginScope.GetOrigin());
initialized = aQuotaManager->IsOriginInitialized(originKey); initialized = aQuotaManager->IsOriginInitialized(originKey);
@ -6101,7 +6036,6 @@ GetUsageOp::DoDirectoryWork(QuotaManager* aQuotaManager)
rv = aQuotaManager->EnsureOriginIsInitialized(PERSISTENCE_TYPE_TEMPORARY, rv = aQuotaManager->EnsureOriginIsInitialized(PERSISTENCE_TYPE_TEMPORARY,
mSuffix, mGroup, mSuffix, mGroup,
mOriginScope.GetOrigin(), mOriginScope.GetOrigin(),
mIsApp,
getter_AddRefs(directory)); getter_AddRefs(directory));
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
@ -6365,8 +6299,8 @@ OriginClearOp::DoInitOnMainThread()
// Figure out which origin we're dealing with. // Figure out which origin we're dealing with.
nsCString origin; nsCString origin;
rv = QuotaManager::GetInfoFromPrincipal(principal, nullptr, nullptr, &origin, rv = QuotaManager::GetInfoFromPrincipal(principal, nullptr, nullptr,
nullptr); &origin);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -6460,14 +6394,12 @@ OriginClearOp::DeleteFiles(QuotaManager* aQuotaManager,
nsCString suffix; nsCString suffix;
nsCString group; nsCString group;
nsCString origin; nsCString origin;
bool isApp;
rv = aQuotaManager->GetDirectoryMetadata2WithRestore(file, rv = aQuotaManager->GetDirectoryMetadata2WithRestore(file,
persistent, persistent,
&timestamp, &timestamp,
suffix, suffix,
group, group,
origin, origin);
&isApp);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return; return;
} }
@ -6491,7 +6423,7 @@ OriginClearOp::DeleteFiles(QuotaManager* aQuotaManager,
aQuotaManager->RemoveQuotaForOrigin(aPersistenceType, group, origin); aQuotaManager->RemoveQuotaForOrigin(aPersistenceType, group, origin);
} }
aQuotaManager->OriginClearCompleted(aPersistenceType, origin, isApp); aQuotaManager->OriginClearCompleted(aPersistenceType, origin);
} }
} }
@ -6626,8 +6558,7 @@ StorageDirectoryHelper::RunOnMainThread()
case OriginProps::eChrome: { case OriginProps::eChrome: {
QuotaManager::GetInfoForChrome(&originProps.mSuffix, QuotaManager::GetInfoForChrome(&originProps.mSuffix,
&originProps.mGroup, &originProps.mGroup,
&originProps.mOrigin, &originProps.mOrigin);
&originProps.mIsApp);
break; break;
} }
@ -6647,8 +6578,7 @@ StorageDirectoryHelper::RunOnMainThread()
rv = QuotaManager::GetInfoFromPrincipal(principal, rv = QuotaManager::GetInfoFromPrincipal(principal,
&originProps.mSuffix, &originProps.mSuffix,
&originProps.mGroup, &originProps.mGroup,
&originProps.mOrigin, &originProps.mOrigin);
&originProps.mIsApp);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -7369,8 +7299,7 @@ CreateOrUpgradeDirectoryMetadataHelper::DoProcessOriginDirectories()
originProps.mTimestamp, originProps.mTimestamp,
originProps.mSuffix, originProps.mSuffix,
originProps.mGroup, originProps.mGroup,
originProps.mOrigin, originProps.mOrigin);
originProps.mIsApp);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -7437,8 +7366,7 @@ CreateOrUpgradeDirectoryMetadataHelper::DoProcessOriginDirectories()
originProps.mTimestamp, originProps.mTimestamp,
originProps.mSuffix, originProps.mSuffix,
originProps.mGroup, originProps.mGroup,
originProps.mOrigin, originProps.mOrigin);
originProps.mIsApp);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -7454,7 +7382,8 @@ CreateOrUpgradeDirectoryMetadataHelper::DoProcessOriginDirectories()
MOZ_ASSERT(stream); MOZ_ASSERT(stream);
rv = stream->WriteBoolean(originProps.mIsApp); // Currently unused (used to be isApp).
rv = stream->WriteBoolean(false);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -7627,8 +7556,7 @@ UpgradeDirectoryMetadataFrom1To2Helper::DoProcessOriginDirectories()
originProps.mTimestamp, originProps.mTimestamp,
originProps.mSuffix, originProps.mSuffix,
originProps.mGroup, originProps.mGroup,
originProps.mOrigin, originProps.mOrigin);
originProps.mIsApp);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -7638,8 +7566,7 @@ UpgradeDirectoryMetadataFrom1To2Helper::DoProcessOriginDirectories()
originProps.mTimestamp, originProps.mTimestamp,
originProps.mSuffix, originProps.mSuffix,
originProps.mGroup, originProps.mGroup,
originProps.mOrigin, originProps.mOrigin);
originProps.mIsApp);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
@ -7709,8 +7636,7 @@ RestoreDirectoryMetadata2Helper::DoProcessOriginDirectories()
originProps.mTimestamp, originProps.mTimestamp,
originProps.mSuffix, originProps.mSuffix,
originProps.mGroup, originProps.mGroup,
originProps.mOrigin, originProps.mOrigin);
originProps.mIsApp);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }

Просмотреть файл

@ -78,16 +78,13 @@ protected:
struct OriginParams struct OriginParams
{ {
OriginParams(PersistenceType aPersistenceType, OriginParams(PersistenceType aPersistenceType,
const nsACString& aOrigin, const nsACString& aOrigin)
bool aIsApp)
: mOrigin(aOrigin) : mOrigin(aOrigin)
, mPersistenceType(aPersistenceType) , mPersistenceType(aPersistenceType)
, mIsApp(aIsApp)
{ } { }
nsCString mOrigin; nsCString mOrigin;
PersistenceType mPersistenceType; PersistenceType mPersistenceType;
bool mIsApp;
}; };
class QuotaManager final class QuotaManager final
@ -149,7 +146,6 @@ public:
InitQuotaForOrigin(PersistenceType aPersistenceType, InitQuotaForOrigin(PersistenceType aPersistenceType,
const nsACString& aGroup, const nsACString& aGroup,
const nsACString& aOrigin, const nsACString& aOrigin,
bool aIsApp,
uint64_t aUsageBytes, uint64_t aUsageBytes,
int64_t aAccessTime); int64_t aAccessTime);
@ -206,8 +202,7 @@ public:
int64_t* aTimestamp, int64_t* aTimestamp,
nsACString& aSuffix, nsACString& aSuffix,
nsACString& aGroup, nsACString& aGroup,
nsACString& aOrigin, nsACString& aOrigin);
bool* aIsApp);
nsresult nsresult
GetDirectoryMetadata2WithRestore(nsIFile* aDirectory, GetDirectoryMetadata2WithRestore(nsIFile* aDirectory,
@ -215,8 +210,7 @@ public:
int64_t* aTimestamp, int64_t* aTimestamp,
nsACString& aSuffix, nsACString& aSuffix,
nsACString& aGroup, nsACString& aGroup,
nsACString& aOrigin, nsACString& aOrigin);
bool* aIsApp);
nsresult nsresult
GetDirectoryMetadata2(nsIFile* aDirectory, int64_t* aTimestamp); GetDirectoryMetadata2(nsIFile* aDirectory, int64_t* aTimestamp);
@ -245,7 +239,6 @@ public:
OpenDirectory(PersistenceType aPersistenceType, OpenDirectory(PersistenceType aPersistenceType,
const nsACString& aGroup, const nsACString& aGroup,
const nsACString& aOrigin, const nsACString& aOrigin,
bool aIsApp,
Client::Type aClientType, Client::Type aClientType,
bool aExclusive, bool aExclusive,
OpenDirectoryListener* aOpenListener); OpenDirectoryListener* aOpenListener);
@ -271,13 +264,11 @@ public:
const nsACString& aSuffix, const nsACString& aSuffix,
const nsACString& aGroup, const nsACString& aGroup,
const nsACString& aOrigin, const nsACString& aOrigin,
bool aIsApp,
nsIFile** aDirectory); nsIFile** aDirectory);
void void
OriginClearCompleted(PersistenceType aPersistenceType, OriginClearCompleted(PersistenceType aPersistenceType,
const nsACString& aOrigin, const nsACString& aOrigin);
bool aIsApp);
void void
ResetOrClearCompleted(); ResetOrClearCompleted();
@ -363,34 +354,28 @@ public:
GetInfoFromPrincipal(nsIPrincipal* aPrincipal, GetInfoFromPrincipal(nsIPrincipal* aPrincipal,
nsACString* aSuffix, nsACString* aSuffix,
nsACString* aGroup, nsACString* aGroup,
nsACString* aOrigin, nsACString* aOrigin);
bool* aIsApp);
static nsresult static nsresult
GetInfoFromWindow(nsPIDOMWindowOuter* aWindow, GetInfoFromWindow(nsPIDOMWindowOuter* aWindow,
nsACString* aSuffix, nsACString* aSuffix,
nsACString* aGroup, nsACString* aGroup,
nsACString* aOrigin, nsACString* aOrigin);
bool* aIsApp);
static void static void
GetInfoForChrome(nsACString* aSuffix, GetInfoForChrome(nsACString* aSuffix,
nsACString* aGroup, nsACString* aGroup,
nsACString* aOrigin, nsACString* aOrigin);
bool* aIsApp);
static bool static bool
IsOriginWhitelistedForPersistentStorage(const nsACString& aOrigin); IsOriginWhitelistedForPersistentStorage(const nsACString& aOrigin);
static bool static bool
IsFirstPromptRequired(PersistenceType aPersistenceType, IsFirstPromptRequired(PersistenceType aPersistenceType,
const nsACString& aOrigin, const nsACString& aOrigin);
bool aIsApp);
static bool static bool
IsQuotaEnforced(PersistenceType aPersistenceType, IsQuotaEnforced(PersistenceType aPersistenceType);
const nsACString& aOrigin,
bool aIsApp);
static void static void
ChromeOrigin(nsACString& aOrigin); ChromeOrigin(nsACString& aOrigin);
@ -410,7 +395,6 @@ private:
CreateDirectoryLock(const Nullable<PersistenceType>& aPersistenceType, CreateDirectoryLock(const Nullable<PersistenceType>& aPersistenceType,
const nsACString& aGroup, const nsACString& aGroup,
const OriginScope& aOriginScope, const OriginScope& aOriginScope,
const Nullable<bool>& aIsApp,
const Nullable<Client::Type>& aClientType, const Nullable<Client::Type>& aClientType,
bool aExclusive, bool aExclusive,
bool aInternal, bool aInternal,
@ -419,8 +403,7 @@ private:
already_AddRefed<DirectoryLockImpl> already_AddRefed<DirectoryLockImpl>
CreateDirectoryLockForEviction(PersistenceType aPersistenceType, CreateDirectoryLockForEviction(PersistenceType aPersistenceType,
const nsACString& aGroup, const nsACString& aGroup,
const nsACString& aOrigin, const nsACString& aOrigin);
bool aIsApp);
void void
RegisterDirectoryLock(DirectoryLockImpl* aLock); RegisterDirectoryLock(DirectoryLockImpl* aLock);
@ -465,7 +448,6 @@ private:
InitializeOrigin(PersistenceType aPersistenceType, InitializeOrigin(PersistenceType aPersistenceType,
const nsACString& aGroup, const nsACString& aGroup,
const nsACString& aOrigin, const nsACString& aOrigin,
bool aIsApp,
int64_t aAccessTime, int64_t aAccessTime,
nsIFile* aDirectory); nsIFile* aDirectory);