Unreviewed, rolling out r248526.
authorryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2019 00:30:51 +0000 (00:30 +0000)
committerryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2019 00:30:51 +0000 (00:30 +0000)
Caused two IndexedDB perf tests to fail

Reverted changeset:

"Remove IDB-specific quota"
https://bugs.webkit.org/show_bug.cgi?id=196545
https://trac.webkit.org/changeset/248526

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248699 268f45cc-cd09-0410-ab3c-d52691b4dbfc

39 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h
Source/WebCore/Modules/indexeddb/server/IDBServer.cpp
Source/WebCore/Modules/indexeddb/server/IDBServer.h
Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h
Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp
Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/NetworkProcess/NetworkProcess.messages.in
Source/WebKit/UIProcess/API/C/WKContext.cpp
Source/WebKit/UIProcess/API/C/WKContextPrivate.h
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKitLegacy/ChangeLog
Source/WebKitLegacy/Storage/WebDatabaseProvider.cpp
Source/WebKitLegacy/Storage/WebDatabaseProvider.h
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/Storage/WebDatabaseManager.mm
Source/WebKitLegacy/mac/Storage/WebDatabaseManagerPrivate.h
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/Interfaces/IWebDatabaseManager.idl
Source/WebKitLegacy/win/WebDatabaseManager.cpp
Source/WebKitLegacy/win/WebDatabaseManager.h
Tools/ChangeLog
Tools/DumpRenderTree/TestRunner.cpp
Tools/DumpRenderTree/TestRunner.h
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/DumpRenderTree/mac/TestRunnerMac.mm
Tools/DumpRenderTree/win/TestRunnerWin.cpp
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp

index 772db2b..b05e320 100644 (file)
@@ -1,3 +1,15 @@
+2019-08-14  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r248526.
+
+        Caused two IndexedDB perf tests to fail
+
+        Reverted changeset:
+
+        "Remove IDB-specific quota"
+        https://bugs.webkit.org/show_bug.cgi?id=196545
+        https://trac.webkit.org/changeset/248526
+
 2019-08-14  Keith Rollin  <krollin@apple.com>
 
         Remove support for macOS < 10.13
index 72ecf2e..291f76e 100644 (file)
@@ -100,6 +100,7 @@ public:
     virtual bool isEphemeral() = 0;
 
     virtual uint64_t databasesSizeForOrigin() const = 0;
+    virtual void setQuota(uint64_t) = 0;
 
     virtual bool hasTransaction(const IDBResourceIdentifier&) const = 0;
 protected:
index f6ab4f3..89bfe79 100644 (file)
@@ -135,7 +135,7 @@ std::unique_ptr<IDBBackingStore> IDBServer::createBackingStore(const IDBDatabase
     if (m_databaseDirectoryPath.isEmpty())
         return MemoryIDBBackingStore::create(identifier);
 
-    return std::make_unique<SQLiteIDBBackingStore>(m_sessionID, identifier, m_databaseDirectoryPath, m_backingStoreTemporaryFileHandler);
+    return std::make_unique<SQLiteIDBBackingStore>(m_sessionID, identifier, m_databaseDirectoryPath, m_backingStoreTemporaryFileHandler, m_perOriginQuota);
 }
 
 void IDBServer::openDatabase(const IDBRequestData& requestData)
@@ -691,6 +691,14 @@ void IDBServer::didPerformCloseAndDeleteDatabases(uint64_t callbackID)
     callback();
 }
 
+void IDBServer::setPerOriginQuota(uint64_t quota)
+{
+    m_perOriginQuota = quota;
+
+    for (auto& database : m_uniqueIDBDatabaseMap.values())
+        database->setQuota(quota);
+}
+
 IDBServer::QuotaUser::QuotaUser(IDBServer& server, StorageQuotaManager* manager, ClientOrigin&& origin)
     : m_server(server)
     , m_manager(makeWeakPtr(manager))
index 09f5c1c..4d328c4 100644 (file)
@@ -115,6 +115,9 @@ public:
     WEBCORE_EXPORT void closeAndDeleteDatabasesModifiedSince(WallTime, Function<void ()>&& completionHandler);
     WEBCORE_EXPORT void closeAndDeleteDatabasesForOrigins(const Vector<SecurityOriginData>&, Function<void ()>&& completionHandler);
 
+    uint64_t perOriginQuota() const { return m_perOriginQuota; }
+    WEBCORE_EXPORT void setPerOriginQuota(uint64_t);
+
     void requestSpace(const ClientOrigin&, uint64_t taskSize, CompletionHandler<void(StorageQuotaManager::Decision)>&&);
     void increasePotentialSpaceUsed(const ClientOrigin&, uint64_t taskSize);
     void decreasePotentialSpaceUsed(const ClientOrigin&, uint64_t taskSize);
@@ -193,6 +196,8 @@ private:
     String m_databaseDirectoryPath;
     IDBBackingStoreTemporaryFileHandler& m_backingStoreTemporaryFileHandler;
 
+    uint64_t m_perOriginQuota { defaultPerOriginQuota };
+
     HashMap<ClientOrigin, std::unique_ptr<QuotaUser>> m_quotaUsers;
     QuotaManagerGetter m_quotaManagerGetter;
 };
index 77cc969..15fe3c4 100644 (file)
@@ -79,6 +79,7 @@ public:
     bool supportsSimultaneousTransactions() final { return true; }
     bool isEphemeral() final { return true; }
 
+    void setQuota(uint64_t quota) final { UNUSED_PARAM(quota); };
     uint64_t databasesSizeForOrigin() const final;
 
     void removeObjectStoreForVersionChangeAbort(MemoryObjectStore&);
index 4f208e4..bfbd09d 100644 (file)
@@ -228,11 +228,12 @@ static const String& blobFilesTableSchemaAlternate()
     return blobFilesTableSchemaString;
 }
 
-SQLiteIDBBackingStore::SQLiteIDBBackingStore(PAL::SessionID sessionID, const IDBDatabaseIdentifier& identifier, const String& databaseRootDirectory, IDBBackingStoreTemporaryFileHandler& fileHandler)
+SQLiteIDBBackingStore::SQLiteIDBBackingStore(PAL::SessionID sessionID, const IDBDatabaseIdentifier& identifier, const String& databaseRootDirectory, IDBBackingStoreTemporaryFileHandler& fileHandler, uint64_t quota)
     : m_sessionID(sessionID)
     , m_identifier(identifier)
     , m_databaseRootDirectory(databaseRootDirectory)
     , m_temporaryFileHandler(fileHandler)
+    , m_quota(quota)
 {
     m_databaseDirectory = fullDatabaseDirectoryWithUpgrade();
 }
@@ -872,6 +873,14 @@ IDBError SQLiteIDBBackingStore::getOrEstablishDatabaseInfo(IDBDatabaseInfo& info
     return IDBError { };
 }
 
+uint64_t SQLiteIDBBackingStore::quotaForOrigin() const
+{
+    ASSERT(!isMainThread());
+    uint64_t diskFreeSpaceSize = 0;
+    FileSystem::getVolumeFreeSpace(m_identifier.databaseDirectoryRelativeToRoot(m_databaseRootDirectory), diskFreeSpaceSize);
+    return std::min(diskFreeSpaceSize / 2, m_quota);
+}
+
 uint64_t SQLiteIDBBackingStore::databasesSizeForFolder(const String& folder)
 {
     uint64_t diskUsage = 0;
@@ -889,6 +898,24 @@ uint64_t SQLiteIDBBackingStore::databasesSizeForOrigin() const
     return databasesSizeForFolder(oldVersionOriginDirectory) + databasesSizeForFolder(newVersionOriginDirectory);
 }
 
+uint64_t SQLiteIDBBackingStore::maximumSize() const
+{
+    ASSERT(!isMainThread());
+
+    // The maximum size for one database file is the quota for its origin, minus size of all databases within that origin,
+    // and plus current size of the database file.
+    uint64_t databaseFileSize = SQLiteFileSystem::getDatabaseFileSize(fullDatabasePath());
+    uint64_t quota = quotaForOrigin();
+
+    uint64_t diskUsage = databasesSizeForOrigin();
+    ASSERT(diskUsage >= databaseFileSize);
+
+    if (quota < diskUsage)
+        return databaseFileSize;
+
+    return quota - diskUsage + databaseFileSize;
+}
+
 IDBError SQLiteIDBBackingStore::beginTransaction(const IDBTransactionInfo& info)
 {
     LOG(IndexedDB, "SQLiteIDBBackingStore::beginTransaction - %s", info.identifier().loggingString().utf8().data());
@@ -897,6 +924,7 @@ IDBError SQLiteIDBBackingStore::beginTransaction(const IDBTransactionInfo& info)
     ASSERT(m_sqliteDB->isOpen());
     ASSERT(m_databaseInfo);
 
+    m_sqliteDB->setMaximumSize(maximumSize());
     auto addResult = m_transactions.add(info.identifier(), nullptr);
     if (!addResult.isNewEntry) {
         LOG_ERROR("Attempt to establish transaction identifier that already exists");
@@ -913,7 +941,10 @@ IDBError SQLiteIDBBackingStore::beginTransaction(const IDBTransactionInfo& info)
         if (sql.prepare() != SQLITE_OK
             || sql.bindText(1, String::number(info.newVersion())) != SQLITE_OK
             || sql.step() != SQLITE_DONE) {
-            error = IDBError { UnknownError, "Failed to store new database version in database"_s };
+            if (m_sqliteDB->lastError() == SQLITE_FULL)
+                error = IDBError { QuotaExceededError, "Failed to store new database version in database because no enough space for domain"_s };
+            else
+                error = IDBError { UnknownError, "Failed to store new database version in database"_s };
         }
     }
 
@@ -996,6 +1027,8 @@ IDBError SQLiteIDBBackingStore::createObjectStore(const IDBResourceIdentifier& t
             || sql->bindInt64(5, info.maxIndexID()) != SQLITE_OK
             || sql->step() != SQLITE_DONE) {
             LOG_ERROR("Could not add object store '%s' to ObjectStoreInfo table (%i) - %s", info.name().utf8().data(), m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            if (m_sqliteDB->lastError() == SQLITE_FULL)
+                return IDBError { QuotaExceededError, "Could not create object store because no enough space for domain"_s };
             return IDBError { UnknownError, "Could not create object store"_s };
         }
     }
@@ -1006,6 +1039,8 @@ IDBError SQLiteIDBBackingStore::createObjectStore(const IDBResourceIdentifier& t
             || sql->bindInt64(1, info.identifier()) != SQLITE_OK
             || sql->step() != SQLITE_DONE) {
             LOG_ERROR("Could not seed initial key generator value for ObjectStoreInfo table (%i) - %s", m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            if (m_sqliteDB->lastError() == SQLITE_FULL)
+                return IDBError { QuotaExceededError, "Could not seed initial key generator value for object store because no enough space for domain"_s };
             return IDBError { UnknownError, "Could not seed initial key generator value for object store"_s };
         }
     }
@@ -1129,6 +1164,8 @@ IDBError SQLiteIDBBackingStore::renameObjectStore(const IDBResourceIdentifier& t
             || sql->bindInt64(2, objectStoreIdentifier) != SQLITE_OK
             || sql->step() != SQLITE_DONE) {
             LOG_ERROR("Could not update name for object store id %" PRIi64 " in ObjectStoreInfo table (%i) - %s", objectStoreIdentifier, m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            if (m_sqliteDB->lastError() == SQLITE_FULL)
+                return IDBError { QuotaExceededError, "Could not rename object store because no enough space for domain"_s };
             return IDBError { UnknownError, "Could not rename object store"_s };
         }
     }
@@ -1210,6 +1247,8 @@ IDBError SQLiteIDBBackingStore::createIndex(const IDBResourceIdentifier& transac
         || sql->bindInt(6, info.multiEntry()) != SQLITE_OK
         || sql->step() != SQLITE_DONE) {
         LOG_ERROR("Could not add index '%s' to IndexInfo table (%i) - %s", info.name().utf8().data(), m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+        if (m_sqliteDB->lastError() == SQLITE_FULL)
+            return IDBError { QuotaExceededError, "Unable to create index in database because no enough space for domain"_s };
         return IDBError { UnknownError, "Unable to create index in database"_s };
     }
 
@@ -1358,6 +1397,8 @@ IDBError SQLiteIDBBackingStore::uncheckedPutIndexRecord(int64_t objectStoreID, i
             || sql->bindInt64(5, recordID) != SQLITE_OK
             || sql->step() != SQLITE_DONE) {
             LOG_ERROR("Could not put index record for index %" PRIi64 " in object store %" PRIi64 " in Records table (%i) - %s", indexID, objectStoreID, m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            if (m_sqliteDB->lastError() == SQLITE_FULL)
+                return IDBError { QuotaExceededError, "Error putting index record into database because no enough space for domain"_s };
             return IDBError { UnknownError, "Error putting index record into database"_s };
         }
     }
@@ -1443,6 +1484,8 @@ IDBError SQLiteIDBBackingStore::renameIndex(const IDBResourceIdentifier& transac
             || sql->bindInt64(3, indexIdentifier) != SQLITE_OK
             || sql->step() != SQLITE_DONE) {
             LOG_ERROR("Could not update name for index id (%" PRIi64 ", %" PRIi64 ") in IndexInfo table (%i) - %s", objectStoreIdentifier, indexIdentifier, m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            if (m_sqliteDB->lastError() == SQLITE_FULL)
+                return IDBError { QuotaExceededError, "Could not rename index because no enough space for domain"_s };
             return IDBError { UnknownError, "Could not rename index"_s };
         }
     }
@@ -1780,6 +1823,8 @@ IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transacti
             || sql->bindBlob(3, value.data().data()->data(), value.data().data()->size()) != SQLITE_OK
             || sql->step() != SQLITE_DONE) {
             LOG_ERROR("Could not put record for object store %" PRIi64 " in Records table (%i) - %s", objectStoreInfo.identifier(), m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            if (m_sqliteDB->lastError() == SQLITE_FULL)
+                return IDBError { QuotaExceededError, "Unable to store record in object store because no enough space for domain"_s };
             return IDBError { UnknownError, "Unable to store record in object store"_s };
         }
 
@@ -1812,6 +1857,8 @@ IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transacti
                 || sql->bindText(2, url) != SQLITE_OK
                 || sql->step() != SQLITE_DONE) {
                 LOG_ERROR("Unable to record Blob record in database");
+                if (m_sqliteDB->lastError() == SQLITE_FULL)
+                    return IDBError { QuotaExceededError, "Unable to record Blob record in database because no enough space for domain"_s };
                 return IDBError { UnknownError, "Unable to record Blob record in database"_s };
             }
         }
@@ -1845,6 +1892,8 @@ IDBError SQLiteIDBBackingStore::addRecord(const IDBResourceIdentifier& transacti
                 || sql->bindText(2, storedFilename) != SQLITE_OK
                 || sql->step() != SQLITE_DONE) {
                 LOG_ERROR("Unable to record Blob file record in database");
+                if (m_sqliteDB->lastError() == SQLITE_FULL)
+                    return IDBError { QuotaExceededError, "Unable to record Blob file in database because no enough space for domain"_s };
                 return IDBError { UnknownError, "Unable to record Blob file record in database"_s };
             }
         }
@@ -2380,6 +2429,8 @@ IDBError SQLiteIDBBackingStore::uncheckedSetKeyGeneratorValue(int64_t objectStor
         || sql->bindInt64(2, value) != SQLITE_OK
         || sql->step() != SQLITE_DONE) {
         LOG_ERROR("Could not update key generator value (%i) - %s", m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+        if (m_sqliteDB->lastError() == SQLITE_FULL)
+            return IDBError { QuotaExceededError, "Error storing new key generator value in database because no enough space for domain"_s };
         return IDBError { ConstraintError, "Error storing new key generator value in database" };
     }
 
index 2f7e0ca..06dc344 100644 (file)
@@ -48,7 +48,7 @@ class SQLiteIDBCursor;
 class SQLiteIDBBackingStore : public IDBBackingStore {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    SQLiteIDBBackingStore(PAL::SessionID, const IDBDatabaseIdentifier&, const String& databaseRootDirectory, IDBBackingStoreTemporaryFileHandler&);
+    SQLiteIDBBackingStore(PAL::SessionID, const IDBDatabaseIdentifier&, const String& databaseRootDirectory, IDBBackingStoreTemporaryFileHandler&, uint64_t quota);
     
     ~SQLiteIDBBackingStore() final;
 
@@ -81,6 +81,7 @@ public:
     IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier) final;
     void deleteBackingStore() final;
 
+    void setQuota(uint64_t quota) final { m_quota = quota; }
     uint64_t databasesSizeForOrigin() const final;
 
     bool supportsSimultaneousTransactions() final { return false; }
@@ -108,6 +109,9 @@ private:
     String fullDatabasePath() const;
     String fullDatabaseDirectoryWithUpgrade();
 
+    uint64_t quotaForOrigin() const;
+    uint64_t maximumSize() const;
+
     bool ensureValidRecordsTable();
     bool ensureValidIndexRecordsTable();
     bool ensureValidIndexRecordsIndex();
@@ -207,6 +211,8 @@ private:
     JSC::Strong<JSC::JSGlobalObject> m_globalObject;
 
     IDBBackingStoreTemporaryFileHandler& m_temporaryFileHandler;
+    
+    uint64_t m_quota;
 };
 
 } // namespace IDBServer
index 1ebc081..7304974 100644 (file)
@@ -2316,6 +2316,12 @@ void UniqueIDBDatabase::forgetErrorCallback(uint64_t callbackIdentifier)
     m_errorCallbacks.remove(callbackIdentifier);
 }
 
+void UniqueIDBDatabase::setQuota(uint64_t quota)
+{
+    if (m_backingStore)
+        m_backingStore->setQuota(quota);
+}
+
 void UniqueIDBDatabase::abortTransactionOnMainThread(UniqueIDBDatabaseTransaction& transaction)
 {
     transaction.setResult(m_backingStore->abortTransaction(transaction.info().identifier()));
index 2676a4f..8c2a1b3 100644 (file)
@@ -126,6 +126,8 @@ public:
 
     uint64_t spaceUsed() const;
 
+    void setQuota(uint64_t);
+
     void finishActiveTransactions();
 
 private:
index 32d8696..5f0f707 100644 (file)
@@ -1,3 +1,15 @@
+2019-08-14  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r248526.
+
+        Caused two IndexedDB perf tests to fail
+
+        Reverted changeset:
+
+        "Remove IDB-specific quota"
+        https://bugs.webkit.org/show_bug.cgi?id=196545
+        https://trac.webkit.org/changeset/248526
+
 2019-08-14  Andy Estes  <aestes@apple.com>
 
         Fix the build when ENABLE(APPLE_PAY) is false.
index e54a54f..e820b29 100644 (file)
@@ -2284,11 +2284,13 @@ Ref<IDBServer::IDBServer> NetworkProcess::createIDBServer(PAL::SessionID session
         path = m_idbDatabasePaths.get(sessionID);
     }
 
-    return IDBServer::IDBServer::create(sessionID, path, *this, [this, weakThis = makeWeakPtr(this)](PAL::SessionID sessionID, const auto& origin) -> StorageQuotaManager* {
+    auto server = IDBServer::IDBServer::create(sessionID, path, *this, [this, weakThis = makeWeakPtr(this)](PAL::SessionID sessionID, const auto& origin) -> StorageQuotaManager* {
         if (!weakThis)
             return nullptr;
         return &this->storageQuotaManager(sessionID, origin);
     });
+    server->setPerOriginQuota(m_idbPerOriginQuota);
+    return server;
 }
 
 IDBServer::IDBServer& NetworkProcess::idbServer(PAL::SessionID sessionID)
@@ -2384,6 +2386,14 @@ void NetworkProcess::addIndexedDatabaseSession(PAL::SessionID sessionID, String&
             postStorageTask(createCrossThreadTask(*this, &NetworkProcess::ensurePathExists, indexedDatabaseDirectory));
     }
 }
+
+void NetworkProcess::setIDBPerOriginQuota(uint64_t quota)
+{
+    m_idbPerOriginQuota = quota;
+    
+    for (auto& server : m_idbServers.values())
+        server->setPerOriginQuota(quota);
+}
 #endif // ENABLE(INDEXED_DATABASE)
 
 void NetworkProcess::updateQuotaBasedOnSpaceUsageForTesting(PAL::SessionID sessionID, const ClientOrigin& origin)
index a92b724..1beb7b6 100644 (file)
@@ -284,6 +284,7 @@ public:
     WebCore::IDBServer::IDBServer& idbServer(PAL::SessionID);
     // WebCore::IDBServer::IDBBackingStoreFileHandler.
     void accessToTemporaryFileComplete(const String& path) final;
+    void setIDBPerOriginQuota(uint64_t);
 #endif
     void updateQuotaBasedOnSpaceUsageForTesting(PAL::SessionID, const WebCore::ClientOrigin&);
 
@@ -524,6 +525,7 @@ private:
 #if ENABLE(INDEXED_DATABASE)
     HashMap<PAL::SessionID, String> m_idbDatabasePaths;
     HashMap<PAL::SessionID, RefPtr<WebCore::IDBServer::IDBServer>> m_idbServers;
+    uint64_t m_idbPerOriginQuota { WebCore::IDBServer::defaultPerOriginQuota };
 #endif
 
     Deque<CrossThreadTask> m_storageTasks;
index 200683b..b76daa1 100644 (file)
@@ -160,6 +160,9 @@ messages -> NetworkProcess LegacyReceiver {
     DisableServiceWorkerProcessTerminationDelay()
 #endif
 
+#if ENABLE(INDEXED_DATABASE)
+    SetIDBPerOriginQuota(uint64_t quota)
+#endif
     UpdateQuotaBasedOnSpaceUsageForTesting(PAL::SessionID sessionID, struct WebCore::ClientOrigin origin)
 
     StoreAdClickAttribution(PAL::SessionID sessionID, WebCore::AdClickAttribution adClickAttribution)
index afce70b..d0eb31a 100644 (file)
@@ -660,6 +660,11 @@ void WKContextClearSupportedPlugins(WKContextRef contextRef)
 #endif
 }
 
+void WKContextSetIDBPerOriginQuota(WKContextRef contextRef, uint64_t quota)
+{
+    WebKit::toImpl(contextRef)->setIDBPerOriginQuota(quota);
+}
+
 void WKContextClearCurrentModifierStateForTesting(WKContextRef contextRef)
 {
     WebKit::toImpl(contextRef)->clearCurrentModifierStateForTesting();
index 0c17b1a..f9c7d32 100644 (file)
@@ -116,6 +116,8 @@ WK_EXPORT WKProcessID WKContextGetNetworkProcessIdentifier(WKContextRef context)
 WK_EXPORT void WKContextAddSupportedPlugin(WKContextRef context, WKStringRef domain, WKStringRef name, WKArrayRef mimeTypes, WKArrayRef extensions);
 WK_EXPORT void WKContextClearSupportedPlugins(WKContextRef context);
 
+WK_EXPORT void WKContextSetIDBPerOriginQuota(WKContextRef context, uint64_t quota);
+
 WK_EXPORT void WKContextClearCurrentModifierStateForTesting(WKContextRef context);
 
 #ifdef __cplusplus
index 5e8819d..36367f0 100644 (file)
@@ -1802,6 +1802,13 @@ void WebProcessPool::syncNetworkProcessCookies()
     ensureNetworkProcess().syncAllCookies();
 }
 
+void WebProcessPool::setIDBPerOriginQuota(uint64_t quota)
+{
+#if ENABLE(INDEXED_DATABASE)
+    ensureNetworkProcess().send(Messages::NetworkProcess::SetIDBPerOriginQuota(quota), 0);
+#endif
+}
+
 void WebProcessPool::allowSpecificHTTPSCertificateForHost(const WebCertificateInfo* certificate, const String& host)
 {
     ensureNetworkProcess();
index d06c440..2ccb47f 100644 (file)
@@ -318,6 +318,8 @@ public:
 
     void syncNetworkProcessCookies();
 
+    void setIDBPerOriginQuota(uint64_t);
+
     void setShouldMakeNextWebProcessLaunchFailForTesting(bool value) { m_shouldMakeNextWebProcessLaunchFailForTesting = value; }
     bool shouldMakeNextWebProcessLaunchFailForTesting() const { return m_shouldMakeNextWebProcessLaunchFailForTesting; }
     void setShouldMakeNextNetworkProcessLaunchFailForTesting(bool value) { m_shouldMakeNextNetworkProcessLaunchFailForTesting = value; }
index 4c51e96..d7bffcb 100644 (file)
@@ -1,3 +1,15 @@
+2019-08-14  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r248526.
+
+        Caused two IndexedDB perf tests to fail
+
+        Reverted changeset:
+
+        "Remove IDB-specific quota"
+        https://bugs.webkit.org/show_bug.cgi?id=196545
+        https://trac.webkit.org/changeset/248526
+
 2019-08-12  Youenn Fablet  <youenn@apple.com>
 
         Remove IDB-specific quota
index 2eb7053..5ee5a7b 100644 (file)
@@ -45,9 +45,17 @@ WebDatabaseProvider::~WebDatabaseProvider()
 #if ENABLE(INDEXED_DATABASE)
 WebCore::IDBClient::IDBConnectionToServer& WebDatabaseProvider::idbConnectionToServerForSession(const PAL::SessionID& sessionID)
 {
-    return m_idbServerMap.ensure(sessionID.sessionID(), [&sessionID] {
-        return sessionID.isEphemeral() ? WebCore::InProcessIDBServer::create(sessionID) : WebCore::InProcessIDBServer::create(sessionID, indexedDatabaseDirectoryPath());
-    }).iterator->value->connectionToServer();
+    auto result = m_idbServerMap.add(sessionID.sessionID(), nullptr);
+    if (result.isNewEntry) {
+        if (sessionID.isEphemeral())
+            result.iterator->value = WebCore::InProcessIDBServer::create(sessionID);
+        else
+            result.iterator->value = WebCore::InProcessIDBServer::create(sessionID, indexedDatabaseDirectoryPath());
+    }
+
+    result.iterator->value->idbServer().setPerOriginQuota(m_idbPerOriginQuota);
+
+    return result.iterator->value->connectionToServer();
 }
 
 void WebDatabaseProvider::deleteAllDatabases()
@@ -55,4 +63,13 @@ void WebDatabaseProvider::deleteAllDatabases()
     for (auto& server : m_idbServerMap.values())
         server->idbServer().closeAndDeleteDatabasesModifiedSince(-WallTime::infinity(), [] { });
 }
+
+void WebDatabaseProvider::setIDBPerOriginQuota(uint64_t quota)
+{
+    m_idbPerOriginQuota = quota;
+
+    for (auto& server : m_idbServerMap.values())
+        server->idbServer().setPerOriginQuota(quota);
+}
+
 #endif
index 3f506d7..5222330 100644 (file)
@@ -44,6 +44,8 @@ public:
     WebCore::IDBClient::IDBConnectionToServer& idbConnectionToServerForSession(const PAL::SessionID&) override;
 
     void deleteAllDatabases();
+
+    void setIDBPerOriginQuota(uint64_t);
 #endif
 
 private:
@@ -53,5 +55,6 @@ private:
 
 #if ENABLE(INDEXED_DATABASE)
     HashMap<uint64_t, RefPtr<WebCore::InProcessIDBServer>> m_idbServerMap;
+    uint64_t m_idbPerOriginQuota { WebCore::IDBServer::defaultPerOriginQuota };
 #endif
 };
index 0cc4acb..02a1ce7 100644 (file)
@@ -1,3 +1,15 @@
+2019-08-14  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r248526.
+
+        Caused two IndexedDB perf tests to fail
+
+        Reverted changeset:
+
+        "Remove IDB-specific quota"
+        https://bugs.webkit.org/show_bug.cgi?id=196545
+        https://trac.webkit.org/changeset/248526
+
 2019-08-14  Keith Rollin  <krollin@apple.com>
 
         Remove support for macOS < 10.13
index 73e2331..6d62a98 100644 (file)
@@ -157,6 +157,13 @@ static NSString *databasesDirectoryPath();
 #endif
 }
 
+- (void)setIDBPerOriginQuota:(uint64_t)quota
+{
+#if ENABLE(INDEXED_DATABASE)
+    WebDatabaseProvider::singleton().setIDBPerOriginQuota(quota);
+#endif
+}
+
 #if PLATFORM(IOS_FAMILY)
 
 static bool isFileHidden(NSString *file)
index 939b4cf..2172416 100644 (file)
@@ -70,6 +70,7 @@ extern CFStringRef WebDatabaseOriginsDidChangeNotification;
 
 // For DumpRenderTree support only
 - (void)deleteAllIndexedDatabases;
+- (void)setIDBPerOriginQuota:(uint64_t)quota;
 
 #if TARGET_OS_IPHONE
 + (void)scheduleEmptyDatabaseRemoval;
index ca14599..46030bb 100644 (file)
@@ -1,3 +1,15 @@
+2019-08-14  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r248526.
+
+        Caused two IndexedDB perf tests to fail
+
+        Reverted changeset:
+
+        "Remove IDB-specific quota"
+        https://bugs.webkit.org/show_bug.cgi?id=196545
+        https://trac.webkit.org/changeset/248526
+
 2019-08-14  Youenn Fablet  <youenn@apple.com>
 
         ThreadableBlobRegistry::blobSize should take a SessionID as parameter
index 7aebcae..e81d493 100644 (file)
@@ -69,4 +69,5 @@ interface IWebDatabaseManager : IUnknown
 interface IWebDatabaseManager2 : IWebDatabaseManager
 {
     HRESULT deleteAllIndexedDatabases();
+    HRESULT setIDBPerOriginQuota([in] unsigned long long quota);
 }
index 68c6bd4..2493c7b 100644 (file)
@@ -346,6 +346,14 @@ HRESULT WebDatabaseManager::deleteAllIndexedDatabases()
     return S_OK;
 }
 
+HRESULT WebDatabaseManager::setIDBPerOriginQuota(unsigned long long quota)
+{
+#if ENABLE(INDEXED_DATABASE)
+    WebDatabaseProvider::singleton().setIDBPerOriginQuota(quota);
+#endif
+    return S_OK;
+}
+
 class DidModifyOriginData {
     WTF_MAKE_NONCOPYABLE(DidModifyOriginData);
 public:
index 51b645f..e0fe3e3 100644 (file)
@@ -56,6 +56,7 @@ public:
 
     // IWebDatabaseManager2
     virtual HRESULT STDMETHODCALLTYPE deleteAllIndexedDatabases();
+    virtual HRESULT STDMETHODCALLTYPE setIDBPerOriginQuota(unsigned long long);
 
     // DatabaseManagerClient
     virtual void dispatchDidModifyOrigin(const WebCore::SecurityOriginData&);
index 81fc20d..c8bfba2 100644 (file)
@@ -1,3 +1,15 @@
+2019-08-14  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r248526.
+
+        Caused two IndexedDB perf tests to fail
+
+        Reverted changeset:
+
+        "Remove IDB-specific quota"
+        https://bugs.webkit.org/show_bug.cgi?id=196545
+        https://trac.webkit.org/changeset/248526
+
 2019-08-14  Keith Rollin  <krollin@apple.com>
 
         Remove support for macOS < 10.13
index e817a57..90c64c3 100644 (file)
@@ -893,6 +893,20 @@ static JSValueRef setDatabaseQuotaCallback(JSContextRef context, JSObjectRef fun
     return JSValueMakeUndefined(context);
 }
 
+static JSValueRef setIDBPerOriginQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+    
+    auto* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
+    
+    double quota = JSValueToNumber(context, arguments[0], nullptr);
+    if (!std::isnan(quota))
+        controller->setIDBPerOriginQuota(static_cast<uint64_t>(quota));
+    
+    return JSValueMakeUndefined(context);
+}
+
 static JSValueRef setDefersLoadingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     if (argumentCount < 1)
@@ -2206,6 +2220,7 @@ JSStaticFunction* TestRunner::staticFunctions()
         { "setRejectsProtectionSpaceAndContinueForAuthenticationChallenges", setRejectsProtectionSpaceAndContinueForAuthenticationChallengesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setHandlesAuthenticationChallenges", setHandlesAuthenticationChallengesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setIconDatabaseEnabled", setIconDatabaseEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setIDBPerOriginQuota", setIDBPerOriginQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAutomaticLinkDetectionEnabled", setAutomaticLinkDetectionEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setMainFrameIsFirstResponder", setMainFrameIsFirstResponderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setMockDeviceOrientation", setMockDeviceOrientationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
index 29a4ef2..8145247 100644 (file)
@@ -106,6 +106,7 @@ public:
     void setDomainRelaxationForbiddenForURLScheme(bool forbidden, JSStringRef scheme);
     void setDefersLoading(bool);
     void setIconDatabaseEnabled(bool);
+    void setIDBPerOriginQuota(uint64_t);
     void setJavaScriptCanAccessClipboard(bool flag);
     void setAutomaticLinkDetectionEnabled(bool flag);
     void setMainFrameIsFirstResponder(bool flag);
index 64db1d1..2e9397f 100644 (file)
@@ -2035,6 +2035,7 @@ static void runTest(const string& inputLine)
     gTestRunner->clearAllApplicationCaches();
 
     gTestRunner->clearAllDatabases();
+    gTestRunner->setIDBPerOriginQuota(50 * MB);
 
     if (disallowedURLs)
         CFSetRemoveAllValues(disallowedURLs);
index 1f960aa..c01bda5 100644 (file)
@@ -439,6 +439,11 @@ void TestRunner::setDatabaseQuota(unsigned long long quota)
     [origin release];
 }
 
+void TestRunner::setIDBPerOriginQuota(uint64_t quota)
+{
+    [[WebDatabaseManager sharedWebDatabaseManager] setIDBPerOriginQuota:quota];
+}
+
 void TestRunner::goBack()
 {
     [[mainFrame webView] goBack];
index 95ad022..a286f23 100644 (file)
@@ -172,6 +172,22 @@ void TestRunner::clearAllDatabases()
     databaseManager2->deleteAllIndexedDatabases();
 }
 
+void TestRunner::setIDBPerOriginQuota(uint64_t quota)
+{
+    COMPtr<IWebDatabaseManager> databaseManager;
+    COMPtr<IWebDatabaseManager> tmpDatabaseManager;
+    if (FAILED(WebKitCreateInstance(CLSID_WebDatabaseManager, 0, IID_IWebDatabaseManager, (void**)&tmpDatabaseManager)))
+        return;
+    if (FAILED(tmpDatabaseManager->sharedWebDatabaseManager(&databaseManager)))
+        return;
+
+    COMPtr<IWebDatabaseManager2> databaseManager2;
+    if (FAILED(databaseManager->QueryInterface(&databaseManager2)))
+        return;
+
+    databaseManager2->setIDBPerOriginQuota(quota);
+}
+
 void TestRunner::setStorageDatabaseIdleInterval(double)
 {
     // FIXME: Implement. Requires non-existant (on Windows) WebStorageManager
index aceed40..158d2f6 100644 (file)
@@ -146,6 +146,9 @@ interface TestRunner {
     attribute double databaseDefaultQuota;
     attribute double databaseMaxQuota;
 
+    // IndexedDB API
+    void setIDBPerOriginQuota(unsigned long long quota);
+
     // Application Cache API
     void clearAllApplicationCaches();
     void setAppCacheMaximumSize(unsigned long long size);
index 3729e05..1860f16 100644 (file)
@@ -367,6 +367,13 @@ void TestRunner::disallowIncreaseForApplicationCacheQuota()
     m_disallowIncreaseForApplicationCacheQuota = true;
 }
 
+void TestRunner::setIDBPerOriginQuota(uint64_t quota)
+{
+    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetIDBPerOriginQuota"));
+    WKRetainPtr<WKUInt64Ref> messageBody = adoptWK(WKUInt64Create(quota));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
+}
+
 static inline JSValueRef stringArrayToJS(JSContextRef context, WKArrayRef strings)
 {
     const size_t count = WKArrayGetSize(strings);
index cafe776..75093d0 100644 (file)
@@ -175,6 +175,9 @@ public:
     uint64_t domCacheSize(JSStringRef origin);
     void setAllowStorageQuotaIncrease(bool);
 
+    // IndexedDB
+    void setIDBPerOriginQuota(uint64_t);
+
     // Failed load condition testing
     void forceImmediateCompletion();
 
index 8fed592..8e733be 100644 (file)
@@ -940,6 +940,7 @@ bool TestController::resetStateToConsistentValues(const TestOptions& options, Re
     WKWebsiteDataStoreClearAllDeviceOrientationPermissions(websiteDataStore);
 
     ClearIndexedDatabases();
+    setIDBPerOriginQuota(50 * MB);
 
     clearServiceWorkerRegistrations();
     clearDOMCaches();
@@ -3063,6 +3064,11 @@ void TestController::clearDOMCaches()
     runUntil(context.done, noTimeout);
 }
 
+void TestController::setIDBPerOriginQuota(uint64_t quota)
+{
+    WKContextSetIDBPerOriginQuota(platformContext(), quota);
+}
+
 struct RemoveAllIndexedDatabasesCallbackContext {
     explicit RemoveAllIndexedDatabasesCallbackContext(TestController& controller)
         : testController(controller)
index 8e11197..b95cea3 100644 (file)
@@ -273,6 +273,8 @@ public:
 
     void setAllowStorageQuotaIncrease(bool);
 
+    void setIDBPerOriginQuota(uint64_t);
+
     bool didReceiveServerRedirectForProvisionalNavigation() const { return m_didReceiveServerRedirectForProvisionalNavigation; }
     void clearDidReceiveServerRedirectForProvisionalNavigation() { m_didReceiveServerRedirectForProvisionalNavigation = false; }
 
index 4d59e83..28ad1ed 100644 (file)
@@ -1514,6 +1514,13 @@ WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedB
         return nullptr;
     }
 
+    if (WKStringIsEqualToUTF8CString(messageName, "SetIDBPerOriginQuota")) {
+        ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID());
+        WKUInt64Ref quota = static_cast<WKUInt64Ref>(messageBody);
+        TestController::singleton().setIDBPerOriginQuota(WKUInt64GetValue(quota));
+        return nullptr;
+    }
+
     if (WKStringIsEqualToUTF8CString(messageName, "InjectUserScript")) {
         ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
         WKStringRef script = static_cast<WKStringRef>(messageBody);