Include WAL and SHM file size in IDB database size computation
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2019 01:24:52 +0000 (01:24 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2019 01:24:52 +0000 (01:24 +0000)
commit12256883bb83e1f77d0edb6fa1900f4ae016390a
tree6ce267e409b58e72aea83990e85378c08014c34d
parent65a9d233caf83244fbab2a5d83d8bd6be5b78401
Include WAL and SHM file size in IDB database size computation
https://bugs.webkit.org/show_bug.cgi?id=195688

Reviewed by Brady Eidson.

Source/WebCore:

Count WAL and SHM files as part of IDB quota checks.
This makes some IDB tests go over the testing quota which then
triggers some IDB tasks to happen sooner than other write IDB tasks.
The IDB implementation requires these tasks to remain ordered.
In case a write task is pending quota check, queue all tasks,
write or read, to keep the order.

This patch specials case aborting a transaction.
In case it is called as part of clearing a database,
the task should not be queued and all pending tasks are errored.
When transaction is aborted by the web page, queue the task.

When we can make a decision to run tasks with size 0,
do not check quota. This ensures that read operations
succeed even if we are above quota.

Covered by existing tests.

* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::waitForRequestSpaceCompletion):
(WebCore::IDBServer::UniqueIDBDatabase::deleteObjectStore):
(WebCore::IDBServer::UniqueIDBDatabase::clearObjectStore):
(WebCore::IDBServer::UniqueIDBDatabase::deleteIndex):
(WebCore::IDBServer::UniqueIDBDatabase::getRecord):
(WebCore::IDBServer::UniqueIDBDatabase::getAllRecords):
(WebCore::IDBServer::UniqueIDBDatabase::getCount):
(WebCore::IDBServer::UniqueIDBDatabase::deleteRecord):
(WebCore::IDBServer::UniqueIDBDatabase::openCursor):
(WebCore::IDBServer::UniqueIDBDatabase::iterateCursor):
(WebCore::IDBServer::UniqueIDBDatabase::commitTransaction):
* Modules/indexeddb/server/UniqueIDBDatabase.h:
* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::usage):
* platform/sql/SQLiteFileSystem.cpp:
(WebCore::SQLiteFileSystem::getDatabaseFileSize):
* storage/StorageQuotaManager.h:
* storage/StorageQuotaManager.cpp:
(WebCore::StorageQuotaManager::requestSpace):

LayoutTests:

* storage/websql/open-database-creation-callback.html:
Bump quota for this test since WAL files are not included in quota computation.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243270 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/storage/websql/open-database-creation-callback.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp
Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp
Source/WebCore/platform/sql/SQLiteFileSystem.cpp
Source/WebCore/storage/StorageQuotaManager.cpp
Source/WebCore/storage/StorageQuotaManager.h