From dcc35b89e65a59f480fa712a1c19216b6ad0b77a Mon Sep 17 00:00:00 2001 From: Jan Varga Date: Mon, 6 Mar 2017 18:38:42 +0100 Subject: [PATCH] Bug 1311057 - Part 2: Remove isApp from quota manager and its clients; r=asuth --- dom/asmjscache/AsmJSCache.cpp | 11 +- dom/base/nsDOMWindowUtils.cpp | 3 +- dom/cache/Context.cpp | 5 +- dom/cache/ManagerId.cpp | 3 +- dom/cache/Types.h | 2 - dom/indexedDB/ActorsParent.cpp | 34 +--- dom/indexedDB/FileManager.h | 8 - dom/indexedDB/IDBDatabase.cpp | 5 +- dom/indexedDB/IndexedDatabaseManager.cpp | 1 - dom/quota/ActorsParent.cpp | 208 ++++++++--------------- dom/quota/QuotaManager.h | 38 ++--- 11 files changed, 94 insertions(+), 224 deletions(-) diff --git a/dom/asmjscache/AsmJSCache.cpp b/dom/asmjscache/AsmJSCache.cpp index a9666403f2cf..bb747ea83cb9 100644 --- a/dom/asmjscache/AsmJSCache.cpp +++ b/dom/asmjscache/AsmJSCache.cpp @@ -351,7 +351,6 @@ public: mWriteParams(aWriteParams), mState(eInitial), mResult(JS::AsmJSCache_InternalError), - mIsApp(false), mEnforcingQuota(true), mDeleteReceived(false), mActorDestroyed(false), @@ -581,7 +580,6 @@ private: State mState; JS::AsmJSCacheResult mResult; - bool mIsApp; bool mEnforcingQuota; bool mDeleteReceived; bool mActorDestroyed; @@ -603,12 +601,11 @@ ParentRunnable::InitOnMainThread() } rv = QuotaManager::GetInfoFromPrincipal(principal, &mSuffix, &mGroup, - &mOrigin, &mIsApp); + &mOrigin); NS_ENSURE_SUCCESS(rv, rv); mEnforcingQuota = - QuotaManager::IsQuotaEnforced(quota::PERSISTENCE_TYPE_TEMPORARY, mOrigin, - mIsApp); + QuotaManager::IsQuotaEnforced(quota::PERSISTENCE_TYPE_TEMPORARY); return NS_OK; } @@ -627,7 +624,6 @@ ParentRunnable::OpenDirectory() QuotaManager::Get()->OpenDirectory(quota::PERSISTENCE_TYPE_TEMPORARY, mGroup, mOrigin, - mIsApp, quota::Client::ASMJS, /* aExclusive */ true, this); @@ -644,8 +640,7 @@ ParentRunnable::ReadMetadata() nsresult rv = qm->EnsureOriginIsInitialized(quota::PERSISTENCE_TYPE_TEMPORARY, mSuffix, - mGroup, mOrigin, mIsApp, - getter_AddRefs(mDirectory)); + mGroup, mOrigin, getter_AddRefs(mDirectory)); if (NS_WARN_IF(NS_FAILED(rv))) { mResult = JS::AsmJSCache_StorageInitFailure; return rv; diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 1548561f8e46..376c8e015d76 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -3059,8 +3059,7 @@ nsDOMWindowUtils::GetFileReferences(const nsAString& aDatabaseName, int64_t aId, nsCString origin; nsresult rv = - quota::QuotaManager::GetInfoFromWindow(window, nullptr, nullptr, &origin, - nullptr); + quota::QuotaManager::GetInfoFromWindow(window, nullptr, nullptr, &origin); NS_ENSURE_SUCCESS(rv, rv); IDBOpenDBOptions options; diff --git a/dom/cache/Context.cpp b/dom/cache/Context.cpp index 006af9c77ed3..ede2daeae11b 100644 --- a/dom/cache/Context.cpp +++ b/dom/cache/Context.cpp @@ -260,7 +260,6 @@ Context::QuotaInitRunnable::OpenDirectory() QuotaManager::Get()->OpenDirectory(PERSISTENCE_TYPE_DEFAULT, mQuotaInfo.mGroup, mQuotaInfo.mOrigin, - mQuotaInfo.mIsApp, quota::Client::DOMCACHE, /* aExclusive */ false, this); @@ -377,8 +376,7 @@ Context::QuotaInitRunnable::Run() nsresult rv = QuotaManager::GetInfoFromPrincipal(principal, &mQuotaInfo.mSuffix, &mQuotaInfo.mGroup, - &mQuotaInfo.mOrigin, - &mQuotaInfo.mIsApp); + &mQuotaInfo.mOrigin); if (NS_WARN_IF(NS_FAILED(rv))) { resolver->Resolve(rv); break; @@ -437,7 +435,6 @@ Context::QuotaInitRunnable::Run() mQuotaInfo.mSuffix, mQuotaInfo.mGroup, mQuotaInfo.mOrigin, - mQuotaInfo.mIsApp, getter_AddRefs(mQuotaInfo.mDir)); if (NS_FAILED(rv)) { resolver->Resolve(rv); diff --git a/dom/cache/ManagerId.cpp b/dom/cache/ManagerId.cpp index 43b46410c19b..6f82e57f0de7 100644 --- a/dom/cache/ManagerId.cpp +++ b/dom/cache/ManagerId.cpp @@ -30,8 +30,7 @@ ManagerId::Create(nsIPrincipal* aPrincipal, ManagerId** aManagerIdOut) nsresult rv = QuotaManager::GetInfoFromPrincipal(aPrincipal, nullptr, // suffix nullptr, // group - "aOrigin, - nullptr); // is app + "aOrigin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } RefPtr ref = new ManagerId(aPrincipal, quotaOrigin); diff --git a/dom/cache/Types.h b/dom/cache/Types.h index 1fc791a022bd..1b80d9a50ce5 100644 --- a/dom/cache/Types.h +++ b/dom/cache/Types.h @@ -29,12 +29,10 @@ static const CacheId INVALID_CACHE_ID = -1; struct QuotaInfo { - QuotaInfo() : mIsApp(false) { } nsCOMPtr mDir; nsCString mSuffix; nsCString mGroup; nsCString mOrigin; - bool mIsApp; }; } // namespace cache diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index fd4c970b7a3b..326b374eec11 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -7482,7 +7482,6 @@ protected: nsCString mDatabaseId; nsString mDatabaseFilePath; State mState; - bool mIsApp; bool mEnforcingQuota; const bool mDeleting; bool mBlockedDatabaseOpen; @@ -17087,7 +17086,6 @@ Cursor::RecvContinue(const CursorRequestParams& aParams) FileManager::FileManager(PersistenceType aPersistenceType, const nsACString& aGroup, const nsACString& aOrigin, - bool aIsApp, const nsAString& aDatabaseName, bool aEnforcingQuota) : mPersistenceType(aPersistenceType) @@ -17095,7 +17093,6 @@ FileManager::FileManager(PersistenceType aPersistenceType, , mOrigin(aOrigin) , mDatabaseName(aDatabaseName) , mLastFileId(0) - , mIsApp(aIsApp) , mEnforcingQuota(aEnforcingQuota) , mInvalidated(false) { } @@ -18646,14 +18643,12 @@ Maintenance::DirectoryWork() int64_t dummyTimeStamp; nsCString dummySuffix; - bool dummyIsApp; if (NS_WARN_IF(NS_FAILED( quotaManager->GetDirectoryMetadata2(originDir, &dummyTimeStamp, dummySuffix, group, - origin, - &dummyIsApp)))) { + origin)))) { // Not much we can do here... continue; } @@ -19486,7 +19481,6 @@ UpgradeFileIdsFunction::Init(nsIFile* aFMDirectory, new FileManager(PERSISTENCE_TYPE_INVALID, EmptyCString(), EmptyCString(), - false, EmptyString(), false); @@ -20735,7 +20729,6 @@ FactoryOp::FactoryOp(Factory* aFactory, , mContentParent(Move(aContentParent)) , mCommonParams(aCommonParams) , mState(State::Initial) - , mIsApp(false) , mEnforcingQuota(true) , mDeleting(aDeleting) , mBlockedDatabaseOpen(false) @@ -21084,13 +21077,12 @@ FactoryOp::CheckPermission(ContentParent* aContentParent, } if (State::Initial == mState) { - QuotaManager::GetInfoForChrome(&mSuffix, &mGroup, &mOrigin, &mIsApp); + QuotaManager::GetInfoForChrome(&mSuffix, &mGroup, &mOrigin); - MOZ_ASSERT(!QuotaManager::IsFirstPromptRequired(persistenceType, mOrigin, - mIsApp)); + MOZ_ASSERT(!QuotaManager::IsFirstPromptRequired(persistenceType, + mOrigin)); - mEnforcingQuota = - QuotaManager::IsQuotaEnforced(persistenceType, mOrigin, mIsApp); + mEnforcingQuota = QuotaManager::IsQuotaEnforced(persistenceType); } *aPermission = PermissionRequestBase::kPermissionAllowed; @@ -21109,27 +21101,24 @@ FactoryOp::CheckPermission(ContentParent* aContentParent, nsCString suffix; nsCString group; nsCString origin; - bool isApp; rv = QuotaManager::GetInfoFromPrincipal(principal, &suffix, &group, - &origin, - &isApp); + &origin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } #ifdef IDB_MOBILE if (persistenceType == PERSISTENCE_TYPE_PERSISTENT && - !QuotaManager::IsOriginWhitelistedForPersistentStorage(origin) && - !isApp) { + !QuotaManager::IsOriginWhitelistedForPersistentStorage(origin)) { return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; } #endif PermissionRequestBase::PermissionValue permission; - if (QuotaManager::IsFirstPromptRequired(persistenceType, origin, isApp)) { + if (QuotaManager::IsFirstPromptRequired(persistenceType, origin)) { rv = PermissionRequestBase::GetCurrentPermission(principal, &permission); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -21143,10 +21132,8 @@ FactoryOp::CheckPermission(ContentParent* aContentParent, mSuffix = suffix; mGroup = group; mOrigin = origin; - mIsApp = isApp; - mEnforcingQuota = - QuotaManager::IsQuotaEnforced(persistenceType, mOrigin, mIsApp); + mEnforcingQuota = QuotaManager::IsQuotaEnforced(persistenceType); } *aPermission = permission; @@ -21303,7 +21290,6 @@ FactoryOp::OpenDirectory() quotaManager->OpenDirectory(persistenceType, mGroup, mOrigin, - mIsApp, Client::IDB, /* aExclusive */ false, this); @@ -21558,7 +21544,6 @@ OpenDatabaseOp::DoDatabaseWork() mSuffix, mGroup, mOrigin, - mIsApp, getter_AddRefs(dbDirectory)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -21682,7 +21667,6 @@ OpenDatabaseOp::DoDatabaseWork() fileManager = new FileManager(persistenceType, mGroup, mOrigin, - mIsApp, databaseName, mEnforcingQuota); diff --git a/dom/indexedDB/FileManager.h b/dom/indexedDB/FileManager.h index 17b9dc61b1f3..c1ddd094c8ff 100644 --- a/dom/indexedDB/FileManager.h +++ b/dom/indexedDB/FileManager.h @@ -42,7 +42,6 @@ class FileManager final // Protected by IndexedDatabaseManager::FileMutex() nsDataHashtable mFileInfos; - const bool mIsApp; const bool mEnforcingQuota; bool mInvalidated; @@ -67,7 +66,6 @@ public: FileManager(PersistenceType aPersistenceType, const nsACString& aGroup, const nsACString& aOrigin, - bool aIsApp, const nsAString& aDatabaseName, bool aEnforcingQuota); @@ -89,12 +87,6 @@ public: return mOrigin; } - bool - IsApp() const - { - return mIsApp; - } - const nsAString& DatabaseName() const { diff --git a/dom/indexedDB/IDBDatabase.cpp b/dom/indexedDB/IDBDatabase.cpp index b94801a6057d..e05c6d05f177 100644 --- a/dom/indexedDB/IDBDatabase.cpp +++ b/dom/indexedDB/IDBDatabase.cpp @@ -1092,7 +1092,7 @@ IDBDatabase::GetQuotaInfo(nsACString& aOrigin, MOZ_CRASH("Is this needed?!"); case PrincipalInfo::TSystemPrincipalInfo: - QuotaManager::GetInfoForChrome(nullptr, nullptr, &aOrigin, nullptr); + QuotaManager::GetInfoForChrome(nullptr, nullptr, &aOrigin); return NS_OK; case PrincipalInfo::TContentPrincipalInfo: { @@ -1106,8 +1106,7 @@ IDBDatabase::GetQuotaInfo(nsACString& aOrigin, rv = QuotaManager::GetInfoFromPrincipal(principal, nullptr, nullptr, - &aOrigin, - nullptr); + &aOrigin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } diff --git a/dom/indexedDB/IndexedDatabaseManager.cpp b/dom/indexedDB/IndexedDatabaseManager.cpp index 6aa90415e372..05944199eeee 100644 --- a/dom/indexedDB/IndexedDatabaseManager.cpp +++ b/dom/indexedDB/IndexedDatabaseManager.cpp @@ -1366,7 +1366,6 @@ DeleteFilesRunnable::Open() quotaManager->OpenDirectory(mFileManager->Type(), mFileManager->Group(), mFileManager->Origin(), - mFileManager->IsApp(), Client::IDB, /* aExclusive */ false, this); diff --git a/dom/quota/ActorsParent.cpp b/dom/quota/ActorsParent.cpp index 20d878558ddf..70bcc50f7e0d 100644 --- a/dom/quota/ActorsParent.cpp +++ b/dom/quota/ActorsParent.cpp @@ -242,7 +242,6 @@ class DirectoryLockImpl final const Nullable mPersistenceType; const nsCString mGroup; const OriginScope mOriginScope; - const Nullable mIsApp; const Nullable mClientType; RefPtr mOpenListener; @@ -262,7 +261,6 @@ public: const Nullable& aPersistenceType, const nsACString& aGroup, const OriginScope& aOriginScope, - const Nullable& aIsApp, const Nullable& aClientType, bool aExclusive, bool aInternal, @@ -294,12 +292,6 @@ public: return mOriginScope; } - const Nullable& - GetIsApp() const - { - return mIsApp; - } - const Nullable& GetClientType() const { @@ -489,10 +481,10 @@ class OriginInfo final friend class QuotaObject; public: - OriginInfo(GroupInfo* aGroupInfo, const nsACString& aOrigin, bool aIsApp, + OriginInfo(GroupInfo* aGroupInfo, const nsACString& aOrigin, uint64_t aUsage, int64_t aAccessTime) : mGroupInfo(aGroupInfo), mOrigin(aOrigin), mUsage(aUsage), - mAccessTime(aAccessTime), mIsApp(aIsApp) + mAccessTime(aAccessTime) { MOZ_COUNT_CTOR(OriginInfo); } @@ -531,7 +523,6 @@ private: const nsCString mOrigin; uint64_t mUsage; int64_t mAccessTime; - const bool mIsApp; }; class OriginInfoLRUComparator @@ -1047,7 +1038,6 @@ class GetUsageOp final const UsageParams mParams; nsCString mSuffix; nsCString mGroup; - bool mIsApp; bool mGetGroupUsage; public: @@ -1369,7 +1359,6 @@ struct StorageDirectoryHelper::OriginProps nsCString mOrigin; Type mType; - bool mIsApp; bool mNeedsRestore; bool mIgnore; @@ -1377,7 +1366,6 @@ public: explicit OriginProps() : mTimestamp(0) , mType(eContent) - , mIsApp(false) , mNeedsRestore(false) , mIgnore(false) { } @@ -1571,22 +1559,15 @@ SanitizeOriginString(nsCString& aOrigin) } bool -IsTreatedAsPersistent(PersistenceType aPersistenceType, - bool aIsApp) +IsTreatedAsPersistent(PersistenceType aPersistenceType) { - if (aPersistenceType == PERSISTENCE_TYPE_PERSISTENT || - (aPersistenceType == PERSISTENCE_TYPE_DEFAULT && aIsApp)) { - return true; - } - - return false; + return aPersistenceType == PERSISTENCE_TYPE_PERSISTENT; } bool -IsTreatedAsTemporary(PersistenceType aPersistenceType, - bool aIsApp) +IsTreatedAsTemporary(PersistenceType aPersistenceType) { - return !IsTreatedAsPersistent(aPersistenceType, aIsApp); + return !IsTreatedAsPersistent(aPersistenceType); } nsresult @@ -1871,7 +1852,7 @@ GetJarPrefix(uint32_t aAppId, nsresult CreateDirectoryMetadata(nsIFile* aDirectory, int64_t aTimestamp, const nsACString& aSuffix, const nsACString& aGroup, - const nsACString& aOrigin, bool aIsApp) + const nsACString& aOrigin) { AssertIsOnIOThread(); @@ -1933,7 +1914,8 @@ CreateDirectoryMetadata(nsIFile* aDirectory, int64_t aTimestamp, return rv; } - rv = stream->WriteBoolean(aIsApp); + // Currently unused (used to be isApp). + rv = stream->WriteBoolean(false); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -1944,7 +1926,7 @@ CreateDirectoryMetadata(nsIFile* aDirectory, int64_t aTimestamp, nsresult CreateDirectoryMetadata2(nsIFile* aDirectory, int64_t aTimestamp, const nsACString& aSuffix, const nsACString& aGroup, - const nsACString& aOrigin, bool aIsApp) + const nsACString& aOrigin) { AssertIsOnIOThread(); @@ -1997,7 +1979,8 @@ CreateDirectoryMetadata2(nsIFile* aDirectory, int64_t aTimestamp, return rv; } - rv = stream->WriteBoolean(aIsApp); + // Currently unused (used to be isApp). + rv = stream->WriteBoolean(false); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -2119,7 +2102,6 @@ DirectoryLockImpl::DirectoryLockImpl(QuotaManager* aQuotaManager, const Nullable& aPersistenceType, const nsACString& aGroup, const OriginScope& aOriginScope, - const Nullable& aIsApp, const Nullable& aClientType, bool aExclusive, bool aInternal, @@ -2128,7 +2110,6 @@ DirectoryLockImpl::DirectoryLockImpl(QuotaManager* aQuotaManager, , mPersistenceType(aPersistenceType) , mGroup(aGroup) , mOriginScope(aOriginScope) - , mIsApp(aIsApp) , mClientType(aClientType) , mOpenListener(aOpenListener) , mExclusive(aExclusive) @@ -2143,7 +2124,6 @@ DirectoryLockImpl::DirectoryLockImpl(QuotaManager* aQuotaManager, aPersistenceType.Value() != PERSISTENCE_TYPE_INVALID); MOZ_ASSERT_IF(!aInternal, !aGroup.IsEmpty()); MOZ_ASSERT_IF(!aInternal, aOriginScope.IsOrigin()); - MOZ_ASSERT_IF(!aInternal, !aIsApp.IsNull()); MOZ_ASSERT_IF(!aInternal, !aClientType.IsNull()); MOZ_ASSERT_IF(!aInternal, aClientType.Value() != Client::TYPE_MAX); MOZ_ASSERT_IF(!aInternal, aOpenListener); @@ -2811,7 +2791,6 @@ auto QuotaManager::CreateDirectoryLock(const Nullable& aPersistenceType, const nsACString& aGroup, const OriginScope& aOriginScope, - const Nullable& aIsApp, const Nullable& aClientType, bool aExclusive, bool aInternal, @@ -2825,7 +2804,6 @@ QuotaManager::CreateDirectoryLock(const Nullable& aPersistenceT aPersistenceType.Value() != PERSISTENCE_TYPE_INVALID); MOZ_ASSERT_IF(!aInternal, !aGroup.IsEmpty()); MOZ_ASSERT_IF(!aInternal, aOriginScope.IsOrigin()); - MOZ_ASSERT_IF(!aInternal, !aIsApp.IsNull()); MOZ_ASSERT_IF(!aInternal, !aClientType.IsNull()); MOZ_ASSERT_IF(!aInternal, aClientType.Value() != Client::TYPE_MAX); MOZ_ASSERT_IF(!aInternal, aOpenListener); @@ -2834,7 +2812,6 @@ QuotaManager::CreateDirectoryLock(const Nullable& aPersistenceT aPersistenceType, aGroup, aOriginScope, - aIsApp, aClientType, aExclusive, aInternal, @@ -2866,8 +2843,7 @@ QuotaManager::CreateDirectoryLock(const Nullable& aPersistenceT auto QuotaManager::CreateDirectoryLockForEviction(PersistenceType aPersistenceType, const nsACString& aGroup, - const nsACString& aOrigin, - bool aIsApp) + const nsACString& aOrigin) -> already_AddRefed { AssertIsOnOwningThread(); @@ -2879,7 +2855,6 @@ QuotaManager::CreateDirectoryLockForEviction(PersistenceType aPersistenceType, Nullable(aPersistenceType), aGroup, OriginScope::FromOrigin(aOrigin), - Nullable(aIsApp), Nullable(), /* aExclusive */ true, /* aInternal */ true, @@ -2994,8 +2969,8 @@ QuotaManager::CollectOriginsForEviction( nsTArray& aInactiveOriginInfos) { for (OriginInfo* originInfo : aOriginInfos) { - MOZ_ASSERT(IsTreatedAsTemporary(originInfo->mGroupInfo->mPersistenceType, - originInfo->mIsApp)); + MOZ_ASSERT( + IsTreatedAsTemporary(originInfo->mGroupInfo->mPersistenceType)); OriginScope originScope = OriginScope::FromOrigin(originInfo->mOrigin); @@ -3098,8 +3073,7 @@ QuotaManager::CollectOriginsForEviction( RefPtr lock = CreateDirectoryLockForEviction(originInfo->mGroupInfo->mPersistenceType, originInfo->mGroupInfo->mGroup, - originInfo->mOrigin, - originInfo->mIsApp); + originInfo->mOrigin); aLocks.AppendElement(lock.forget()); } @@ -3249,12 +3223,11 @@ void QuotaManager::InitQuotaForOrigin(PersistenceType aPersistenceType, const nsACString& aGroup, const nsACString& aOrigin, - bool aIsApp, uint64_t aUsageBytes, int64_t aAccessTime) { AssertIsOnIOThread(); - MOZ_ASSERT(IsTreatedAsTemporary(aPersistenceType, aIsApp)); + MOZ_ASSERT(IsTreatedAsTemporary(aPersistenceType)); MutexAutoLock lock(mQuotaMutex); @@ -3272,7 +3245,7 @@ QuotaManager::InitQuotaForOrigin(PersistenceType aPersistenceType, } RefPtr originInfo = - new OriginInfo(groupInfo, aOrigin, aIsApp, aUsageBytes, aAccessTime); + new OriginInfo(groupInfo, aOrigin, aUsageBytes, aAccessTime); groupInfo->LockedAddOriginInfo(originInfo); } @@ -3521,13 +3494,11 @@ QuotaManager::GetDirectoryMetadata2(nsIFile* aDirectory, int64_t* aTimestamp, nsACString& aSuffix, nsACString& aGroup, - nsACString& aOrigin, - bool* aIsApp) + nsACString& aOrigin) { MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(aDirectory); MOZ_ASSERT(aTimestamp); - MOZ_ASSERT(aIsApp); MOZ_ASSERT(mStorageInitialized); nsCOMPtr binaryStream; @@ -3572,8 +3543,9 @@ QuotaManager::GetDirectoryMetadata2(nsIFile* aDirectory, rv = binaryStream->ReadCString(origin); NS_ENSURE_SUCCESS(rv, rv); - bool isApp; - rv = binaryStream->ReadBoolean(&isApp); + // Currently unused (used to be isApp). + bool dummy; + rv = binaryStream->ReadBoolean(&dummy); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -3582,7 +3554,6 @@ QuotaManager::GetDirectoryMetadata2(nsIFile* aDirectory, aSuffix = suffix; aGroup = group; aOrigin = origin; - *aIsApp = isApp; return NS_OK; } @@ -3592,15 +3563,13 @@ QuotaManager::GetDirectoryMetadata2WithRestore(nsIFile* aDirectory, int64_t* aTimestamp, nsACString& aSuffix, nsACString& aGroup, - nsACString& aOrigin, - bool* aIsApp) + nsACString& aOrigin) { nsresult rv = GetDirectoryMetadata2(aDirectory, aTimestamp, aSuffix, aGroup, - aOrigin, - aIsApp); + aOrigin); if (NS_WARN_IF(NS_FAILED(rv))) { rv = RestoreDirectoryMetadata2(aDirectory, aPersistent); if (NS_WARN_IF(NS_FAILED(rv))) { @@ -3611,8 +3580,7 @@ QuotaManager::GetDirectoryMetadata2WithRestore(nsIFile* aDirectory, aTimestamp, aSuffix, aGroup, - aOrigin, - aIsApp); + aOrigin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -3736,23 +3704,17 @@ QuotaManager::InitializeRepository(PersistenceType aPersistenceType) nsCString suffix; nsCString group; nsCString origin; - bool isApp; rv = GetDirectoryMetadata2WithRestore(childDirectory, /* aPersistent */ false, ×tamp, suffix, group, - origin, - &isApp); + origin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } - if (IsTreatedAsPersistent(aPersistenceType, isApp)) { - continue; - } - - rv = InitializeOrigin(aPersistenceType, group, origin, isApp, timestamp, + rv = InitializeOrigin(aPersistenceType, group, origin, timestamp, childDirectory); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -3800,7 +3762,6 @@ nsresult QuotaManager::InitializeOrigin(PersistenceType aPersistenceType, const nsACString& aGroup, const nsACString& aOrigin, - bool aIsApp, int64_t aAccessTime, nsIFile* aDirectory) { @@ -3808,7 +3769,7 @@ QuotaManager::InitializeOrigin(PersistenceType aPersistenceType, 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 // get the total usage to initialize the quota. @@ -3866,7 +3827,7 @@ QuotaManager::InitializeOrigin(PersistenceType aPersistenceType, } if (trackQuota) { - InitQuotaForOrigin(aPersistenceType, aGroup, aOrigin, aIsApp, + InitQuotaForOrigin(aPersistenceType, aGroup, aOrigin, usageInfo->TotalUsage(), aAccessTime); } @@ -4402,7 +4363,6 @@ void QuotaManager::OpenDirectory(PersistenceType aPersistenceType, const nsACString& aGroup, const nsACString& aOrigin, - bool aIsApp, Client::Type aClientType, bool aExclusive, OpenDirectoryListener* aOpenListener) @@ -4413,7 +4373,6 @@ QuotaManager::OpenDirectory(PersistenceType aPersistenceType, CreateDirectoryLock(Nullable(aPersistenceType), aGroup, OriginScope::FromOrigin(aOrigin), - Nullable(aIsApp), Nullable(aClientType), aExclusive, false, @@ -4434,7 +4393,6 @@ QuotaManager::OpenDirectoryInternal(const Nullable& aPersistenc CreateDirectoryLock(aPersistenceType, EmptyCString(), aOriginScope, - Nullable(), Nullable(aClientType), aExclusive, true, @@ -4490,7 +4448,6 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType, const nsACString& aSuffix, const nsACString& aGroup, const nsACString& aOrigin, - bool aIsApp, nsIFile** aDirectory) { AssertIsOnIOThread(); @@ -4504,7 +4461,7 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType, getter_AddRefs(directory)); NS_ENSURE_SUCCESS(rv, rv); - if (IsTreatedAsPersistent(aPersistenceType, aIsApp)) { + if (IsTreatedAsPersistent(aPersistenceType)) { if (mInitializedOrigins.Contains(OriginKey(aPersistenceType, aOrigin))) { directory.forget(aDirectory); return NS_OK; @@ -4586,7 +4543,7 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType, rv = EnsureDirectory(directory, &created); NS_ENSURE_SUCCESS(rv, rv); - if (IsTreatedAsPersistent(aPersistenceType, aIsApp)) { + if (IsTreatedAsPersistent(aPersistenceType)) { if (created) { timestamp = PR_Now(); @@ -4594,8 +4551,7 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType, timestamp, aSuffix, aGroup, - aOrigin, - aIsApp); + aOrigin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -4604,8 +4560,7 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType, timestamp, aSuffix, aGroup, - aOrigin, - aIsApp); + aOrigin); NS_ENSURE_SUCCESS(rv, rv); } else { bool persistent = aPersistenceType == PERSISTENCE_TYPE_PERSISTENT; @@ -4619,7 +4574,7 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType, MOZ_ASSERT(timestamp <= PR_Now()); } - rv = InitializeOrigin(aPersistenceType, aGroup, aOrigin, aIsApp, timestamp, + rv = InitializeOrigin(aPersistenceType, aGroup, aOrigin, timestamp, directory); NS_ENSURE_SUCCESS(rv, rv); @@ -4631,8 +4586,7 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType, timestamp, aSuffix, aGroup, - aOrigin, - aIsApp); + aOrigin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -4641,11 +4595,10 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType, timestamp, aSuffix, aGroup, - aOrigin, - aIsApp); + aOrigin); NS_ENSURE_SUCCESS(rv, rv); - rv = InitializeOrigin(aPersistenceType, aGroup, aOrigin, aIsApp, timestamp, + rv = InitializeOrigin(aPersistenceType, aGroup, aOrigin, timestamp, directory); NS_ENSURE_SUCCESS(rv, rv); } @@ -4656,12 +4609,11 @@ QuotaManager::EnsureOriginIsInitialized(PersistenceType aPersistenceType, void QuotaManager::OriginClearCompleted(PersistenceType aPersistenceType, - const nsACString& aOrigin, - bool aIsApp) + const nsACString& aOrigin) { AssertIsOnIOThread(); - if (IsTreatedAsPersistent(aPersistenceType, aIsApp)) { + if (IsTreatedAsPersistent(aPersistenceType)) { mInitializedOrigins.RemoveElement(OriginKey(aPersistenceType, aOrigin)); } @@ -4763,14 +4715,13 @@ nsresult QuotaManager::GetInfoFromPrincipal(nsIPrincipal* aPrincipal, nsACString* aSuffix, nsACString* aGroup, - nsACString* aOrigin, - bool* aIsApp) + nsACString* aOrigin) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aPrincipal); if (nsContentUtils::IsSystemPrincipal(aPrincipal)) { - GetInfoForChrome(aSuffix, aGroup, aOrigin, aIsApp); + GetInfoForChrome(aSuffix, aGroup, aOrigin); return NS_OK; } @@ -4828,11 +4779,6 @@ QuotaManager::GetInfoFromPrincipal(nsIPrincipal* aPrincipal, aOrigin->Assign(origin); } - if (aIsApp) { - *aIsApp = aPrincipal->GetAppStatus() != - nsIPrincipal::APP_STATUS_NOT_INSTALLED; - } - return NS_OK; } @@ -4841,8 +4787,7 @@ nsresult QuotaManager::GetInfoFromWindow(nsPIDOMWindowOuter* aWindow, nsACString* aSuffix, nsACString* aGroup, - nsACString* aOrigin, - bool* aIsApp) + nsACString* aOrigin) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aWindow); @@ -4854,7 +4799,7 @@ QuotaManager::GetInfoFromWindow(nsPIDOMWindowOuter* aWindow, NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE); nsresult rv = - GetInfoFromPrincipal(principal, aSuffix, aGroup, aOrigin, aIsApp); + GetInfoFromPrincipal(principal, aSuffix, aGroup, aOrigin); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; @@ -4864,8 +4809,7 @@ QuotaManager::GetInfoFromWindow(nsPIDOMWindowOuter* aWindow, void QuotaManager::GetInfoForChrome(nsACString* aSuffix, nsACString* aGroup, - nsACString* aOrigin, - bool* aIsApp) + nsACString* aOrigin) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(nsContentUtils::LegacyIsCallerChromeOrNativeCode()); @@ -4879,9 +4823,6 @@ QuotaManager::GetInfoForChrome(nsACString* aSuffix, if (aOrigin) { ChromeOrigin(*aOrigin); } - if (aIsApp) { - *aIsApp = false; - } } // static @@ -4903,10 +4844,9 @@ QuotaManager::IsOriginWhitelistedForPersistentStorage(const nsACString& aOrigin) // static bool QuotaManager::IsFirstPromptRequired(PersistenceType aPersistenceType, - const nsACString& aOrigin, - bool aIsApp) + const nsACString& aOrigin) { - if (IsTreatedAsTemporary(aPersistenceType, aIsApp)) { + if (IsTreatedAsTemporary(aPersistenceType)) { return false; } @@ -4915,11 +4855,9 @@ QuotaManager::IsFirstPromptRequired(PersistenceType aPersistenceType, // static bool -QuotaManager::IsQuotaEnforced(PersistenceType aPersistenceType, - const nsACString& aOrigin, - bool aIsApp) +QuotaManager::IsQuotaEnforced(PersistenceType aPersistenceType) { - return IsTreatedAsTemporary(aPersistenceType, aIsApp); + return IsTreatedAsTemporary(aPersistenceType); } // static @@ -5103,21 +5041,19 @@ QuotaManager::CheckTemporaryStorageLimits() doomedOriginInfo->mGroupInfo->mPersistenceType; nsCString group = doomedOriginInfo->mGroupInfo->mGroup; nsCString origin = doomedOriginInfo->mOrigin; - bool isApp = doomedOriginInfo->mIsApp; LockedRemoveQuotaForOrigin(persistenceType, group, origin); #ifdef DEBUG doomedOriginInfos[index] = nullptr; #endif - doomedOrigins.AppendElement(OriginParams(persistenceType, origin, isApp)); + doomedOrigins.AppendElement(OriginParams(persistenceType, origin)); } } for (const OriginParams& doomedOrigin : doomedOrigins) { OriginClearCompleted(doomedOrigin.mPersistenceType, - doomedOrigin.mOrigin, - doomedOrigin.mIsApp); + doomedOrigin.mOrigin); } } @@ -5595,8 +5531,7 @@ FinalizeOriginEvictionOp::DoDirectoryWork(QuotaManager* aQuotaManager) for (RefPtr& lock : mLocks) { aQuotaManager->OriginClearCompleted(lock->GetPersistenceType().Value(), - lock->GetOriginScope().GetOrigin(), - lock->GetIsApp().Value()); + lock->GetOriginScope().GetOrigin()); } return NS_OK; @@ -5971,8 +5906,8 @@ GetUsageOp::DoInitOnMainThread() // Figure out which origin we're dealing with. nsCString origin; - rv = QuotaManager::GetInfoFromPrincipal(principal, &mSuffix, &mGroup, &origin, - &mIsApp); + rv = QuotaManager::GetInfoFromPrincipal(principal, &mSuffix, &mGroup, + &origin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -6003,7 +5938,7 @@ GetUsageOp::AddToUsage(QuotaManager* aQuotaManager, if (exists && !mUsageInfo.Canceled()) { bool initialized; - if (IsTreatedAsPersistent(aPersistenceType, mIsApp)) { + if (IsTreatedAsPersistent(aPersistenceType)) { nsCString originKey = OriginKey(aPersistenceType, mOriginScope.GetOrigin()); initialized = aQuotaManager->IsOriginInitialized(originKey); @@ -6101,7 +6036,6 @@ GetUsageOp::DoDirectoryWork(QuotaManager* aQuotaManager) rv = aQuotaManager->EnsureOriginIsInitialized(PERSISTENCE_TYPE_TEMPORARY, mSuffix, mGroup, mOriginScope.GetOrigin(), - mIsApp, getter_AddRefs(directory)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -6365,8 +6299,8 @@ OriginClearOp::DoInitOnMainThread() // Figure out which origin we're dealing with. nsCString origin; - rv = QuotaManager::GetInfoFromPrincipal(principal, nullptr, nullptr, &origin, - nullptr); + rv = QuotaManager::GetInfoFromPrincipal(principal, nullptr, nullptr, + &origin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -6460,14 +6394,12 @@ OriginClearOp::DeleteFiles(QuotaManager* aQuotaManager, nsCString suffix; nsCString group; nsCString origin; - bool isApp; rv = aQuotaManager->GetDirectoryMetadata2WithRestore(file, persistent, ×tamp, suffix, group, - origin, - &isApp); + origin); if (NS_WARN_IF(NS_FAILED(rv))) { return; } @@ -6491,7 +6423,7 @@ OriginClearOp::DeleteFiles(QuotaManager* aQuotaManager, aQuotaManager->RemoveQuotaForOrigin(aPersistenceType, group, origin); } - aQuotaManager->OriginClearCompleted(aPersistenceType, origin, isApp); + aQuotaManager->OriginClearCompleted(aPersistenceType, origin); } } @@ -6626,8 +6558,7 @@ StorageDirectoryHelper::RunOnMainThread() case OriginProps::eChrome: { QuotaManager::GetInfoForChrome(&originProps.mSuffix, &originProps.mGroup, - &originProps.mOrigin, - &originProps.mIsApp); + &originProps.mOrigin); break; } @@ -6647,8 +6578,7 @@ StorageDirectoryHelper::RunOnMainThread() rv = QuotaManager::GetInfoFromPrincipal(principal, &originProps.mSuffix, &originProps.mGroup, - &originProps.mOrigin, - &originProps.mIsApp); + &originProps.mOrigin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -7369,8 +7299,7 @@ CreateOrUpgradeDirectoryMetadataHelper::DoProcessOriginDirectories() originProps.mTimestamp, originProps.mSuffix, originProps.mGroup, - originProps.mOrigin, - originProps.mIsApp); + originProps.mOrigin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -7437,8 +7366,7 @@ CreateOrUpgradeDirectoryMetadataHelper::DoProcessOriginDirectories() originProps.mTimestamp, originProps.mSuffix, originProps.mGroup, - originProps.mOrigin, - originProps.mIsApp); + originProps.mOrigin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -7454,7 +7382,8 @@ CreateOrUpgradeDirectoryMetadataHelper::DoProcessOriginDirectories() 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))) { return rv; } @@ -7627,8 +7556,7 @@ UpgradeDirectoryMetadataFrom1To2Helper::DoProcessOriginDirectories() originProps.mTimestamp, originProps.mSuffix, originProps.mGroup, - originProps.mOrigin, - originProps.mIsApp); + originProps.mOrigin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -7638,8 +7566,7 @@ UpgradeDirectoryMetadataFrom1To2Helper::DoProcessOriginDirectories() originProps.mTimestamp, originProps.mSuffix, originProps.mGroup, - originProps.mOrigin, - originProps.mIsApp); + originProps.mOrigin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -7709,8 +7636,7 @@ RestoreDirectoryMetadata2Helper::DoProcessOriginDirectories() originProps.mTimestamp, originProps.mSuffix, originProps.mGroup, - originProps.mOrigin, - originProps.mIsApp); + originProps.mOrigin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } diff --git a/dom/quota/QuotaManager.h b/dom/quota/QuotaManager.h index 6a9424b2e730..a8f6af1b99e7 100644 --- a/dom/quota/QuotaManager.h +++ b/dom/quota/QuotaManager.h @@ -78,16 +78,13 @@ protected: struct OriginParams { OriginParams(PersistenceType aPersistenceType, - const nsACString& aOrigin, - bool aIsApp) + const nsACString& aOrigin) : mOrigin(aOrigin) , mPersistenceType(aPersistenceType) - , mIsApp(aIsApp) { } nsCString mOrigin; PersistenceType mPersistenceType; - bool mIsApp; }; class QuotaManager final @@ -149,7 +146,6 @@ public: InitQuotaForOrigin(PersistenceType aPersistenceType, const nsACString& aGroup, const nsACString& aOrigin, - bool aIsApp, uint64_t aUsageBytes, int64_t aAccessTime); @@ -206,8 +202,7 @@ public: int64_t* aTimestamp, nsACString& aSuffix, nsACString& aGroup, - nsACString& aOrigin, - bool* aIsApp); + nsACString& aOrigin); nsresult GetDirectoryMetadata2WithRestore(nsIFile* aDirectory, @@ -215,8 +210,7 @@ public: int64_t* aTimestamp, nsACString& aSuffix, nsACString& aGroup, - nsACString& aOrigin, - bool* aIsApp); + nsACString& aOrigin); nsresult GetDirectoryMetadata2(nsIFile* aDirectory, int64_t* aTimestamp); @@ -245,7 +239,6 @@ public: OpenDirectory(PersistenceType aPersistenceType, const nsACString& aGroup, const nsACString& aOrigin, - bool aIsApp, Client::Type aClientType, bool aExclusive, OpenDirectoryListener* aOpenListener); @@ -271,13 +264,11 @@ public: const nsACString& aSuffix, const nsACString& aGroup, const nsACString& aOrigin, - bool aIsApp, nsIFile** aDirectory); void OriginClearCompleted(PersistenceType aPersistenceType, - const nsACString& aOrigin, - bool aIsApp); + const nsACString& aOrigin); void ResetOrClearCompleted(); @@ -363,34 +354,28 @@ public: GetInfoFromPrincipal(nsIPrincipal* aPrincipal, nsACString* aSuffix, nsACString* aGroup, - nsACString* aOrigin, - bool* aIsApp); + nsACString* aOrigin); static nsresult GetInfoFromWindow(nsPIDOMWindowOuter* aWindow, nsACString* aSuffix, nsACString* aGroup, - nsACString* aOrigin, - bool* aIsApp); + nsACString* aOrigin); static void GetInfoForChrome(nsACString* aSuffix, nsACString* aGroup, - nsACString* aOrigin, - bool* aIsApp); + nsACString* aOrigin); static bool IsOriginWhitelistedForPersistentStorage(const nsACString& aOrigin); static bool IsFirstPromptRequired(PersistenceType aPersistenceType, - const nsACString& aOrigin, - bool aIsApp); + const nsACString& aOrigin); static bool - IsQuotaEnforced(PersistenceType aPersistenceType, - const nsACString& aOrigin, - bool aIsApp); + IsQuotaEnforced(PersistenceType aPersistenceType); static void ChromeOrigin(nsACString& aOrigin); @@ -410,7 +395,6 @@ private: CreateDirectoryLock(const Nullable& aPersistenceType, const nsACString& aGroup, const OriginScope& aOriginScope, - const Nullable& aIsApp, const Nullable& aClientType, bool aExclusive, bool aInternal, @@ -419,8 +403,7 @@ private: already_AddRefed CreateDirectoryLockForEviction(PersistenceType aPersistenceType, const nsACString& aGroup, - const nsACString& aOrigin, - bool aIsApp); + const nsACString& aOrigin); void RegisterDirectoryLock(DirectoryLockImpl* aLock); @@ -465,7 +448,6 @@ private: InitializeOrigin(PersistenceType aPersistenceType, const nsACString& aGroup, const nsACString& aOrigin, - bool aIsApp, int64_t aAccessTime, nsIFile* aDirectory);