Title: [280415] trunk
Revision
280415
Author
[email protected]
Date
2021-07-28 21:04:18 -0700 (Wed, 28 Jul 2021)

Log Message

Implement IDBTransaction.durability
https://bugs.webkit.org/show_bug.cgi?id=228289

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/IndexedDB/idlharness.any-expected.txt:
* web-platform-tests/IndexedDB/idlharness.any.worker-expected.txt:
* web-platform-tests/IndexedDB/transaction-relaxed-durability.tentative.any-expected.txt:
* web-platform-tests/IndexedDB/transaction-relaxed-durability.tentative.any.worker-expected.txt:

Source/WebCore:

Spec: https://www.w3.org/TR/IndexedDB/#dom-idbtransaction-durability
      https://www.w3.org/TR/IndexedDB/#dictdef-idbtransactionoptions

IDBTransaction.durability gives a hint about durability of a transaction. If it's strict, backend would try
syncing data to database file after transaction commit, which enforces durability. If it's relaxed, it means
data may stay in the OS buffer some time after transaction commit, which gives better performance. Firefox and
Chrome already implemented durability. They have different ways of setting durability, and we choose to use
TransactionOptions as spec.

Rebaselined existing tests.
New tests: storage/indexeddb/idbtransaction-durability-private.html
           storage/indexeddb/idbtransaction-durability.html

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Headers.cmake:
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::transaction):
* Modules/indexeddb/IDBDatabase.h:
* Modules/indexeddb/IDBDatabase.idl:
* Modules/indexeddb/IDBTransaction.h:
* Modules/indexeddb/IDBTransaction.idl:
* Modules/indexeddb/IDBTransactionDurability.h: Added.
* Modules/indexeddb/IDBTransactionDurability.idl: Added.
* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::commitTransaction):
* Modules/indexeddb/server/SQLiteIDBTransaction.h:
(WebCore::IDBServer::SQLiteIDBTransaction::durability const):
* Modules/indexeddb/shared/IDBTransactionInfo.cpp:
(WebCore::IDBTransactionInfo::clientTransaction):
(WebCore::IDBTransactionInfo::IDBTransactionInfo):
(WebCore::IDBTransactionInfo::isolatedCopy):
* Modules/indexeddb/shared/IDBTransactionInfo.h:
(WebCore::IDBTransactionInfo::durability const):
(WebCore::IDBTransactionInfo::encode const):
(WebCore::IDBTransactionInfo::decode):
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/sql/SQLiteDatabase.cpp:
(WebCore::checkpointModeValue):
(WebCore::SQLiteDatabase::checkpoint):
(WebCore::SQLiteDatabase::useWALJournalMode):
* platform/sql/SQLiteDatabase.h:

LayoutTests:

* storage/indexeddb/idbtransaction-durability-expected.txt: Added.
* storage/indexeddb/idbtransaction-durability-private-expected.txt: Added.
* storage/indexeddb/idbtransaction-durability-private.html: Added.
* storage/indexeddb/idbtransaction-durability.html: Added.
* storage/indexeddb/resources/idbtransaction-durability.js: Added.
(onOpenUpgradeNeeded):
(onOpenSuccess):
(onTransactionComplete):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (280414 => 280415)


--- trunk/LayoutTests/ChangeLog	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/LayoutTests/ChangeLog	2021-07-29 04:04:18 UTC (rev 280415)
@@ -1,3 +1,19 @@
+2021-07-28  Sihui Liu  <[email protected]>
+
+        Implement IDBTransaction.durability
+        https://bugs.webkit.org/show_bug.cgi?id=228289
+
+        Reviewed by Darin Adler.
+
+        * storage/indexeddb/idbtransaction-durability-expected.txt: Added.
+        * storage/indexeddb/idbtransaction-durability-private-expected.txt: Added.
+        * storage/indexeddb/idbtransaction-durability-private.html: Added.
+        * storage/indexeddb/idbtransaction-durability.html: Added.
+        * storage/indexeddb/resources/idbtransaction-durability.js: Added.
+        (onOpenUpgradeNeeded):
+        (onOpenSuccess):
+        (onTransactionComplete):
+
 2021-07-28  Ayumi Kojima  <[email protected]>
 
         [ iPad ] platform/ipad/media/modern-media-controls/media-documents/media-document-audio-ios-sizing.html is a flaky timeout.

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (280414 => 280415)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-07-29 04:04:18 UTC (rev 280415)
@@ -1,5 +1,17 @@
 2021-07-28  Sihui Liu  <[email protected]>
 
+        Implement IDBTransaction.durability
+        https://bugs.webkit.org/show_bug.cgi?id=228289
+
+        Reviewed by Darin Adler.
+
+        * web-platform-tests/IndexedDB/idlharness.any-expected.txt:
+        * web-platform-tests/IndexedDB/idlharness.any.worker-expected.txt:
+        * web-platform-tests/IndexedDB/transaction-relaxed-durability.tentative.any-expected.txt:
+        * web-platform-tests/IndexedDB/transaction-relaxed-durability.tentative.any.worker-expected.txt:
+
+2021-07-28  Sihui Liu  <[email protected]>
+
         IDBFactory.databases should not return databases with invalid version
         https://bugs.webkit.org/show_bug.cgi?id=228554
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idlharness.any-expected.txt (280414 => 280415)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idlharness.any-expected.txt	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idlharness.any-expected.txt	2021-07-29 04:04:18 UTC (rev 280415)
@@ -185,7 +185,7 @@
 PASS IDBTransaction interface: existence and properties of interface prototype object's @@unscopables property
 PASS IDBTransaction interface: attribute objectStoreNames
 PASS IDBTransaction interface: attribute mode
-FAIL IDBTransaction interface: attribute durability assert_true: The prototype object must have a property "durability" expected true got false
+PASS IDBTransaction interface: attribute durability
 PASS IDBTransaction interface: attribute db
 PASS IDBTransaction interface: attribute error
 PASS IDBTransaction interface: operation objectStore(DOMString)

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idlharness.any.worker-expected.txt (280414 => 280415)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idlharness.any.worker-expected.txt	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idlharness.any.worker-expected.txt	2021-07-29 04:04:18 UTC (rev 280415)
@@ -185,7 +185,7 @@
 PASS IDBTransaction interface: existence and properties of interface prototype object's @@unscopables property
 PASS IDBTransaction interface: attribute objectStoreNames
 PASS IDBTransaction interface: attribute mode
-FAIL IDBTransaction interface: attribute durability assert_true: The prototype object must have a property "durability" expected true got false
+PASS IDBTransaction interface: attribute durability
 PASS IDBTransaction interface: attribute db
 PASS IDBTransaction interface: attribute error
 PASS IDBTransaction interface: operation objectStore(DOMString)

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/transaction-relaxed-durability.tentative.any-expected.txt (280414 => 280415)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/transaction-relaxed-durability.tentative.any-expected.txt	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/transaction-relaxed-durability.tentative.any-expected.txt	2021-07-29 04:04:18 UTC (rev 280415)
@@ -1,10 +1,8 @@
 
-FAIL Committed data can be read back out: case 0 assert_equals: expected (string) "default" but got (undefined) undefined
-FAIL Committed data can be read back out: case 1 assert_equals: expected (string) "default" but got (undefined) undefined
-FAIL Committed data can be read back out: case 2 assert_equals: expected (string) "default" but got (undefined) undefined
-FAIL Committed data can be read back out: case 3 assert_equals: expected (string) "relaxed" but got (undefined) undefined
-FAIL Committed data can be read back out: case 4 assert_equals: expected (string) "strict" but got (undefined) undefined
-FAIL Invalid durability option throws a TypeError assert_throws_js: function "function () {
-      db.transaction(['books'], 'readwrite', { durability: 'invalid' });
-  }" did not throw
+PASS Committed data can be read back out: case 0
+PASS Committed data can be read back out: case 1
+PASS Committed data can be read back out: case 2
+PASS Committed data can be read back out: case 3
+PASS Committed data can be read back out: case 4
+PASS Invalid durability option throws a TypeError
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/transaction-relaxed-durability.tentative.any.worker-expected.txt (280414 => 280415)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/transaction-relaxed-durability.tentative.any.worker-expected.txt	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/transaction-relaxed-durability.tentative.any.worker-expected.txt	2021-07-29 04:04:18 UTC (rev 280415)
@@ -1,10 +1,8 @@
 
-FAIL Committed data can be read back out: case 0 assert_equals: expected (string) "default" but got (undefined) undefined
-FAIL Committed data can be read back out: case 1 assert_equals: expected (string) "default" but got (undefined) undefined
-FAIL Committed data can be read back out: case 2 assert_equals: expected (string) "default" but got (undefined) undefined
-FAIL Committed data can be read back out: case 3 assert_equals: expected (string) "relaxed" but got (undefined) undefined
-FAIL Committed data can be read back out: case 4 assert_equals: expected (string) "strict" but got (undefined) undefined
-FAIL Invalid durability option throws a TypeError assert_throws_js: function "function () {
-      db.transaction(['books'], 'readwrite', { durability: 'invalid' });
-  }" did not throw
+PASS Committed data can be read back out: case 0
+PASS Committed data can be read back out: case 1
+PASS Committed data can be read back out: case 2
+PASS Committed data can be read back out: case 3
+PASS Committed data can be read back out: case 4
+PASS Invalid durability option throws a TypeError
 

Added: trunk/LayoutTests/storage/indexeddb/idbtransaction-durability-expected.txt (0 => 280415)


--- trunk/LayoutTests/storage/indexeddb/idbtransaction-durability-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/idbtransaction-durability-expected.txt	2021-07-29 04:04:18 UTC (rev 280415)
@@ -0,0 +1,24 @@
+Ensure durability of transaction is expected
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
+
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
+
+onOpenUpgradeNeeded():
+database = event.target.result
+PASS event.target.transaction.durability is "default"
+
+onOpenSuccess():
+transaction = database.transaction('objectstore')
+PASS transaction.durability is "default"
+
+onTransactionComplete():
+PASS transaction.durability is "default"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/storage/indexeddb/idbtransaction-durability-private-expected.txt (0 => 280415)


--- trunk/LayoutTests/storage/indexeddb/idbtransaction-durability-private-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/idbtransaction-durability-private-expected.txt	2021-07-29 04:04:18 UTC (rev 280415)
@@ -0,0 +1,24 @@
+Ensure durability of transaction is expected
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
+
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
+
+onOpenUpgradeNeeded():
+database = event.target.result
+PASS event.target.transaction.durability is "default"
+
+onOpenSuccess():
+transaction = database.transaction('objectstore')
+PASS transaction.durability is "default"
+
+onTransactionComplete():
+PASS transaction.durability is "default"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/storage/indexeddb/idbtransaction-durability-private.html (0 => 280415)


--- trunk/LayoutTests/storage/indexeddb/idbtransaction-durability-private.html	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/idbtransaction-durability-private.html	2021-07-29 04:04:18 UTC (rev 280415)
@@ -0,0 +1,10 @@
+<!-- webkit-test-runner [ useEphemeralSession=true ] -->
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<script src=""
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/storage/indexeddb/idbtransaction-durability.html (0 => 280415)


--- trunk/LayoutTests/storage/indexeddb/idbtransaction-durability.html	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/idbtransaction-durability.html	2021-07-29 04:04:18 UTC (rev 280415)
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<script src=""
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/storage/indexeddb/resources/idbtransaction-durability.js (0 => 280415)


--- trunk/LayoutTests/storage/indexeddb/resources/idbtransaction-durability.js	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/resources/idbtransaction-durability.js	2021-07-29 04:04:18 UTC (rev 280415)
@@ -0,0 +1,34 @@
+if (this.importScripts) {
+    importScripts('../../../resources/js-test.js');
+    importScripts('shared.js');
+}
+
+description('Ensure durability of transaction is expected');
+
+indexedDBTest(onOpenUpgradeNeeded, onOpenSuccess);
+
+function onOpenUpgradeNeeded(event)
+{
+    preamble(event);
+
+    database = evalAndLog('database = event.target.result');
+    database.createObjectStore('objectstore');
+    shouldBeEqualToString('event.target.transaction.durability', 'default');
+}
+
+function onOpenSuccess(event)
+{
+    preamble(event);
+
+    transaction = evalAndLog("transaction = database.transaction('objectstore')");
+    transaction._oncomplete_ = onTransactionComplete;
+    shouldBeEqualToString('transaction.durability', 'default');
+}
+
+function onTransactionComplete(event)
+{
+    preamble(event);
+
+    shouldBeEqualToString('transaction.durability', 'default');
+    finishJSTest();
+}
\ No newline at end of file

Modified: trunk/Source/WebCore/CMakeLists.txt (280414 => 280415)


--- trunk/Source/WebCore/CMakeLists.txt	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/CMakeLists.txt	2021-07-29 04:04:18 UTC (rev 280415)
@@ -303,6 +303,7 @@
     Modules/indexeddb/IDBOpenDBRequest.idl
     Modules/indexeddb/IDBRequest.idl
     Modules/indexeddb/IDBTransaction.idl
+    Modules/indexeddb/IDBTransactionDurability.idl
     Modules/indexeddb/IDBTransactionMode.idl
     Modules/indexeddb/IDBVersionChangeEvent.idl
     Modules/indexeddb/WindowOrWorkerGlobalScope+IndexedDatabase.idl

Modified: trunk/Source/WebCore/ChangeLog (280414 => 280415)


--- trunk/Source/WebCore/ChangeLog	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/ChangeLog	2021-07-29 04:04:18 UTC (rev 280415)
@@ -1,5 +1,58 @@
 2021-07-28  Sihui Liu  <[email protected]>
 
+        Implement IDBTransaction.durability
+        https://bugs.webkit.org/show_bug.cgi?id=228289
+
+        Reviewed by Darin Adler.
+
+        Spec: https://www.w3.org/TR/IndexedDB/#dom-idbtransaction-durability
+              https://www.w3.org/TR/IndexedDB/#dictdef-idbtransactionoptions
+
+        IDBTransaction.durability gives a hint about durability of a transaction. If it's strict, backend would try
+        syncing data to database file after transaction commit, which enforces durability. If it's relaxed, it means 
+        data may stay in the OS buffer some time after transaction commit, which gives better performance. Firefox and 
+        Chrome already implemented durability. They have different ways of setting durability, and we choose to use
+        TransactionOptions as spec.
+
+        Rebaselined existing tests.
+        New tests: storage/indexeddb/idbtransaction-durability-private.html
+                   storage/indexeddb/idbtransaction-durability.html
+
+        * CMakeLists.txt:
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Headers.cmake:
+        * Modules/indexeddb/IDBDatabase.cpp:
+        (WebCore::IDBDatabase::transaction):
+        * Modules/indexeddb/IDBDatabase.h:
+        * Modules/indexeddb/IDBDatabase.idl:
+        * Modules/indexeddb/IDBTransaction.h:
+        * Modules/indexeddb/IDBTransaction.idl:
+        * Modules/indexeddb/IDBTransactionDurability.h: Added.
+        * Modules/indexeddb/IDBTransactionDurability.idl: Added.
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+        (WebCore::IDBServer::SQLiteIDBBackingStore::commitTransaction):
+        * Modules/indexeddb/server/SQLiteIDBTransaction.h:
+        (WebCore::IDBServer::SQLiteIDBTransaction::durability const):
+        * Modules/indexeddb/shared/IDBTransactionInfo.cpp:
+        (WebCore::IDBTransactionInfo::clientTransaction):
+        (WebCore::IDBTransactionInfo::IDBTransactionInfo):
+        (WebCore::IDBTransactionInfo::isolatedCopy):
+        * Modules/indexeddb/shared/IDBTransactionInfo.h:
+        (WebCore::IDBTransactionInfo::durability const):
+        (WebCore::IDBTransactionInfo::encode const):
+        (WebCore::IDBTransactionInfo::decode):
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/sql/SQLiteDatabase.cpp:
+        (WebCore::checkpointModeValue):
+        (WebCore::SQLiteDatabase::checkpoint):
+        (WebCore::SQLiteDatabase::useWALJournalMode):
+        * platform/sql/SQLiteDatabase.h:
+
+2021-07-28  Sihui Liu  <[email protected]>
+
         IDBFactory.databases should not return databases with invalid version
         https://bugs.webkit.org/show_bug.cgi?id=228554
 

Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (280414 => 280415)


--- trunk/Source/WebCore/DerivedSources-input.xcfilelist	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist	2021-07-29 04:04:18 UTC (rev 280415)
@@ -151,6 +151,7 @@
 $(PROJECT_DIR)/Modules/indexeddb/IDBOpenDBRequest.idl
 $(PROJECT_DIR)/Modules/indexeddb/IDBRequest.idl
 $(PROJECT_DIR)/Modules/indexeddb/IDBTransaction.idl
+$(PROJECT_DIR)/Modules/indexeddb/IDBTransactionDurability.idl
 $(PROJECT_DIR)/Modules/indexeddb/IDBTransactionMode.idl
 $(PROJECT_DIR)/Modules/indexeddb/IDBVersionChangeEvent.idl
 $(PROJECT_DIR)/Modules/indexeddb/WindowOrWorkerGlobalScope+IndexedDatabase.idl

Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (280414 => 280415)


--- trunk/Source/WebCore/DerivedSources-output.xcfilelist	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist	2021-07-29 04:04:18 UTC (rev 280415)
@@ -1167,6 +1167,8 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIDBRequest.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIDBTransaction.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIDBTransaction.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIDBTransactionDurability.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIDBTransactionDurability.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIDBTransactionMode.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIDBTransactionMode.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIDBVersionChangeEvent.cpp

Modified: trunk/Source/WebCore/DerivedSources.make (280414 => 280415)


--- trunk/Source/WebCore/DerivedSources.make	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/DerivedSources.make	2021-07-29 04:04:18 UTC (rev 280415)
@@ -177,6 +177,7 @@
     $(WebCore)/Modules/indexeddb/IDBOpenDBRequest.idl \
     $(WebCore)/Modules/indexeddb/IDBRequest.idl \
     $(WebCore)/Modules/indexeddb/IDBTransaction.idl \
+	$(WebCore)/Modules/indexeddb/IDBTransactionDurability.idl \
     $(WebCore)/Modules/indexeddb/IDBTransactionMode.idl \
     $(WebCore)/Modules/indexeddb/IDBVersionChangeEvent.idl \
     $(WebCore)/Modules/indexeddb/WindowOrWorkerGlobalScope+IndexedDatabase.idl \

Modified: trunk/Source/WebCore/Headers.cmake (280414 => 280415)


--- trunk/Source/WebCore/Headers.cmake	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/Headers.cmake	2021-07-29 04:04:18 UTC (rev 280415)
@@ -66,6 +66,7 @@
     Modules/indexeddb/IDBOpenDBRequest.h
     Modules/indexeddb/IDBRequest.h
     Modules/indexeddb/IDBTransaction.h
+    Modules/indexeddb/IDBTransactionDurability.h
     Modules/indexeddb/IDBTransactionMode.h
     Modules/indexeddb/IDBValue.h
     Modules/indexeddb/IndexedDB.h

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp (280414 => 280415)


--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp	2021-07-29 04:04:18 UTC (rev 280415)
@@ -162,7 +162,7 @@
     return m_versionChangeTransaction->createObjectStore(info);
 }
 
-ExceptionOr<Ref<IDBTransaction>> IDBDatabase::transaction(StringOrVectorOfStrings&& storeNames, IDBTransactionMode mode)
+ExceptionOr<Ref<IDBTransaction>> IDBDatabase::transaction(StringOrVectorOfStrings&& storeNames, IDBTransactionMode mode, TransactionOptions options)
 {
     LOG(IndexedDB, "IDBDatabase::transaction");
 
@@ -200,7 +200,7 @@
     if (mode != IDBTransactionMode::Readonly && mode != IDBTransactionMode::Readwrite)
         return Exception { TypeError };
 
-    auto info = IDBTransactionInfo::clientTransaction(m_connectionProxy.get(), objectStores, mode);
+    auto info = IDBTransactionInfo::clientTransaction(m_connectionProxy.get(), objectStores, mode, options.durability);
 
     LOG(IndexedDBOperations, "IDB creating transaction: %s", info.loggingString().utf8().data());
     auto transaction = IDBTransaction::create(*this, info);

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h (280414 => 280415)


--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h	2021-07-29 04:04:18 UTC (rev 280415)
@@ -63,7 +63,10 @@
     ExceptionOr<Ref<IDBObjectStore>> createObjectStore(const String& name, ObjectStoreParameters&&);
 
     using StringOrVectorOfStrings = WTF::Variant<String, Vector<String>>;
-    ExceptionOr<Ref<IDBTransaction>> transaction(StringOrVectorOfStrings&& storeNames, IDBTransactionMode);
+    struct TransactionOptions {
+        std::optional<IDBTransactionDurability> durability;
+    };
+    ExceptionOr<Ref<IDBTransaction>> transaction(StringOrVectorOfStrings&& storeNames, IDBTransactionMode, TransactionOptions = { });
     ExceptionOr<void> deleteObjectStore(const String& name);
     void close();
 

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.idl (280414 => 280415)


--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.idl	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.idl	2021-07-29 04:04:18 UTC (rev 280415)
@@ -33,8 +33,7 @@
     readonly attribute unsigned long long version;
     readonly attribute DOMStringList objectStoreNames;
 
-    // FIXME: 'transaction' should also take an optional 'IDBTransactionOptions' argument.
-    [NewObject] IDBTransaction transaction((DOMString or sequence<DOMString>) storeNames, optional IDBTransactionMode mode = "readonly");
+    [NewObject] IDBTransaction transaction((DOMString or sequence<DOMString>) storeNames, optional IDBTransactionMode mode = "readonly", optional IDBTransactionOptions options);
     undefined close();
 
     [NewObject] IDBObjectStore createObjectStore(DOMString name, optional IDBObjectStoreParameters parameters);
@@ -55,3 +54,7 @@
     (DOMString or sequence<DOMString>)? keyPath = null;
     boolean autoIncrement = false;
 };
+
+dictionary IDBTransactionOptions {
+    IDBTransactionDurability durability = "default";
+};

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h (280414 => 280415)


--- trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h	2021-07-29 04:04:18 UTC (rev 280415)
@@ -77,6 +77,7 @@
     // IDBTransaction IDL
     Ref<DOMStringList> objectStoreNames() const;
     IDBTransactionMode mode() const { return m_info.mode(); }
+    IDBTransactionDurability durability() const { return m_info.durability(); }
     IDBDatabase* db();
     DOMException* error() const;
     ExceptionOr<Ref<IDBObjectStore>> objectStore(const String& name);

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.idl (280414 => 280415)


--- trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.idl	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.idl	2021-07-29 04:04:18 UTC (rev 280415)
@@ -32,8 +32,7 @@
 ] interface IDBTransaction : EventTarget {
     readonly attribute DOMStringList objectStoreNames;
     readonly attribute IDBTransactionMode mode;
-    // Implement 'durability'.
-    // readonly attribute IDBTransactionDurability durability;
+    readonly attribute IDBTransactionDurability durability;
     [SameObject] readonly attribute IDBDatabase db;
     readonly attribute DOMException? error;
 

Added: trunk/Source/WebCore/Modules/indexeddb/IDBTransactionDurability.h (0 => 280415)


--- trunk/Source/WebCore/Modules/indexeddb/IDBTransactionDurability.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransactionDurability.h	2021-07-29 04:04:18 UTC (rev 280415)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/EnumTraits.h>
+
+namespace WebCore {
+
+enum class IDBTransactionDurability : uint8_t {
+    Strict,
+    Relaxed,
+    Default
+};
+
+} // namespace WebCore
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::IDBTransactionDurability> {
+    using values = EnumValues<
+        WebCore::IDBTransactionDurability,
+        WebCore::IDBTransactionDurability::Strict,
+        WebCore::IDBTransactionDurability::Relaxed,
+        WebCore::IDBTransactionDurability::Default
+    >;
+};
+
+} // namespace WTF

Added: trunk/Source/WebCore/Modules/indexeddb/IDBTransactionDurability.idl (0 => 280415)


--- trunk/Source/WebCore/Modules/indexeddb/IDBTransactionDurability.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransactionDurability.idl	2021-07-29 04:04:18 UTC (rev 280415)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2021 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+] enum IDBTransactionDurability {
+    "strict",
+    "relaxed",
+    "default"
+};

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (280414 => 280415)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2021-07-29 04:04:18 UTC (rev 280415)
@@ -1149,8 +1149,11 @@
             ASSERT(m_originalDatabaseInfoBeforeVersionChange);
             m_databaseInfo = WTFMove(m_originalDatabaseInfoBeforeVersionChange);
         }
-    } else
+    } else {
         m_originalDatabaseInfoBeforeVersionChange = nullptr;
+        if (transaction->durability() == IDBTransactionDurability::Strict)
+            m_sqliteDB->checkpoint(SQLiteDatabase::CheckpointMode::Full);
+    }
 
     return error;
 }

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.h (280414 => 280415)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.h	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.h	2021-07-29 04:04:18 UTC (rev 280415)
@@ -65,6 +65,7 @@
     void notifyCursorsOfChanges(int64_t objectStoreID);
 
     IDBTransactionMode mode() const { return m_info.mode(); }
+    IDBTransactionDurability durability() const { return m_info.durability(); }
     bool inProgress() const;
 
     SQLiteTransaction* sqliteTransaction() const { return m_sqliteTransaction.get(); }

Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.cpp (280414 => 280415)


--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.cpp	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.cpp	2021-07-29 04:04:18 UTC (rev 280415)
@@ -39,11 +39,13 @@
 {
 }
 
-IDBTransactionInfo IDBTransactionInfo::clientTransaction(const IDBClient::IDBConnectionProxy& connectionProxy, const Vector<String>& objectStores, IDBTransactionMode mode)
+IDBTransactionInfo IDBTransactionInfo::clientTransaction(const IDBClient::IDBConnectionProxy& connectionProxy, const Vector<String>& objectStores, IDBTransactionMode mode, std::optional<IDBTransactionDurability> durability)
 {
     IDBTransactionInfo result((IDBResourceIdentifier(connectionProxy)));
+    result.m_objectStores = objectStores;
     result.m_mode = mode;
-    result.m_objectStores = objectStores;
+    if (durability)
+        result.m_durability = *durability;
 
     return result;
 }
@@ -61,6 +63,7 @@
 IDBTransactionInfo::IDBTransactionInfo(const IDBTransactionInfo& info)
     : m_identifier(info.identifier())
     , m_mode(info.m_mode)
+    , m_durability(info.m_durability)
     , m_newVersion(info.m_newVersion)
     , m_objectStores(info.m_objectStores)
 {
@@ -82,6 +85,7 @@
 {
     destination.m_identifier = source.m_identifier.isolatedCopy();
     destination.m_mode = source.m_mode;
+    destination.m_durability = source.m_durability;
     destination.m_newVersion = source.m_newVersion;
 
     destination.m_objectStores.reserveCapacity(source.m_objectStores.size());

Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.h (280414 => 280415)


--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.h	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.h	2021-07-29 04:04:18 UTC (rev 280415)
@@ -27,6 +27,7 @@
 
 #include "IDBDatabaseInfo.h"
 #include "IDBResourceIdentifier.h"
+#include "IDBTransactionDurability.h"
 #include "IDBTransactionMode.h"
 #include "IndexedDB.h"
 #include <wtf/Vector.h>
@@ -44,7 +45,7 @@
 class IDBTransactionInfo {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    static IDBTransactionInfo clientTransaction(const IDBClient::IDBConnectionProxy&, const Vector<String>& objectStores, IDBTransactionMode);
+    static IDBTransactionInfo clientTransaction(const IDBClient::IDBConnectionProxy&, const Vector<String>& objectStores, IDBTransactionMode, std::optional<IDBTransactionDurability>);
     static IDBTransactionInfo versionChange(const IDBServer::IDBConnectionToClient&, const IDBDatabaseInfo& originalDatabaseInfo, uint64_t newVersion);
 
     WEBCORE_EXPORT IDBTransactionInfo(const IDBTransactionInfo&);
@@ -59,6 +60,7 @@
     const IDBResourceIdentifier& identifier() const { return m_identifier; }
 
     IDBTransactionMode mode() const { return m_mode; }
+    IDBTransactionDurability durability() const { return m_durability; }
     uint64_t newVersion() const { return m_newVersion; }
 
     const Vector<String>& objectStores() const { return m_objectStores; }
@@ -81,6 +83,7 @@
     IDBResourceIdentifier m_identifier;
 
     IDBTransactionMode m_mode { IDBTransactionMode::Readonly };
+    IDBTransactionDurability m_durability { IDBTransactionDurability::Default };
     uint64_t m_newVersion { 0 };
     Vector<String> m_objectStores;
     std::unique_ptr<IDBDatabaseInfo> m_originalDatabaseInfo;
@@ -90,7 +93,7 @@
 void IDBTransactionInfo::encode(Encoder& encoder) const
 {
     encoder << m_identifier << m_newVersion << m_objectStores;
-    encoder << m_mode;
+    encoder << m_mode << m_durability;
 
     encoder << !!m_originalDatabaseInfo;
     if (m_originalDatabaseInfo)
@@ -112,6 +115,9 @@
     if (!decoder.decode(info.m_mode))
         return false;
 
+    if (!decoder.decode(info.m_durability))
+        return false;
+
     bool hasObject;
     if (!decoder.decode(hasObject))
         return false;

Modified: trunk/Source/WebCore/Sources.txt (280414 => 280415)


--- trunk/Source/WebCore/Sources.txt	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/Sources.txt	2021-07-29 04:04:18 UTC (rev 280415)
@@ -3210,6 +3210,7 @@
 JSIDBOpenDBRequest.cpp
 JSIDBRequest.cpp
 JSIDBTransaction.cpp
+JSIDBTransactionDurability.cpp
 JSIDBTransactionMode.cpp
 JSIDBVersionChangeEvent.cpp
 JSIdleDeadline.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (280414 => 280415)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-07-29 04:04:18 UTC (rev 280415)
@@ -2849,6 +2849,7 @@
 		935F45430F7C3B5F00D7C1FB /* JSLazyEventListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 935F45410F7C3B5F00D7C1FB /* JSLazyEventListener.h */; };
 		935FBC4509BA00B900E230B1 /* EventListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 935FBC4409BA00B900E230B1 /* EventListener.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		935FBCF209BA143B00E230B1 /* ExceptionCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 935FBCF109BA143B00E230B1 /* ExceptionCode.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		936583B726AB92B5004E61F4 /* IDBTransactionDurability.h in Headers */ = {isa = PBXBuildFile; fileRef = 936583B626AB9174004E61F4 /* IDBTransactionDurability.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9370918D1416D86B00477333 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 9370918C1416D86B00477333 /* [email protected] */; };
 		9377ABA015DEFEEF0031FD04 /* Pagination.h in Headers */ = {isa = PBXBuildFile; fileRef = 9377AB9F15DEFEEF0031FD04 /* Pagination.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		937FF3D51A1012D6008EBA31 /* DictionaryLookup.h in Headers */ = {isa = PBXBuildFile; fileRef = 937FF3D41A1012D6008EBA31 /* DictionaryLookup.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -11706,6 +11707,8 @@
 		935F45410F7C3B5F00D7C1FB /* JSLazyEventListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSLazyEventListener.h; sourceTree = "<group>"; };
 		935FBC4409BA00B900E230B1 /* EventListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventListener.h; sourceTree = "<group>"; };
 		935FBCF109BA143B00E230B1 /* ExceptionCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExceptionCode.h; sourceTree = "<group>"; };
+		936583B426AB8CB4004E61F4 /* IDBTransactionDurability.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = IDBTransactionDurability.idl; sourceTree = "<group>"; };
+		936583B626AB9174004E61F4 /* IDBTransactionDurability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBTransactionDurability.h; sourceTree = "<group>"; };
 		936B21F41DBBF8300052E117 /* CanvasPath.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CanvasPath.idl; sourceTree = "<group>"; };
 		936DD03A09CEAC270056AE8C /* Range.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Range.idl; sourceTree = "<group>"; };
 		9370918C1416D86B00477333 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
@@ -24432,6 +24435,8 @@
 				51645B501B9F889B00F789CE /* IDBTransaction.cpp */,
 				51645B511B9F889B00F789CE /* IDBTransaction.h */,
 				51D719A6181106E00016DC51 /* IDBTransaction.idl */,
+				936583B626AB9174004E61F4 /* IDBTransactionDurability.h */,
+				936583B426AB8CB4004E61F4 /* IDBTransactionDurability.idl */,
 				838EF5361DC149DA008F0C39 /* IDBTransactionMode.h */,
 				838EF5371DC149DA008F0C39 /* IDBTransactionMode.idl */,
 				516103AD1CADB9A30016B4C7 /* IDBValue.cpp */,
@@ -33127,6 +33132,7 @@
 				9323B07023061F9700901C8B /* IDBSerializationContext.h in Headers */,
 				5185FCBB1BB4CBF80012898F /* IDBServer.h in Headers */,
 				5185FCAD1BB4C4E80012898F /* IDBTransaction.h in Headers */,
+				936583B726AB92B5004E61F4 /* IDBTransactionDurability.h in Headers */,
 				5198F7AD1BBDD3EB00E2CC5F /* IDBTransactionInfo.h in Headers */,
 				838EF5381DC149E2008F0C39 /* IDBTransactionMode.h in Headers */,
 				516103AF1CADBA770016B4C7 /* IDBValue.h in Headers */,

Modified: trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp (280414 => 280415)


--- trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp	2021-07-29 04:04:18 UTC (rev 280415)
@@ -192,6 +192,31 @@
     sqlite3_wal_hook(m_db, walAutomaticTruncationHook, nullptr);
 }
 
+static int checkpointModeValue(SQLiteDatabase::CheckpointMode mode)
+{
+    switch (mode) {
+    case SQLiteDatabase::CheckpointMode::Full:
+        return SQLITE_CHECKPOINT_FULL;
+    case SQLiteDatabase::CheckpointMode::Truncate:
+        return SQLITE_CHECKPOINT_TRUNCATE;
+    }
+}
+
+void SQLiteDatabase::checkpoint(CheckpointMode mode)
+{
+    SQLiteTransactionInProgressAutoCounter transactionCounter;
+    int result = sqlite3_wal_checkpoint_v2(m_db, nullptr, checkpointModeValue(mode), nullptr, nullptr);
+    if (result == SQLITE_OK)
+        return;
+
+    if (result == SQLITE_BUSY) {
+        LOG(SQLDatabase, "SQLite database checkpoint is blocked");
+        return;
+    }
+
+    LOG_ERROR("SQLite database failed to checkpoint: %s", lastErrorMsg());
+}
+
 void SQLiteDatabase::useWALJournalMode()
 {
     m_useWAL = true;
@@ -207,15 +232,7 @@
             LOG_ERROR("SQLite database failed to set journal_mode to WAL, error: %s", lastErrorMsg());
     }
 
-    {
-        SQLiteTransactionInProgressAutoCounter transactionCounter;
-        auto checkpointStatement = prepareStatement("PRAGMA wal_checkpoint(TRUNCATE)"_s);
-        if (checkpointStatement && checkpointStatement->step() == SQLITE_ROW) {
-            if (checkpointStatement->columnInt(0))
-                LOG(SQLDatabase, "SQLite database checkpoint is blocked");
-        } else
-            LOG_ERROR("SQLite database failed to checkpoint: %s", lastErrorMsg());
-    }
+    checkpoint(CheckpointMode::Truncate);
 }
 
 void SQLiteDatabase::close(ShouldSetErrorState shouldSetErrorState)

Modified: trunk/Source/WebCore/platform/sql/SQLiteDatabase.h (280414 => 280415)


--- trunk/Source/WebCore/platform/sql/SQLiteDatabase.h	2021-07-29 02:33:05 UTC (rev 280414)
+++ trunk/Source/WebCore/platform/sql/SQLiteDatabase.h	2021-07-29 04:04:18 UTC (rev 280415)
@@ -97,6 +97,8 @@
     // SQLITE_CHECKPOINT_TRUNCATE will invoke the busy handler if it can't acquire the necessary
     // locks, which can lead to unintended delays.
     void enableAutomaticWALTruncation();
+    enum class CheckpointMode : uint8_t { Full, Truncate };
+    void checkpoint(CheckpointMode);
 
     // Gets/sets the maximum size in bytes
     // Depending on per-database attributes, the size will only be settable in units that are the page size of the database, which is established at creation
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to