Add a storage limit for IndexedDB
authorsihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Nov 2018 21:11:57 +0000 (21:11 +0000)
committersihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Nov 2018 21:11:57 +0000 (21:11 +0000)
commit96132be46f3f3ad3e0aa2a79610ac5fb10d94ff5
tree3de3fc7b254d89ce7e73046dd5853571a1221426
parentaa1f92d8633635f108bc59a02744c0f43105ec0f
Add a storage limit for IndexedDB
https://bugs.webkit.org/show_bug.cgi?id=190598
<rdar://problem/44654715>

Reviewed by Chris Dumez.

Source/WebCore:

Set a storage limit in IndexedDB for each pair of mainFrameOrigin and openingOrigin.
IndexedDB will return a QuotaExceededError if limit is reached.

If the size of free disk space is over 1 GB, the default limit is 500 MB; otherwise it is
half the free disk space.

Test: storage/indexeddb/storage-limit.html

* Modules/indexeddb/server/IDBBackingStore.h:
* Modules/indexeddb/server/IDBServer.cpp:
(WebCore::IDBServer::IDBServer::createBackingStore):
(WebCore::IDBServer::IDBServer::setPerOriginQuota):
* Modules/indexeddb/server/IDBServer.h:
(WebCore::IDBServer::IDBServer::perOriginQuota const):
* Modules/indexeddb/server/MemoryIDBBackingStore.h:
* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::SQLiteIDBBackingStore):
(WebCore::IDBServer::SQLiteIDBBackingStore::quotaForOrigin const):
(WebCore::IDBServer::SQLiteIDBBackingStore::maximumSize const):
(WebCore::IDBServer::SQLiteIDBBackingStore::beginTransaction):
(WebCore::IDBServer::SQLiteIDBBackingStore::createObjectStore):
(WebCore::IDBServer::SQLiteIDBBackingStore::renameObjectStore):
(WebCore::IDBServer::SQLiteIDBBackingStore::createIndex):
(WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedPutIndexRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::renameIndex):
(WebCore::IDBServer::SQLiteIDBBackingStore::addRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedSetKeyGeneratorValue):
* Modules/indexeddb/server/SQLiteIDBBackingStore.h:
* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::setQuota):
* Modules/indexeddb/server/UniqueIDBDatabase.h:

Source/WebKit:

Add SPI for testing.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::NetworkProcess):
(WebKit::NetworkProcess::idbServer):
(WebKit::NetworkProcess::setIDBPerOriginQuota):
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* UIProcess/API/C/WKContext.cpp:
(WKContextSetIDBPerOriginQuota):
* UIProcess/API/C/WKContextPrivate.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::setIDBPerOriginQuota):
* UIProcess/WebProcessPool.h:

Source/WebKitLegacy:

* Storage/WebDatabaseProvider.cpp:
(WebDatabaseProvider::idbConnectionToServerForSession):
(WebDatabaseProvider::setIDBPerOriginQuota):
* Storage/WebDatabaseProvider.h:

Source/WebKitLegacy/mac:

* Storage/WebDatabaseManager.mm:
(-[WebDatabaseManager setIDBPerOriginQuota:]):
* Storage/WebDatabaseManagerPrivate.h:

Source/WebKitLegacy/win:

* Interfaces/IWebDatabaseManager.idl:
* WebDatabaseManager.cpp:
(WebDatabaseManager::setIDBPerOriginQuota):
* WebDatabaseManager.h:

Tools:

Add API for testing.

* DumpRenderTree/TestRunner.cpp:
(setIDBPerOriginQuotaCallback):
(TestRunner::staticFunctions):
* DumpRenderTree/TestRunner.h:
* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::setIDBPerOriginQuota):
* DumpRenderTree/win/TestRunnerWin.cpp:
(TestRunner::setIDBPerOriginQuota):
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setIDBPerOriginQuota):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::setIDBPerOriginQuota):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

Some tests will fail after adding storage limit to IndexedDB, so we need to reduce their
size and rebase their expectations.

* storage/indexeddb/key-type-array-expected.txt:
* storage/indexeddb/key-type-array-private-expected.txt:
* storage/indexeddb/modern/idbkey-array-equality-expected.txt:
* storage/indexeddb/modern/idbkey-array-equality-private-expected.txt:
* storage/indexeddb/modern/resources/idbkey-array-equality.js:
(request.onsuccess):
(request.onerror):
(doAdd):
* storage/indexeddb/prefetch-invalidation-expected.txt:
* storage/indexeddb/prefetch-invalidation-private-expected.txt:
* storage/indexeddb/resources/key-type-array.js:
(testValidArrayKeys.getreq.onsuccess):
(testValidArrayKeys.putreq.onsuccess):
(testValidArrayKeys.testArrayPutGet):
* storage/indexeddb/resources/prefetch-invalidation.js:
(cursorRequest.onsuccess):
(continue50Times):
(continue100Times): Deleted.
* storage/indexeddb/resources/storage-limit.js: Added.
(prepareDatabase):
(onOpenSuccess.request.onerror):
(onOpenSuccess.request.onsuccess):
(onOpenSuccess):
* storage/indexeddb/storage-limit-expected.txt: Added.
* storage/indexeddb/storage-limit.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237700 268f45cc-cd09-0410-ab3c-d52691b4dbfc
51 files changed:
LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/key-type-array-expected.txt
LayoutTests/storage/indexeddb/key-type-array-private-expected.txt
LayoutTests/storage/indexeddb/modern/idbkey-array-equality-expected.txt
LayoutTests/storage/indexeddb/modern/idbkey-array-equality-private-expected.txt
LayoutTests/storage/indexeddb/modern/resources/idbkey-array-equality.js
LayoutTests/storage/indexeddb/prefetch-invalidation-expected.txt
LayoutTests/storage/indexeddb/prefetch-invalidation-private-expected.txt
LayoutTests/storage/indexeddb/resources/key-type-array.js
LayoutTests/storage/indexeddb/resources/prefetch-invalidation.js
LayoutTests/storage/indexeddb/resources/storage-limit.js [new file with mode: 0644]
LayoutTests/storage/indexeddb/storage-limit-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/storage-limit.html [new file with mode: 0644]
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/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